@cynnie/ui-element 0.1.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.
- package/README.md +35 -0
- package/dist/ProButton-BfUxqs4G.js +53 -0
- package/dist/ProButton-BfUxqs4G.js.map +1 -0
- package/dist/ProCheckboxGroup-BbooVQg4.js +52 -0
- package/dist/ProCheckboxGroup-BbooVQg4.js.map +1 -0
- package/dist/ProConfirmButton-BiZ2aUaM.js +49 -0
- package/dist/ProConfirmButton-BiZ2aUaM.js.map +1 -0
- package/dist/ProDescriptions-DerGI86i.js +46 -0
- package/dist/ProDescriptions-DerGI86i.js.map +1 -0
- package/dist/ProFormBuilder-DDzUy-ZE.js +473 -0
- package/dist/ProFormBuilder-DDzUy-ZE.js.map +1 -0
- package/dist/ProInput-BnjX-7sv.js +40 -0
- package/dist/ProInput-BnjX-7sv.js.map +1 -0
- package/dist/ProModal-CTIpMv3y.js +63 -0
- package/dist/ProModal-CTIpMv3y.js.map +1 -0
- package/dist/ProRadioGroup-CXhwhi2P.js +52 -0
- package/dist/ProRadioGroup-CXhwhi2P.js.map +1 -0
- package/dist/ProSelect-DH8Nm5LN.js +401 -0
- package/dist/ProSelect-DH8Nm5LN.js.map +1 -0
- package/dist/ProTable-DXAnL7FT.js +166 -0
- package/dist/ProTable-DXAnL7FT.js.map +1 -0
- package/dist/_Uint8Array-CZRAGBxP.js +608 -0
- package/dist/_Uint8Array-CZRAGBxP.js.map +1 -0
- package/dist/components/ProButton/ProCountdownButton.vue.d.ts +28 -0
- package/dist/components/ProButton/index.js +2 -0
- package/dist/components/ProButton/index.vue.d.ts +25 -0
- package/dist/components/ProCheckboxGroup/index.js +2 -0
- package/dist/components/ProCheckboxGroup/index.vue.d.ts +18 -0
- package/dist/components/ProConfirmButton/index.js +2 -0
- package/dist/components/ProConfirmButton/index.vue.d.ts +25 -0
- package/dist/components/ProDescriptions/index.js +2 -0
- package/dist/components/ProDescriptions/index.vue.d.ts +36 -0
- package/dist/components/ProFormBuilder/index.js +2 -0
- package/dist/components/ProFormBuilder/index.vue.d.ts +38 -0
- package/dist/components/ProInput/index.js +2 -0
- package/dist/components/ProInput/index.vue.d.ts +28 -0
- package/dist/components/ProModal/index.js +2 -0
- package/dist/components/ProModal/index.vue.d.ts +32 -0
- package/dist/components/ProRadioGroup/index.js +2 -0
- package/dist/components/ProRadioGroup/index.vue.d.ts +18 -0
- package/dist/components/ProSelect/index.js +2 -0
- package/dist/components/ProSelect/index.vue.d.ts +33 -0
- package/dist/components/ProTable/ProTableForm.vue.d.ts +86 -0
- package/dist/components/ProTable/index.js +2 -0
- package/dist/components/ProTable/index.vue.d.ts +36 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/openDialog-BfikyMPD.js +79 -0
- package/dist/openDialog-BfikyMPD.js.map +1 -0
- package/dist/utils/openDialog.d.ts +24 -0
- package/dist/utils/openDialog.js +2 -0
- package/dist/utils/uiMessage.d.ts +9 -0
- package/package.json +96 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { FormItem, FormRules } from '@cynnie/ui-core';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
formItems: FormItem[];
|
|
4
|
+
rules?: FormRules;
|
|
5
|
+
formData: Record<string, any>;
|
|
6
|
+
requestApi: (data: Record<string, any>) => Promise<any>;
|
|
7
|
+
};
|
|
8
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {
|
|
9
|
+
submit(): Promise<any>;
|
|
10
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
11
|
+
formRef: {
|
|
12
|
+
$: import('vue').ComponentInternalInstance;
|
|
13
|
+
$data: {};
|
|
14
|
+
$props: {
|
|
15
|
+
readonly modelValue?: Record<string, any>;
|
|
16
|
+
readonly formItems: FormItem[];
|
|
17
|
+
readonly rules?: Record<string, any>;
|
|
18
|
+
readonly span?: number;
|
|
19
|
+
readonly formConfig?: Record<string, any>;
|
|
20
|
+
readonly "onUpdate:modelValue"?: (value: Record<string, any>) => any;
|
|
21
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps;
|
|
22
|
+
$attrs: {
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
$refs: {
|
|
26
|
+
[x: string]: unknown;
|
|
27
|
+
} & {
|
|
28
|
+
formRef: unknown;
|
|
29
|
+
};
|
|
30
|
+
$slots: Readonly<{
|
|
31
|
+
[name: string]: import('vue').Slot<any>;
|
|
32
|
+
}>;
|
|
33
|
+
$root: import('vue').ComponentPublicInstance | null;
|
|
34
|
+
$parent: import('vue').ComponentPublicInstance | null;
|
|
35
|
+
$host: Element | null;
|
|
36
|
+
$emit: (event: "update:modelValue", value: Record<string, any>) => void;
|
|
37
|
+
$el: any;
|
|
38
|
+
$options: import('vue').ComponentOptionsBase<Readonly<{
|
|
39
|
+
modelValue?: Record<string, any>;
|
|
40
|
+
} & {
|
|
41
|
+
formItems: FormItem[];
|
|
42
|
+
rules?: Record<string, any>;
|
|
43
|
+
span?: number;
|
|
44
|
+
formConfig?: Record<string, any>;
|
|
45
|
+
}> & Readonly<{
|
|
46
|
+
"onUpdate:modelValue"?: (value: Record<string, any>) => any;
|
|
47
|
+
}>, {
|
|
48
|
+
validate: () => any;
|
|
49
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
50
|
+
"update:modelValue": (value: Record<string, any>) => any;
|
|
51
|
+
}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & {
|
|
52
|
+
beforeCreate?: (() => void) | (() => void)[];
|
|
53
|
+
created?: (() => void) | (() => void)[];
|
|
54
|
+
beforeMount?: (() => void) | (() => void)[];
|
|
55
|
+
mounted?: (() => void) | (() => void)[];
|
|
56
|
+
beforeUpdate?: (() => void) | (() => void)[];
|
|
57
|
+
updated?: (() => void) | (() => void)[];
|
|
58
|
+
activated?: (() => void) | (() => void)[];
|
|
59
|
+
deactivated?: (() => void) | (() => void)[];
|
|
60
|
+
beforeDestroy?: (() => void) | (() => void)[];
|
|
61
|
+
beforeUnmount?: (() => void) | (() => void)[];
|
|
62
|
+
destroyed?: (() => void) | (() => void)[];
|
|
63
|
+
unmounted?: (() => void) | (() => void)[];
|
|
64
|
+
renderTracked?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
|
|
65
|
+
renderTriggered?: ((e: import('vue').DebuggerEvent) => void) | ((e: import('vue').DebuggerEvent) => void)[];
|
|
66
|
+
errorCaptured?: ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import('vue').ComponentPublicInstance | null, info: string) => boolean | void)[];
|
|
67
|
+
};
|
|
68
|
+
$forceUpdate: () => void;
|
|
69
|
+
$nextTick: typeof import('vue').nextTick;
|
|
70
|
+
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, import('@vue/reactivity').OnCleanup]) => any : (...args: [any, any, import('@vue/reactivity').OnCleanup]) => any, options?: import('vue').WatchOptions): import('vue').WatchStopHandle;
|
|
71
|
+
} & Readonly<{}> & Omit<Readonly<{
|
|
72
|
+
modelValue?: Record<string, any>;
|
|
73
|
+
} & {
|
|
74
|
+
formItems: FormItem[];
|
|
75
|
+
rules?: Record<string, any>;
|
|
76
|
+
span?: number;
|
|
77
|
+
formConfig?: Record<string, any>;
|
|
78
|
+
}> & Readonly<{
|
|
79
|
+
"onUpdate:modelValue"?: (value: Record<string, any>) => any;
|
|
80
|
+
}>, "validate"> & import('vue').ShallowUnwrapRef<{
|
|
81
|
+
validate: () => any;
|
|
82
|
+
}> & {} & import('vue').ComponentCustomProperties & {} & {
|
|
83
|
+
$slots: Partial<Record<string, (_: {}) => any>>;
|
|
84
|
+
};
|
|
85
|
+
}, any>;
|
|
86
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PageApis, TableColumn, FormItem, FormRules } from '@cynnie/ui-core';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
apis: PageApis;
|
|
4
|
+
rowKey?: string;
|
|
5
|
+
beforeCreate?: () => Promise<Record<string, any>>;
|
|
6
|
+
columns: TableColumn[];
|
|
7
|
+
formItems: FormItem[];
|
|
8
|
+
rules?: FormRules;
|
|
9
|
+
};
|
|
10
|
+
declare function loadData(): void;
|
|
11
|
+
type __VLS_PublicProps = {
|
|
12
|
+
"queryParams"?: any;
|
|
13
|
+
} & __VLS_Props;
|
|
14
|
+
declare function __VLS_template(): {
|
|
15
|
+
attrs: Partial<{}>;
|
|
16
|
+
slots: {
|
|
17
|
+
search?(_: {}): any;
|
|
18
|
+
};
|
|
19
|
+
refs: {};
|
|
20
|
+
rootEl: HTMLDivElement;
|
|
21
|
+
};
|
|
22
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
23
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
24
|
+
refresh: typeof loadData;
|
|
25
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
26
|
+
"update:queryParams": (value: any) => any;
|
|
27
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
28
|
+
"onUpdate:queryParams"?: (value: any) => any;
|
|
29
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
30
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
31
|
+
export default _default;
|
|
32
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
33
|
+
new (): {
|
|
34
|
+
$slots: S;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as ProTable } from './ProTable/index.vue';
|
|
2
|
+
export { default as ProTableForm } from './ProTable/ProTableForm.vue';
|
|
3
|
+
export { default as ProFormBuilder } from './ProFormBuilder/index.vue';
|
|
4
|
+
export { default as ProButton } from './ProButton/index.vue';
|
|
5
|
+
export { default as ProCountdownButton } from './ProButton/ProCountdownButton.vue';
|
|
6
|
+
export { default as ProInput } from './ProInput/index.vue';
|
|
7
|
+
export { default as ProSelect } from './ProSelect/index.vue';
|
|
8
|
+
export { default as ProCheckboxGroup } from './ProCheckboxGroup/index.vue';
|
|
9
|
+
export { default as ProRadioGroup } from './ProRadioGroup/index.vue';
|
|
10
|
+
export { default as ProModal } from './ProModal/index.vue';
|
|
11
|
+
export { default as ProConfirmButton } from './ProConfirmButton/index.vue';
|
|
12
|
+
export { default as ProDescriptions } from './ProDescriptions/index.vue';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { openDialog, renderDialogForm } from './utils/openDialog.js';
|
|
2
|
+
export { uiMessage } from './utils/uiMessage.js';
|
|
3
|
+
export { createApis } from '@cynnie/ui-core';
|
|
4
|
+
export { useOptions } from '@cynnie/ui-core';
|
|
5
|
+
export { useDebounce, useThrottle, useAsyncLoading } from '@cynnie/ui-core';
|
|
6
|
+
export type { DictOption, UseOptionsOptions, PageApis, PromiseFn, CreateApisOptions, FormItem, FormRules, TableColumn, DialogOptions, DialogHandle, } from '@cynnie/ui-core';
|
|
7
|
+
export type { DescriptionItem } from './components/ProDescriptions/index.vue';
|
|
8
|
+
export { ProTable, ProTableForm, ProFormBuilder, ProButton, ProCountdownButton, ProInput, ProSelect, ProCheckboxGroup, ProRadioGroup, ProModal, ProConfirmButton, ProDescriptions, } from './components/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { t as ProSelect_default } from "./ProSelect-DH8Nm5LN.js";
|
|
2
|
+
import { t as ProFormBuilder_default } from "./ProFormBuilder-DDzUy-ZE.js";
|
|
3
|
+
import { n as renderDialogForm, t as openDialog } from "./openDialog-BfikyMPD.js";
|
|
4
|
+
import { n as ProTableForm_default, t as ProTable_default } from "./ProTable-DXAnL7FT.js";
|
|
5
|
+
import { t as ProButton_default } from "./ProButton-BfUxqs4G.js";
|
|
6
|
+
import { t as ProInput_default } from "./ProInput-BnjX-7sv.js";
|
|
7
|
+
import { t as ProCheckboxGroup_default } from "./ProCheckboxGroup-BbooVQg4.js";
|
|
8
|
+
import { t as ProRadioGroup_default } from "./ProRadioGroup-CXhwhi2P.js";
|
|
9
|
+
import { t as ProModal_default } from "./ProModal-CTIpMv3y.js";
|
|
10
|
+
import { t as ProConfirmButton_default } from "./ProConfirmButton-BiZ2aUaM.js";
|
|
11
|
+
import { t as ProDescriptions_default } from "./ProDescriptions-DerGI86i.js";
|
|
12
|
+
import { Fragment, createBlock, createElementBlock, createTextVNode, defineComponent, mergeProps, openBlock, ref, renderSlot, resolveComponent, toDisplayString, withCtx } from "vue";
|
|
13
|
+
import { ElMessage } from "element-plus";
|
|
14
|
+
import { createApis, useAsyncLoading, useDebounce, useOptions, useThrottle } from "@cynnie/ui-core";
|
|
15
|
+
const uiMessage = {
|
|
16
|
+
success: (content) => ElMessage.success(content),
|
|
17
|
+
info: (content) => ElMessage.info(content),
|
|
18
|
+
error: (content) => ElMessage.error(content),
|
|
19
|
+
warning: (content) => ElMessage.warning(content)
|
|
20
|
+
};
|
|
21
|
+
var ProCountdownButton_default = /* @__PURE__ */ defineComponent({
|
|
22
|
+
name: "ProCountdownButton",
|
|
23
|
+
inheritAttrs: false,
|
|
24
|
+
__name: "ProCountdownButton",
|
|
25
|
+
props: {
|
|
26
|
+
seconds: { default: 60 },
|
|
27
|
+
countingText: { default: "{n}s 后重发" },
|
|
28
|
+
onClick: {}
|
|
29
|
+
},
|
|
30
|
+
setup(__props) {
|
|
31
|
+
const props = __props;
|
|
32
|
+
const remaining = ref(0);
|
|
33
|
+
let timer;
|
|
34
|
+
function stopTimer() {
|
|
35
|
+
if (timer) {
|
|
36
|
+
clearInterval(timer);
|
|
37
|
+
timer = void 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function handleClick(...args) {
|
|
41
|
+
if (remaining.value > 0) return;
|
|
42
|
+
if (props.onClick) {
|
|
43
|
+
const result = props.onClick(...args);
|
|
44
|
+
if (result instanceof Promise) await result;
|
|
45
|
+
}
|
|
46
|
+
remaining.value = props.seconds;
|
|
47
|
+
timer = setInterval(() => {
|
|
48
|
+
remaining.value -= 1;
|
|
49
|
+
if (remaining.value <= 0) stopTimer();
|
|
50
|
+
}, 1e3);
|
|
51
|
+
}
|
|
52
|
+
return (_ctx, _cache) => {
|
|
53
|
+
const _component_el_button = resolveComponent("el-button");
|
|
54
|
+
return openBlock(), createBlock(_component_el_button, mergeProps(_ctx.$attrs, {
|
|
55
|
+
disabled: remaining.value > 0,
|
|
56
|
+
onClick: handleClick
|
|
57
|
+
}), {
|
|
58
|
+
default: withCtx(() => [remaining.value > 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(props.countingText.replace("{n}", String(remaining.value))), 1)], 64)) : renderSlot(_ctx.$slots, "default", { key: 1 })]),
|
|
59
|
+
_: 3
|
|
60
|
+
}, 16, ["disabled"]);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
export { ProButton_default as ProButton, ProCheckboxGroup_default as ProCheckboxGroup, ProConfirmButton_default as ProConfirmButton, ProCountdownButton_default as ProCountdownButton, ProDescriptions_default as ProDescriptions, ProFormBuilder_default as ProFormBuilder, ProInput_default as ProInput, ProModal_default as ProModal, ProRadioGroup_default as ProRadioGroup, ProSelect_default as ProSelect, ProTable_default as ProTable, ProTableForm_default as ProTableForm, createApis, openDialog, renderDialogForm, uiMessage, useAsyncLoading, useDebounce, useOptions, useThrottle };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["$attrs"],"sources":["../src/utils/uiMessage.ts","../src/components/ProButton/ProCountdownButton.vue","../src/components/ProButton/ProCountdownButton.vue"],"sourcesContent":["import { ElMessage } from \"element-plus\";\n\n/**\n * 全局提示的统一抽象:两套实现包导出同名方法,调用方无需关心底层 UI 库。\n */\nexport const uiMessage = {\n success: (content: string) => ElMessage.success(content),\n info: (content: string) => ElMessage.info(content),\n error: (content: string) => ElMessage.error(content),\n warning: (content: string) => ElMessage.warning(content),\n};\n","<script setup lang=\"ts\">\nimport { ref } from \"vue\";\n\ndefineOptions({\n name: \"ProCountdownButton\",\n inheritAttrs: false,\n});\n\nconst props = withDefaults(\n defineProps<{\n /** 倒计时秒数 */\n seconds?: number;\n /** 倒计时期间按钮文案,{} 会替换为剩余秒数 */\n countingText?: string;\n /** 点击处理函数:返回 Promise 且 resolve 后才开始倒计时(适合发验证码接口) */\n onClick?: (...args: any[]) => any;\n }>(),\n {\n seconds: 60,\n countingText: \"{n}s 后重发\",\n },\n);\n\nconst remaining = ref(0);\nlet timer: ReturnType<typeof setInterval> | undefined;\n\nfunction stopTimer() {\n if (timer) {\n clearInterval(timer);\n timer = undefined;\n }\n}\n\nasync function handleClick(...args: any[]) {\n if (remaining.value > 0) return;\n\n if (props.onClick) {\n const result = props.onClick(...args);\n if (result instanceof Promise) await result;\n }\n\n remaining.value = props.seconds;\n timer = setInterval(() => {\n remaining.value -= 1;\n if (remaining.value <= 0) stopTimer();\n }, 1000);\n}\n</script>\n\n<template>\n <el-button v-bind=\"$attrs\" :disabled=\"remaining > 0\" @click=\"handleClick\">\n <template v-if=\"remaining > 0\">{{\n props.countingText.replace(\"{n}\", String(remaining))\n }}</template>\n <slot v-else></slot>\n </el-button>\n</template>\n","<script setup lang=\"ts\">\nimport { ref } from \"vue\";\n\ndefineOptions({\n name: \"ProCountdownButton\",\n inheritAttrs: false,\n});\n\nconst props = withDefaults(\n defineProps<{\n /** 倒计时秒数 */\n seconds?: number;\n /** 倒计时期间按钮文案,{} 会替换为剩余秒数 */\n countingText?: string;\n /** 点击处理函数:返回 Promise 且 resolve 后才开始倒计时(适合发验证码接口) */\n onClick?: (...args: any[]) => any;\n }>(),\n {\n seconds: 60,\n countingText: \"{n}s 后重发\",\n },\n);\n\nconst remaining = ref(0);\nlet timer: ReturnType<typeof setInterval> | undefined;\n\nfunction stopTimer() {\n if (timer) {\n clearInterval(timer);\n timer = undefined;\n }\n}\n\nasync function handleClick(...args: any[]) {\n if (remaining.value > 0) return;\n\n if (props.onClick) {\n const result = props.onClick(...args);\n if (result instanceof Promise) await result;\n }\n\n remaining.value = props.seconds;\n timer = setInterval(() => {\n remaining.value -= 1;\n if (remaining.value <= 0) stopTimer();\n }, 1000);\n}\n</script>\n\n<template>\n <el-button v-bind=\"$attrs\" :disabled=\"remaining > 0\" @click=\"handleClick\">\n <template v-if=\"remaining > 0\">{{\n props.countingText.replace(\"{n}\", String(remaining))\n }}</template>\n <slot v-else></slot>\n </el-button>\n</template>\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAa,YAAY;CACvB,UAAU,YAAoB,UAAU,QAAQ,QAAQ;CACxD,OAAO,YAAoB,UAAU,KAAK,QAAQ;CAClD,QAAQ,YAAoB,UAAU,MAAM,QAAQ;CACpD,UAAU,YAAoB,UAAU,QAAQ,QAAQ;CACzD;;;;;;;;;;;EEFD,MAAM,QAAQ;EAed,MAAM,YAAY,IAAI,EAAE;EACxB,IAAI;EAEJ,SAAS,YAAY;AACnB,OAAI,OAAO;AACT,kBAAc,MAAM;AACpB,YAAQ,KAAA;;;EAIZ,eAAe,YAAY,GAAG,MAAa;AACzC,OAAI,UAAU,QAAQ,EAAG;AAEzB,OAAI,MAAM,SAAS;IACjB,MAAM,SAAS,MAAM,QAAQ,GAAG,KAAK;AACrC,QAAI,kBAAkB,QAAS,OAAM;;AAGvC,aAAU,QAAQ,MAAM;AACxB,WAAQ,kBAAkB;AACxB,cAAU,SAAS;AACnB,QAAI,UAAU,SAAS,EAAG,YAAW;MACpC,IAAK;;;;uBAKR,YAKY,sBALZ,WAAmBA,KAKP,QALa;IAAG,UAAU,UAAA,QAAS;IAAO,SAAO;;2BAG9C,CAFG,UAAA,QAAS,KAAA,WAAA,EAAzB,mBAEa,UAAA,EAAA,KAAA,GAAA,EAAA,CAAA,gBAAA,gBADX,MAAM,aAAa,QAAO,OAAQ,OAAO,UAAA,MAAS,CAAA,CAAA,EAAA,EAAA,CAAA,EAAA,GAAA,IAEpD,WAAoB,KAAA,QAAA,WAAA,EAAA,KAAA,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { t as ProFormBuilder_default } from "./ProFormBuilder-DDzUy-ZE.js";
|
|
2
|
+
import { createApp, h, reactive, ref } from "vue";
|
|
3
|
+
import { ElButton, ElCol, ElDialog, ElForm, ElFormItem, ElRow } from "element-plus";
|
|
4
|
+
var EMPTY_OBJ = Object.freeze({});
|
|
5
|
+
function openDialog(component, props = EMPTY_OBJ, modelProps = EMPTY_OBJ) {
|
|
6
|
+
const { methodKey = "submit", onSubmit, ...restProps } = props;
|
|
7
|
+
const open = ref(true);
|
|
8
|
+
const instance = ref();
|
|
9
|
+
const container = document.createElement("div");
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
document.body.appendChild(container);
|
|
12
|
+
const reactiveModelProps = reactive(modelProps);
|
|
13
|
+
const dialog = () => {
|
|
14
|
+
const title = typeof reactiveModelProps.title === "function" ? reactiveModelProps.title() : reactiveModelProps.title;
|
|
15
|
+
return h(ElDialog, {
|
|
16
|
+
...reactiveModelProps,
|
|
17
|
+
title,
|
|
18
|
+
modelValue: open.value,
|
|
19
|
+
"onUpdate:modelValue": (value) => {
|
|
20
|
+
open.value = value;
|
|
21
|
+
},
|
|
22
|
+
beforeClose: (done) => {
|
|
23
|
+
open.value = false;
|
|
24
|
+
reactiveModelProps.onCancel?.();
|
|
25
|
+
done();
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
default: () => h(component, {
|
|
29
|
+
...restProps,
|
|
30
|
+
ref: instance
|
|
31
|
+
}),
|
|
32
|
+
footer: () => h("div", null, [h(ElButton, { onClick: () => open.value = false }, () => "取消"), h(ElButton, {
|
|
33
|
+
type: "primary",
|
|
34
|
+
loading: loading.value,
|
|
35
|
+
onClick: handleOk
|
|
36
|
+
}, () => "确定")])
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
async function handleOk() {
|
|
40
|
+
loading.value = true;
|
|
41
|
+
try {
|
|
42
|
+
let result;
|
|
43
|
+
if (onSubmit) result = await onSubmit(instance.value);
|
|
44
|
+
else if (instance.value?.[methodKey]) result = await instance.value[methodKey]();
|
|
45
|
+
open.value = false;
|
|
46
|
+
reactiveModelProps.onOk?.(result);
|
|
47
|
+
} catch {} finally {
|
|
48
|
+
loading.value = false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const app = createApp(dialog);
|
|
52
|
+
app.component("ElForm", ElForm);
|
|
53
|
+
app.component("ElRow", ElRow);
|
|
54
|
+
app.component("ElCol", ElCol);
|
|
55
|
+
app.component("ElFormItem", ElFormItem);
|
|
56
|
+
app.mount(container);
|
|
57
|
+
function close() {
|
|
58
|
+
open.value = false;
|
|
59
|
+
}
|
|
60
|
+
return { close };
|
|
61
|
+
}
|
|
62
|
+
function renderDialogForm(formProps, modelProps = EMPTY_OBJ) {
|
|
63
|
+
const reactiveFormProps = reactive(formProps);
|
|
64
|
+
return openDialog({ setup(_, { expose }) {
|
|
65
|
+
const formInstance = ref();
|
|
66
|
+
expose({ async submit() {
|
|
67
|
+
await formInstance.value?.validate?.();
|
|
68
|
+
return reactiveFormProps.modelValue;
|
|
69
|
+
} });
|
|
70
|
+
const FormComp = ProFormBuilder_default;
|
|
71
|
+
return () => h(FormComp, {
|
|
72
|
+
...reactiveFormProps,
|
|
73
|
+
ref: formInstance
|
|
74
|
+
});
|
|
75
|
+
} }, {}, modelProps);
|
|
76
|
+
}
|
|
77
|
+
export { renderDialogForm as n, openDialog as t };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=openDialog-BfikyMPD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openDialog-BfikyMPD.js","names":["result: any"],"sources":["../src/utils/openDialog.ts"],"sourcesContent":["import { type Component, h, createApp, reactive, ref } from \"vue\";\nimport { ElButton, ElCol, ElDialog, ElForm, ElFormItem, ElRow } from \"element-plus\";\nimport ProFormBuilder from \"../components/ProFormBuilder/index.vue\";\nimport type { DialogHandle } from \"@cynnie/ui-core\";\n\n// 避免每次调用都创建新空对象\nconst EMPTY_OBJ = Object.freeze({});\n\ninterface ElDialogProps extends Record<string, any> {\n title?: any;\n width?: string | number;\n onOk?: (result?: any) => any;\n onCancel?: (e?: any) => any;\n}\n\nexport function openDialog(\n component: Component,\n props: Record<string, any> = EMPTY_OBJ,\n modelProps: ElDialogProps = EMPTY_OBJ,\n): DialogHandle {\n // 与 antd 版契约一致:\n // - methodKey:内容组件暴露的方法名,默认 'submit'\n // - onSubmit:直接传函数(拿到内容组件实例),优先级高于 methodKey\n const { methodKey = \"submit\", onSubmit, ...restProps } = props;\n const open = ref(true);\n const instance = ref<Record<string, any>>();\n const container = document.createElement(\"div\");\n const loading = ref(false);\n document.body.appendChild(container);\n\n // reactive 包一层:外部传 ref 的 title 等配置可动态响应\n const reactiveModelProps = reactive(modelProps);\n const dialog = () => {\n const title =\n typeof reactiveModelProps.title === \"function\" ? (reactiveModelProps.title as any)() : reactiveModelProps.title;\n return h(\n ElDialog,\n {\n ...reactiveModelProps,\n title,\n modelValue: open.value,\n \"onUpdate:modelValue\": (value: boolean) => {\n open.value = value;\n },\n beforeClose: (done: () => void) => {\n // 点 X / ESC 走这里,与 onCancel 对齐;确定按钮不经过 beforeClose\n open.value = false;\n reactiveModelProps.onCancel?.();\n done();\n },\n },\n {\n // ElDialog 的 footer 是插槽而不是 prop\n default: () => h(component, { ...restProps, ref: instance }),\n footer: () =>\n h(\"div\", null, [\n h(ElButton, { onClick: () => (open.value = false) }, () => \"取消\"),\n h(ElButton, { type: \"primary\", loading: loading.value, onClick: handleOk }, () => \"确定\"),\n ]),\n },\n );\n };\n\n async function handleOk() {\n loading.value = true;\n try {\n let result: any;\n if (onSubmit) {\n result = await onSubmit(instance.value);\n } else if (instance.value?.[methodKey]) {\n result = await instance.value[methodKey]();\n }\n open.value = false;\n // 内容组件提交方法(或 onSubmit)的返回值交给 onOk\n reactiveModelProps.onOk?.(result);\n } catch {\n // 提交失败(校验不通过 / 请求报错)保持弹窗打开\n } finally {\n loading.value = false;\n }\n }\n\n function unmount() {\n app.unmount();\n document.body.removeChild(container);\n }\n\n const app = createApp(dialog);\n // 命令式 createApp 的独立实例没有全局注册的 el-* 组件,内容组件模板里的\n // el-form/el-row/el-col/el-form-item 需要在这里补注册\n app.component(\"ElForm\", ElForm);\n app.component(\"ElRow\", ElRow);\n app.component(\"ElCol\", ElCol);\n app.component(\"ElFormItem\", ElFormItem);\n app.mount(container);\n\n // 返回 close 方法,调用方可编程式关闭弹窗\n function close() {\n open.value = false;\n }\n return { close };\n}\n\n/**\n * 命令式弹窗表单:一行代码弹出一个「确定时自动校验」的表单弹窗。\n *\n * @param formProps ProFormBuilder 的配置:formItems / rules / modelValue 等\n * @param modelProps 弹窗的配置(title / width / onOk 等)\n * @returns { close } 关闭弹窗\n *\n * @example\n * const { close } = renderDialogForm(\n * { formItems: [{ label: '姓名', key: 'name' }], rules: { name: [{ required: true }] } },\n * { title: '新增用户', onOk: (data) => console.log('提交', data) },\n * );\n */\nexport function renderDialogForm(formProps: Record<string, any>, modelProps: ElDialogProps = EMPTY_OBJ): DialogHandle {\n const reactiveFormProps = reactive(formProps);\n return openDialog(\n {\n setup(_: any, { expose }: any) {\n const formInstance = ref();\n expose({\n // 点确定时先跑表单校验,通过后把表单数据交给 onOk\n async submit() {\n await formInstance.value?.validate?.();\n return reactiveFormProps.modelValue;\n },\n });\n // formProps 是运行时动态对象,断言绕开 h() 对 .vue 组件的严格 props 推断\n const FormComp = ProFormBuilder as unknown as Component;\n return () => h(FormComp, { ...reactiveFormProps, ref: formInstance });\n },\n },\n {},\n modelProps,\n );\n}\n"],"mappings":";;;AAMA,IAAM,YAAY,OAAO,OAAO,EAAE,CAAC;AASnC,SAAgB,WACd,WACA,QAA6B,WAC7B,aAA4B,WACd;CAId,MAAM,EAAE,YAAY,UAAU,UAAU,GAAG,cAAc;CACzD,MAAM,OAAO,IAAI,KAAK;CACtB,MAAM,WAAW,KAA0B;CAC3C,MAAM,YAAY,SAAS,cAAc,MAAM;CAC/C,MAAM,UAAU,IAAI,MAAM;AAC1B,UAAS,KAAK,YAAY,UAAU;CAGpC,MAAM,qBAAqB,SAAS,WAAW;CAC/C,MAAM,eAAe;EACnB,MAAM,QACJ,OAAO,mBAAmB,UAAU,aAAc,mBAAmB,OAAe,GAAG,mBAAmB;AAC5G,SAAO,EACL,UACA;GACE,GAAG;GACH;GACA,YAAY,KAAK;GACjB,wBAAwB,UAAmB;AACzC,SAAK,QAAQ;;GAEf,cAAc,SAAqB;AAEjC,SAAK,QAAQ;AACb,uBAAmB,YAAY;AAC/B,UAAM;;GAET,EACD;GAEE,eAAe,EAAE,WAAW;IAAE,GAAG;IAAW,KAAK;IAAU,CAAC;GAC5D,cACE,EAAE,OAAO,MAAM,CACb,EAAE,UAAU,EAAE,eAAgB,KAAK,QAAQ,OAAQ,QAAQ,KAAK,EAChE,EAAE,UAAU;IAAE,MAAM;IAAW,SAAS,QAAQ;IAAO,SAAS;IAAU,QAAQ,KAAK,CACxF,CAAC;GACL,CACF;;CAGH,eAAe,WAAW;AACxB,UAAQ,QAAQ;AAChB,MAAI;GACF,IAAIA;AACJ,OAAI,SACF,UAAS,MAAM,SAAS,SAAS,MAAM;YAC9B,SAAS,QAAQ,WAC1B,UAAS,MAAM,SAAS,MAAM,YAAY;AAE5C,QAAK,QAAQ;AAEb,sBAAmB,OAAO,OAAO;UAC3B,WAEE;AACR,WAAQ,QAAQ;;;CASpB,MAAM,MAAM,UAAU,OAAO;AAG7B,KAAI,UAAU,UAAU,OAAO;AAC/B,KAAI,UAAU,SAAS,MAAM;AAC7B,KAAI,UAAU,SAAS,MAAM;AAC7B,KAAI,UAAU,cAAc,WAAW;AACvC,KAAI,MAAM,UAAU;CAGpB,SAAS,QAAQ;AACf,OAAK,QAAQ;;AAEf,QAAO,EAAE,OAAO;;AAgBlB,SAAgB,iBAAiB,WAAgC,aAA4B,WAAyB;CACpH,MAAM,oBAAoB,SAAS,UAAU;AAC7C,QAAO,WACL,EACE,MAAM,GAAQ,EAAE,UAAe;EAC7B,MAAM,eAAe,KAAK;AAC1B,SAAO,EAEL,MAAM,SAAS;AACb,SAAM,aAAa,OAAO,YAAY;AACtC,UAAO,kBAAkB;KAE5B,CAAC;EAEF,MAAM,WAAW;AACjB,eAAa,EAAE,UAAU;GAAE,GAAG;GAAmB,KAAK;GAAc,CAAC;IAExE,EACD,EAAE,EACF,WACD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { DialogHandle } from '@cynnie/ui-core';
|
|
3
|
+
interface ElDialogProps extends Record<string, any> {
|
|
4
|
+
title?: any;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
onOk?: (result?: any) => any;
|
|
7
|
+
onCancel?: (e?: any) => any;
|
|
8
|
+
}
|
|
9
|
+
export declare function openDialog(component: Component, props?: Record<string, any>, modelProps?: ElDialogProps): DialogHandle;
|
|
10
|
+
/**
|
|
11
|
+
* 命令式弹窗表单:一行代码弹出一个「确定时自动校验」的表单弹窗。
|
|
12
|
+
*
|
|
13
|
+
* @param formProps ProFormBuilder 的配置:formItems / rules / modelValue 等
|
|
14
|
+
* @param modelProps 弹窗的配置(title / width / onOk 等)
|
|
15
|
+
* @returns { close } 关闭弹窗
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const { close } = renderDialogForm(
|
|
19
|
+
* { formItems: [{ label: '姓名', key: 'name' }], rules: { name: [{ required: true }] } },
|
|
20
|
+
* { title: '新增用户', onOk: (data) => console.log('提交', data) },
|
|
21
|
+
* );
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderDialogForm(formProps: Record<string, any>, modelProps?: ElDialogProps): DialogHandle;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局提示的统一抽象:两套实现包导出同名方法,调用方无需关心底层 UI 库。
|
|
3
|
+
*/
|
|
4
|
+
export declare const uiMessage: {
|
|
5
|
+
success: (content: string) => import('element-plus').MessageHandler;
|
|
6
|
+
info: (content: string) => import('element-plus').MessageHandler;
|
|
7
|
+
error: (content: string) => import('element-plus').MessageHandler;
|
|
8
|
+
warning: (content: string) => import('element-plus').MessageHandler;
|
|
9
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cynnie/ui-element",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "基于 element-plus 的 SnowUI 二次封装组件库,API 与 @cynnie/ui-antd 对齐",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/snowbitx/ui.git",
|
|
10
|
+
"directory": "packages/ui-element"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./components/ProTable": {
|
|
21
|
+
"types": "./dist/components/ProTable/index.vue.d.ts",
|
|
22
|
+
"import": "./dist/components/ProTable/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./components/ProFormBuilder": {
|
|
25
|
+
"types": "./dist/components/ProFormBuilder/index.vue.d.ts",
|
|
26
|
+
"import": "./dist/components/ProFormBuilder/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./utils/openDialog": {
|
|
29
|
+
"types": "./dist/utils/openDialog.d.ts",
|
|
30
|
+
"import": "./dist/utils/openDialog.js"
|
|
31
|
+
},
|
|
32
|
+
"./components/ProButton": {
|
|
33
|
+
"types": "./dist/components/ProButton/index.vue.d.ts",
|
|
34
|
+
"import": "./dist/components/ProButton/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./components/ProInput": {
|
|
37
|
+
"types": "./dist/components/ProInput/index.vue.d.ts",
|
|
38
|
+
"import": "./dist/components/ProInput/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./components/ProSelect": {
|
|
41
|
+
"types": "./dist/components/ProSelect/index.vue.d.ts",
|
|
42
|
+
"import": "./dist/components/ProSelect/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./components/ProCheckboxGroup": {
|
|
45
|
+
"types": "./dist/components/ProCheckboxGroup/index.vue.d.ts",
|
|
46
|
+
"import": "./dist/components/ProCheckboxGroup/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./components/ProRadioGroup": {
|
|
49
|
+
"types": "./dist/components/ProRadioGroup/index.vue.d.ts",
|
|
50
|
+
"import": "./dist/components/ProRadioGroup/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./components/ProModal": {
|
|
53
|
+
"types": "./dist/components/ProModal/index.vue.d.ts",
|
|
54
|
+
"import": "./dist/components/ProModal/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./components/ProConfirmButton": {
|
|
57
|
+
"types": "./dist/components/ProConfirmButton/index.vue.d.ts",
|
|
58
|
+
"import": "./dist/components/ProConfirmButton/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./components/ProDescriptions": {
|
|
61
|
+
"types": "./dist/components/ProDescriptions/index.vue.d.ts",
|
|
62
|
+
"import": "./dist/components/ProDescriptions/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./package.json": "./package.json"
|
|
65
|
+
},
|
|
66
|
+
"files": [
|
|
67
|
+
"dist"
|
|
68
|
+
],
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"sideEffects": false,
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"element-plus": "^2.9.0",
|
|
75
|
+
"vue": "^3.5.17"
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"lodash-es": "^4.17.21",
|
|
79
|
+
"@cynnie/ui-core": "^0.1.0"
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@types/lodash-es": "^4.17.12",
|
|
83
|
+
"@vitejs/plugin-vue": "^6.0.0",
|
|
84
|
+
"@vitejs/plugin-vue-jsx": "^5.0.0",
|
|
85
|
+
"@vue/tsconfig": "^0.7.0",
|
|
86
|
+
"element-plus": "^2.9.0",
|
|
87
|
+
"vite": "npm:rolldown-vite@^7.3.1",
|
|
88
|
+
"vite-plugin-dts": "^4.5.4",
|
|
89
|
+
"vue-tsc": "^2.2.10"
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "vite build",
|
|
93
|
+
"format": "prettier --write src/",
|
|
94
|
+
"type-check": "vue-tsc --noEmit -p tsconfig.json"
|
|
95
|
+
}
|
|
96
|
+
}
|