@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
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @cynnie/ui-element
|
|
2
|
+
|
|
3
|
+
基于 [element-plus](https://element-plus.org/) 的 SnowUI 二次封装组件库,API 与 `@cynnie/ui-antd` 完全对齐,提供开箱即用的中后台组件:
|
|
4
|
+
|
|
5
|
+
- **ProTable** — 搜索表单 + 表格 + 分页一体化
|
|
6
|
+
- **ProFormBuilder** — JSON 配置化表单
|
|
7
|
+
- **ProButton / ProCountdownButton / ProConfirmButton** — 带防抖 / 倒计时 / 二次确认的按钮
|
|
8
|
+
- **ProInput** — 自动搜索防抖输入框
|
|
9
|
+
- **ProSelect / ProCheckboxGroup / ProRadioGroup** — 字典驱动的选择组件
|
|
10
|
+
- **ProModal** — 受控/命令式弹窗
|
|
11
|
+
- **ProDescriptions** — 描述列表
|
|
12
|
+
- **openDialog** — 命令式打开弹窗的工具函数
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
pnpm add @cynnie/ui-element element-plus
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
peer 依赖:`vue ^3.5`、`element-plus ^2.9`。
|
|
21
|
+
|
|
22
|
+
## 使用
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { ProTable } from "@cynnie/ui-element";
|
|
27
|
+
// 或按需深路径引入:import ProTable from "@cynnie/ui-element/components/ProTable";
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
同系列还有 [@cynnie/ui-antd](https://www.npmjs.com/package/@cynnie/ui-antd)(ant-design-vue 版)与 [@cynnie/ui-shadcn](https://www.npmjs.com/package/@cynnie/ui-shadcn)(shadcn-vue 版),API 完全对齐,可按 UI 库切换。
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
MIT
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { computed, createBlock, defineComponent, mergeProps, onBeforeUnmount, openBlock, ref, renderSlot, resolveComponent, withCtx } from "vue";
|
|
2
|
+
var ProButton_default = /* @__PURE__ */ defineComponent({
|
|
3
|
+
name: "ProButton",
|
|
4
|
+
inheritAttrs: false,
|
|
5
|
+
__name: "index",
|
|
6
|
+
props: {
|
|
7
|
+
debounce: { default: 0 },
|
|
8
|
+
onClick: {}
|
|
9
|
+
},
|
|
10
|
+
setup(__props) {
|
|
11
|
+
const props = __props;
|
|
12
|
+
const isLoading = ref(false);
|
|
13
|
+
let timer;
|
|
14
|
+
onBeforeUnmount(() => {
|
|
15
|
+
if (timer) clearTimeout(timer);
|
|
16
|
+
});
|
|
17
|
+
const isLoadingOrDebouncing = computed(() => {
|
|
18
|
+
if (isLoading.value) return true;
|
|
19
|
+
return props.debounce > 0 && timer !== void 0;
|
|
20
|
+
});
|
|
21
|
+
async function handleClick(...args) {
|
|
22
|
+
if (props.debounce > 0) {
|
|
23
|
+
if (timer) return;
|
|
24
|
+
timer = setTimeout(() => {
|
|
25
|
+
timer = void 0;
|
|
26
|
+
}, props.debounce);
|
|
27
|
+
}
|
|
28
|
+
if (!props.onClick) return;
|
|
29
|
+
const result = props.onClick(...args);
|
|
30
|
+
if (result instanceof Promise) {
|
|
31
|
+
isLoading.value = true;
|
|
32
|
+
try {
|
|
33
|
+
await result;
|
|
34
|
+
} finally {
|
|
35
|
+
isLoading.value = false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return (_ctx, _cache) => {
|
|
40
|
+
const _component_el_button = resolveComponent("el-button");
|
|
41
|
+
return openBlock(), createBlock(_component_el_button, mergeProps(_ctx.$attrs, {
|
|
42
|
+
loading: isLoadingOrDebouncing.value,
|
|
43
|
+
onClick: handleClick
|
|
44
|
+
}), {
|
|
45
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
46
|
+
_: 3
|
|
47
|
+
}, 16, ["loading"]);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export { ProButton_default as t };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=ProButton-BfUxqs4G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProButton-BfUxqs4G.js","names":["$attrs"],"sources":["../src/components/ProButton/index.vue","../src/components/ProButton/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref } from \"vue\";\n\ndefineOptions({\n name: \"ProButton\",\n inheritAttrs: false,\n});\n\nconst props = withDefaults(\n defineProps<{\n /** 点击后 delay 毫秒内再次点击不生效(防抖) */\n debounce?: number;\n /** 点击处理函数:返回 Promise 时按钮自动进入 loading 直到结束 */\n onClick?: (...args: any[]) => any;\n }>(),\n {\n debounce: 0,\n },\n);\n\nconst isLoading = ref(false);\nlet timer: ReturnType<typeof setTimeout> | undefined;\n\nonBeforeUnmount(() => {\n if (timer) clearTimeout(timer);\n});\n\nconst isLoadingOrDebouncing = computed(() => {\n if (isLoading.value) return true;\n // 防抖期间给视觉反馈,避免用户误以为没点上\n return props.debounce > 0 && timer !== undefined;\n});\n\nasync function handleClick(...args: any[]) {\n if (props.debounce > 0) {\n if (timer) return;\n timer = setTimeout(() => {\n timer = undefined;\n }, props.debounce);\n }\n\n if (!props.onClick) return;\n const result = props.onClick(...args);\n if (result instanceof Promise) {\n isLoading.value = true;\n try {\n await result;\n } finally {\n isLoading.value = false;\n }\n }\n}\n</script>\n\n<template>\n <el-button v-bind=\"$attrs\" :loading=\"isLoadingOrDebouncing\" @click=\"handleClick\">\n <slot></slot>\n </el-button>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref } from \"vue\";\n\ndefineOptions({\n name: \"ProButton\",\n inheritAttrs: false,\n});\n\nconst props = withDefaults(\n defineProps<{\n /** 点击后 delay 毫秒内再次点击不生效(防抖) */\n debounce?: number;\n /** 点击处理函数:返回 Promise 时按钮自动进入 loading 直到结束 */\n onClick?: (...args: any[]) => any;\n }>(),\n {\n debounce: 0,\n },\n);\n\nconst isLoading = ref(false);\nlet timer: ReturnType<typeof setTimeout> | undefined;\n\nonBeforeUnmount(() => {\n if (timer) clearTimeout(timer);\n});\n\nconst isLoadingOrDebouncing = computed(() => {\n if (isLoading.value) return true;\n // 防抖期间给视觉反馈,避免用户误以为没点上\n return props.debounce > 0 && timer !== undefined;\n});\n\nasync function handleClick(...args: any[]) {\n if (props.debounce > 0) {\n if (timer) return;\n timer = setTimeout(() => {\n timer = undefined;\n }, props.debounce);\n }\n\n if (!props.onClick) return;\n const result = props.onClick(...args);\n if (result instanceof Promise) {\n isLoading.value = true;\n try {\n await result;\n } finally {\n isLoading.value = false;\n }\n }\n}\n</script>\n\n<template>\n <el-button v-bind=\"$attrs\" :loading=\"isLoadingOrDebouncing\" @click=\"handleClick\">\n <slot></slot>\n </el-button>\n</template>\n"],"mappings":";;;;;;;;;;ECQA,MAAM,QAAQ;EAYd,MAAM,YAAY,IAAI,MAAM;EAC5B,IAAI;AAEJ,wBAAsB;AACpB,OAAI,MAAO,cAAa,MAAM;IAC9B;EAEF,MAAM,wBAAwB,eAAe;AAC3C,OAAI,UAAU,MAAO,QAAO;AAE5B,UAAO,MAAM,WAAW,KAAK,UAAU,KAAA;IACvC;EAEF,eAAe,YAAY,GAAG,MAAa;AACzC,OAAI,MAAM,WAAW,GAAG;AACtB,QAAI,MAAO;AACX,YAAQ,iBAAiB;AACvB,aAAQ,KAAA;OACP,MAAM,SAAS;;AAGpB,OAAI,CAAC,MAAM,QAAS;GACpB,MAAM,SAAS,MAAM,QAAQ,GAAG,KAAK;AACrC,OAAI,kBAAkB,SAAS;AAC7B,cAAU,QAAQ;AAClB,QAAI;AACF,WAAM;cACE;AACR,eAAU,QAAQ;;;;;;uBAOtB,YAEY,sBAFZ,WAAmBA,KAEP,QAFa;IAAG,SAAS,sBAAA;IAAwB,SAAO;;2BACrD,CAAb,WAAa,KAAA,QAAA,UAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Fragment, computed, createBlock, createElementBlock, defineComponent, mergeModels, mergeProps, openBlock, renderList, resolveComponent, unref, useModel, withCtx } from "vue";
|
|
2
|
+
import { useOptions } from "@cynnie/ui-core";
|
|
3
|
+
var ProCheckboxGroup_default = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "ProCheckboxGroup",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
__name: "index",
|
|
7
|
+
props: /* @__PURE__ */ mergeModels({
|
|
8
|
+
options: {},
|
|
9
|
+
labelField: {},
|
|
10
|
+
valueField: {},
|
|
11
|
+
deps: {}
|
|
12
|
+
}, {
|
|
13
|
+
"modelValue": {},
|
|
14
|
+
"modelModifiers": {}
|
|
15
|
+
}),
|
|
16
|
+
emits: ["update:modelValue"],
|
|
17
|
+
setup(__props) {
|
|
18
|
+
const props = __props;
|
|
19
|
+
const model = useModel(__props, "modelValue");
|
|
20
|
+
const { options: innerOptions } = useOptions({
|
|
21
|
+
options: computed(() => props.options),
|
|
22
|
+
deps: computed(() => props.deps)
|
|
23
|
+
});
|
|
24
|
+
function toOption(item) {
|
|
25
|
+
if (item && typeof item === "object" && "label" in item) return item;
|
|
26
|
+
return {
|
|
27
|
+
label: props.labelField ? item[props.labelField] : item,
|
|
28
|
+
value: props.valueField ? item[props.valueField] : item
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return (_ctx, _cache) => {
|
|
32
|
+
const _component_el_checkbox = resolveComponent("el-checkbox");
|
|
33
|
+
const _component_el_checkbox_group = resolveComponent("el-checkbox-group");
|
|
34
|
+
return openBlock(), createBlock(_component_el_checkbox_group, mergeProps(_ctx.$attrs, {
|
|
35
|
+
modelValue: model.value,
|
|
36
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event)
|
|
37
|
+
}), {
|
|
38
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(innerOptions).map(toOption), (opt) => {
|
|
39
|
+
return openBlock(), createBlock(_component_el_checkbox, {
|
|
40
|
+
key: opt.value,
|
|
41
|
+
label: opt.label,
|
|
42
|
+
value: opt.value
|
|
43
|
+
}, null, 8, ["label", "value"]);
|
|
44
|
+
}), 128))]),
|
|
45
|
+
_: 1
|
|
46
|
+
}, 16, ["modelValue"]);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
export { ProCheckboxGroup_default as t };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=ProCheckboxGroup-BbooVQg4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProCheckboxGroup-BbooVQg4.js","names":["$attrs"],"sources":["../src/components/ProCheckboxGroup/index.vue","../src/components/ProCheckboxGroup/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { useOptions } from \"@cynnie/ui-core\";\n\ndefineOptions({\n name: \"ProCheckboxGroup\",\n inheritAttrs: false,\n});\n\nconst props = defineProps<{\n /** 选项数据源:静态数组 / 字符串数组 / 返回数组的函数(远程字典) */\n options?: any;\n /** options 里 label / value 的字段名 */\n labelField?: string;\n valueField?: string;\n /** 远程字典的依赖值,变化时自动重新拉取 */\n deps?: any;\n}>();\n\nconst model = defineModel<any[]>();\n\nconst { options: innerOptions } = useOptions({\n options: computed(() => props.options),\n deps: computed(() => props.deps),\n});\n\nfunction toOption(item: any) {\n if (item && typeof item === \"object\" && \"label\" in item) return item;\n return {\n label: props.labelField ? item[props.labelField] : item,\n value: props.valueField ? item[props.valueField] : item,\n };\n}\n</script>\n\n<template>\n <el-checkbox-group v-bind=\"$attrs\" v-model=\"model\">\n <el-checkbox v-for=\"opt in innerOptions.map(toOption)\" :key=\"opt.value\" :label=\"opt.label\" :value=\"opt.value\" />\n </el-checkbox-group>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { useOptions } from \"@cynnie/ui-core\";\n\ndefineOptions({\n name: \"ProCheckboxGroup\",\n inheritAttrs: false,\n});\n\nconst props = defineProps<{\n /** 选项数据源:静态数组 / 字符串数组 / 返回数组的函数(远程字典) */\n options?: any;\n /** options 里 label / value 的字段名 */\n labelField?: string;\n valueField?: string;\n /** 远程字典的依赖值,变化时自动重新拉取 */\n deps?: any;\n}>();\n\nconst model = defineModel<any[]>();\n\nconst { options: innerOptions } = useOptions({\n options: computed(() => props.options),\n deps: computed(() => props.deps),\n});\n\nfunction toOption(item: any) {\n if (item && typeof item === \"object\" && \"label\" in item) return item;\n return {\n label: props.labelField ? item[props.labelField] : item,\n value: props.valueField ? item[props.valueField] : item,\n };\n}\n</script>\n\n<template>\n <el-checkbox-group v-bind=\"$attrs\" v-model=\"model\">\n <el-checkbox v-for=\"opt in innerOptions.map(toOption)\" :key=\"opt.value\" :label=\"opt.label\" :value=\"opt.value\" />\n </el-checkbox-group>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;ECSA,MAAM,QAAQ;EAUd,MAAM,QAAQ,SAAkB,SAAA,aAAE;EAElC,MAAM,EAAE,SAAS,iBAAiB,WAAW;GAC3C,SAAS,eAAe,MAAM,QAAQ;GACtC,MAAM,eAAe,MAAM,KAAK;GACjC,CAAC;EAEF,SAAS,SAAS,MAAW;AAC3B,OAAI,QAAQ,OAAO,SAAS,YAAY,WAAW,KAAM,QAAO;AAChE,UAAO;IACL,OAAO,MAAM,aAAa,KAAK,MAAM,cAAc;IACnD,OAAO,MAAM,aAAa,KAAK,MAAM,cAAc;IACpD;;;;;uBAKD,YAEoB,8BAFpB,WAA2BA,KAEP,QAFa;gBAAW,MAAA;uEAAK,QAAA;;2BACO,EAAA,UAAA,KAAA,EAAtD,mBAAgH,UAAA,MAAA,WAArF,MAAA,aAAY,CAAC,IAAI,SAAQ,GAAhC,QAAG;yBAAvB,YAAgH,wBAAA;MAAxD,KAAK,IAAI;MAAQ,OAAO,IAAI;MAAQ,OAAO,IAAI"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createBlock, defineComponent, mergeProps, openBlock, ref, renderSlot, resolveComponent, withCtx } from "vue";
|
|
2
|
+
import { ElMessageBox } from "element-plus";
|
|
3
|
+
var ProConfirmButton_default = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "ProConfirmButton",
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
__name: "index",
|
|
7
|
+
props: {
|
|
8
|
+
title: { default: "确定执行此操作吗?" },
|
|
9
|
+
onConfirm: {}
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const props = __props;
|
|
13
|
+
const isLoading = ref(false);
|
|
14
|
+
async function handleClick() {
|
|
15
|
+
try {
|
|
16
|
+
await ElMessageBox.confirm(props.title, "提示", {
|
|
17
|
+
type: "warning",
|
|
18
|
+
confirmButtonText: "确定",
|
|
19
|
+
cancelButtonText: "取消"
|
|
20
|
+
});
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!props.onConfirm) return;
|
|
25
|
+
const result = props.onConfirm();
|
|
26
|
+
if (result instanceof Promise) {
|
|
27
|
+
isLoading.value = true;
|
|
28
|
+
try {
|
|
29
|
+
await result;
|
|
30
|
+
} finally {
|
|
31
|
+
isLoading.value = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return (_ctx, _cache) => {
|
|
36
|
+
const _component_el_button = resolveComponent("el-button");
|
|
37
|
+
return openBlock(), createBlock(_component_el_button, mergeProps(_ctx.$attrs, {
|
|
38
|
+
loading: isLoading.value || void 0,
|
|
39
|
+
onClick: handleClick
|
|
40
|
+
}), {
|
|
41
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
42
|
+
_: 3
|
|
43
|
+
}, 16, ["loading"]);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export { ProConfirmButton_default as t };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=ProConfirmButton-BiZ2aUaM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProConfirmButton-BiZ2aUaM.js","names":["$attrs"],"sources":["../src/components/ProConfirmButton/index.vue","../src/components/ProConfirmButton/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nimport { ElMessageBox } from \"element-plus\";\n\ndefineOptions({\n name: \"ProConfirmButton\",\n inheritAttrs: false,\n});\n\nconst props = withDefaults(\n defineProps<{\n /** 确认框标题 */\n title?: string;\n /** 确认执行函数:返回 Promise 时确认按钮自动进入 loading */\n onConfirm?: () => Promise<any> | any;\n }>(),\n {\n title: \"确定执行此操作吗?\",\n },\n);\n\nconst isLoading = ref(false);\n\nasync function handleClick() {\n try {\n await ElMessageBox.confirm(props.title, \"提示\", {\n type: \"warning\",\n confirmButtonText: \"确定\",\n cancelButtonText: \"取消\",\n });\n } catch {\n return; // 用户取消\n }\n if (!props.onConfirm) return;\n const result = props.onConfirm();\n if (result instanceof Promise) {\n isLoading.value = true;\n try {\n await result;\n } finally {\n isLoading.value = false;\n }\n }\n}\n</script>\n\n<template>\n <el-button v-bind=\"$attrs\" :loading=\"isLoading || undefined\" @click=\"handleClick\">\n <slot></slot>\n </el-button>\n</template>\n","<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nimport { ElMessageBox } from \"element-plus\";\n\ndefineOptions({\n name: \"ProConfirmButton\",\n inheritAttrs: false,\n});\n\nconst props = withDefaults(\n defineProps<{\n /** 确认框标题 */\n title?: string;\n /** 确认执行函数:返回 Promise 时确认按钮自动进入 loading */\n onConfirm?: () => Promise<any> | any;\n }>(),\n {\n title: \"确定执行此操作吗?\",\n },\n);\n\nconst isLoading = ref(false);\n\nasync function handleClick() {\n try {\n await ElMessageBox.confirm(props.title, \"提示\", {\n type: \"warning\",\n confirmButtonText: \"确定\",\n cancelButtonText: \"取消\",\n });\n } catch {\n return; // 用户取消\n }\n if (!props.onConfirm) return;\n const result = props.onConfirm();\n if (result instanceof Promise) {\n isLoading.value = true;\n try {\n await result;\n } finally {\n isLoading.value = false;\n }\n }\n}\n</script>\n\n<template>\n <el-button v-bind=\"$attrs\" :loading=\"isLoading || undefined\" @click=\"handleClick\">\n <slot></slot>\n </el-button>\n</template>\n"],"mappings":";;;;;;;;;;;ECSA,MAAM,QAAQ;EAYd,MAAM,YAAY,IAAI,MAAM;EAE5B,eAAe,cAAc;AAC3B,OAAI;AACF,UAAM,aAAa,QAAQ,MAAM,OAAO,MAAM;KAC5C,MAAM;KACN,mBAAmB;KACnB,kBAAkB;KACnB,CAAC;WACI;AACN;;AAEF,OAAI,CAAC,MAAM,UAAW;GACtB,MAAM,SAAS,MAAM,WAAW;AAChC,OAAI,kBAAkB,SAAS;AAC7B,cAAU,QAAQ;AAClB,QAAI;AACF,WAAM;cACE;AACR,eAAU,QAAQ;;;;;;uBAOtB,YAEY,sBAFZ,WAAmBA,KAEP,QAFa;IAAG,SAAS,UAAA,SAAa,KAAA;IAAY,SAAO;;2BACtD,CAAb,WAAa,KAAA,QAAA,UAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Fragment, computed, createBlock, createElementBlock, createTextVNode, defineComponent, guardReactiveProps, normalizeProps, openBlock, renderList, renderSlot, resolveComponent, toDisplayString, withCtx } from "vue";
|
|
2
|
+
var ProDescriptions_default = /* @__PURE__ */ defineComponent({
|
|
3
|
+
name: "ProDescriptions",
|
|
4
|
+
inheritAttrs: false,
|
|
5
|
+
__name: "index",
|
|
6
|
+
props: {
|
|
7
|
+
items: {},
|
|
8
|
+
data: {},
|
|
9
|
+
emptyText: {}
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const props = __props;
|
|
13
|
+
const rows = computed(() => props.items.map((item) => ({
|
|
14
|
+
label: item.label,
|
|
15
|
+
value: renderValue(item)
|
|
16
|
+
})));
|
|
17
|
+
function renderValue(item) {
|
|
18
|
+
const value = props.data?.[item.key];
|
|
19
|
+
if (item.render) return item.render(value, props.data);
|
|
20
|
+
if (value === void 0 || value === null || value === "") return props.emptyText ?? "-";
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return (_ctx, _cache) => {
|
|
24
|
+
const _component_el_descriptions_item = resolveComponent("el-descriptions-item");
|
|
25
|
+
const _component_el_descriptions = resolveComponent("el-descriptions");
|
|
26
|
+
return openBlock(), createBlock(_component_el_descriptions, normalizeProps(guardReactiveProps(_ctx.$attrs)), {
|
|
27
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(rows.value, (row) => {
|
|
28
|
+
return openBlock(), createBlock(_component_el_descriptions_item, {
|
|
29
|
+
key: row.label,
|
|
30
|
+
label: row.label
|
|
31
|
+
}, {
|
|
32
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "value", {
|
|
33
|
+
label: row.label,
|
|
34
|
+
value: row.value
|
|
35
|
+
}, () => [createTextVNode(toDisplayString(row.value), 1)])]),
|
|
36
|
+
_: 2
|
|
37
|
+
}, 1032, ["label"]);
|
|
38
|
+
}), 128))]),
|
|
39
|
+
_: 3
|
|
40
|
+
}, 16);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export { ProDescriptions_default as t };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=ProDescriptions-DerGI86i.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProDescriptions-DerGI86i.js","names":["$attrs"],"sources":["../src/components/ProDescriptions/index.vue","../src/components/ProDescriptions/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from \"vue\";\n\ndefineOptions({\n name: \"ProDescriptions\",\n inheritAttrs: false,\n});\n\nexport interface DescriptionItem {\n /** 标签 */\n label: string;\n /** 字段名 */\n key: string;\n /** 自定义渲染,返回字符串或 vnode */\n render?: (value: any, record: Record<string, any>) => any;\n}\n\nconst props = defineProps<{\n /** 描述项配置 */\n items: DescriptionItem[];\n /** 数据对象 */\n data: Record<string, any>;\n /** 空值占位符 */\n emptyText?: string;\n}>();\n\nconst rows = computed(() =>\n props.items.map((item) => ({\n label: item.label,\n value: renderValue(item),\n })),\n);\n\nfunction renderValue(item: DescriptionItem) {\n const value = props.data?.[item.key];\n if (item.render) return item.render(value, props.data);\n if (value === undefined || value === null || value === \"\") return props.emptyText ?? \"-\";\n return value;\n}\n</script>\n\n<template>\n <el-descriptions v-bind=\"$attrs\">\n <el-descriptions-item v-for=\"row in rows\" :key=\"row.label\" :label=\"row.label\">\n <slot name=\"value\" :label=\"row.label\" :value=\"row.value\">\n {{ row.value }}\n </slot>\n </el-descriptions-item>\n </el-descriptions>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\n\ndefineOptions({\n name: \"ProDescriptions\",\n inheritAttrs: false,\n});\n\nexport interface DescriptionItem {\n /** 标签 */\n label: string;\n /** 字段名 */\n key: string;\n /** 自定义渲染,返回字符串或 vnode */\n render?: (value: any, record: Record<string, any>) => any;\n}\n\nconst props = defineProps<{\n /** 描述项配置 */\n items: DescriptionItem[];\n /** 数据对象 */\n data: Record<string, any>;\n /** 空值占位符 */\n emptyText?: string;\n}>();\n\nconst rows = computed(() =>\n props.items.map((item) => ({\n label: item.label,\n value: renderValue(item),\n })),\n);\n\nfunction renderValue(item: DescriptionItem) {\n const value = props.data?.[item.key];\n if (item.render) return item.render(value, props.data);\n if (value === undefined || value === null || value === \"\") return props.emptyText ?? \"-\";\n return value;\n}\n</script>\n\n<template>\n <el-descriptions v-bind=\"$attrs\">\n <el-descriptions-item v-for=\"row in rows\" :key=\"row.label\" :label=\"row.label\">\n <slot name=\"value\" :label=\"row.label\" :value=\"row.value\">\n {{ row.value }}\n </slot>\n </el-descriptions-item>\n </el-descriptions>\n</template>\n"],"mappings":";;;;;;;;;;;ECiBA,MAAM,QAAQ;EASd,MAAM,OAAO,eACX,MAAM,MAAM,KAAK,UAAU;GACzB,OAAO,KAAK;GACZ,OAAO,YAAY,KAAK;GACzB,EAAE,CACJ;EAED,SAAS,YAAY,MAAuB;GAC1C,MAAM,QAAQ,MAAM,OAAO,KAAK;AAChC,OAAI,KAAK,OAAQ,QAAO,KAAK,OAAO,OAAO,MAAM,KAAK;AACtD,OAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,GAAI,QAAO,MAAM,aAAa;AACrF,UAAO;;;;;uBAKP,YAMkB,4BAAA,eAAA,mBANOA,KAAAA,OAAM,CAAA,EAAA;2BACY,EAAA,UAAA,KAAA,EAAzC,mBAIuB,UAAA,MAAA,WAJa,KAAA,QAAP,QAAG;yBAAhC,YAIuB,iCAAA;MAJoB,KAAK,IAAI;MAAQ,OAAO,IAAI;;6BAG9D,CAFP,WAEO,KAAA,QAAA,SAAA;OAFa,OAAO,IAAI;OAAQ,OAAO,IAAI;eAE3C,CAAA,gBAAA,gBADF,IAAI,MAAK,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA"}
|