@cynnie/ui-antd 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.
Files changed (54) hide show
  1. package/README.md +35 -0
  2. package/dist/ProButton-CqnwsC_1.js +53 -0
  3. package/dist/ProButton-CqnwsC_1.js.map +1 -0
  4. package/dist/ProCheckboxGroup-Cgi80joE.js +48 -0
  5. package/dist/ProCheckboxGroup-Cgi80joE.js.map +1 -0
  6. package/dist/ProConfirmButton-BwTUXN3q.js +44 -0
  7. package/dist/ProConfirmButton-BwTUXN3q.js.map +1 -0
  8. package/dist/ProDescriptions-Bt7-Bj8s.js +46 -0
  9. package/dist/ProDescriptions-Bt7-Bj8s.js.map +1 -0
  10. package/dist/ProFormBuilder-C4qUATw1.js +1078 -0
  11. package/dist/ProFormBuilder-C4qUATw1.js.map +1 -0
  12. package/dist/ProInput-5zs6KNEY.js +40 -0
  13. package/dist/ProInput-5zs6KNEY.js.map +1 -0
  14. package/dist/ProModal-DJ5mCAGT.js +51 -0
  15. package/dist/ProModal-DJ5mCAGT.js.map +1 -0
  16. package/dist/ProRadioGroup-DQhMJA70.js +48 -0
  17. package/dist/ProRadioGroup-DQhMJA70.js.map +1 -0
  18. package/dist/ProSelect-9bs8QyA-.js +64 -0
  19. package/dist/ProSelect-9bs8QyA-.js.map +1 -0
  20. package/dist/ProTable-DW3gXtOc.js +165 -0
  21. package/dist/ProTable-DW3gXtOc.js.map +1 -0
  22. package/dist/components/ProButton/ProCountdownButton.vue.d.ts +28 -0
  23. package/dist/components/ProButton/index.js +2 -0
  24. package/dist/components/ProButton/index.vue.d.ts +25 -0
  25. package/dist/components/ProCheckboxGroup/index.js +2 -0
  26. package/dist/components/ProCheckboxGroup/index.vue.d.ts +31 -0
  27. package/dist/components/ProConfirmButton/index.js +2 -0
  28. package/dist/components/ProConfirmButton/index.vue.d.ts +25 -0
  29. package/dist/components/ProDescriptions/index.js +2 -0
  30. package/dist/components/ProDescriptions/index.vue.d.ts +36 -0
  31. package/dist/components/ProFormBuilder/index.js +2 -0
  32. package/dist/components/ProFormBuilder/index.vue.d.ts +54 -0
  33. package/dist/components/ProInput/index.js +2 -0
  34. package/dist/components/ProInput/index.vue.d.ts +28 -0
  35. package/dist/components/ProModal/index.js +2 -0
  36. package/dist/components/ProModal/index.vue.d.ts +30 -0
  37. package/dist/components/ProRadioGroup/index.js +2 -0
  38. package/dist/components/ProRadioGroup/index.vue.d.ts +31 -0
  39. package/dist/components/ProSelect/index.js +2 -0
  40. package/dist/components/ProSelect/index.vue.d.ts +33 -0
  41. package/dist/components/ProTable/index.js +2 -0
  42. package/dist/components/ProTable/index.vue.d.ts +41 -0
  43. package/dist/components/index.d.ts +12 -0
  44. package/dist/composables/index.d.ts +1 -0
  45. package/dist/index.d.ts +7 -0
  46. package/dist/index.js +66 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/openDialog-Bc1V5It3.js +75 -0
  49. package/dist/openDialog-Bc1V5It3.js.map +1 -0
  50. package/dist/utils/index.d.ts +1 -0
  51. package/dist/utils/openDialog.d.ts +18 -0
  52. package/dist/utils/openDialog.js +2 -0
  53. package/dist/utils/uiMessage.d.ts +9 -0
  54. package/package.json +96 -0
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @cynnie/ui-antd
2
+
3
+ 基于 [ant-design-vue](https://antdv.com/) 的 SnowUI 二次封装组件库,提供开箱即用的中后台组件:
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-antd ant-design-vue
18
+ ```
19
+
20
+ peer 依赖:`vue ^3.5`、`ant-design-vue ^4.2`。
21
+
22
+ ## 使用
23
+
24
+ ```vue
25
+ <script setup lang="ts">
26
+ import { ProTable } from "@cynnie/ui-antd";
27
+ // 或按需深路径引入:import ProTable from "@cynnie/ui-antd/components/ProTable";
28
+ </script>
29
+ ```
30
+
31
+ 同系列还有 [@cynnie/ui-element](https://www.npmjs.com/package/@cynnie/ui-element)(element-plus 版)与 [@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_a_button = resolveComponent("a-button");
41
+ return openBlock(), createBlock(_component_a_button, mergeProps(_ctx.$attrs, {
42
+ loading: isLoadingOrDebouncing.value || void 0,
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-CqnwsC_1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProButton-CqnwsC_1.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 <a-button v-bind=\"$attrs\" :loading=\"isLoadingOrDebouncing || undefined\" @click=\"handleClick\">\n <slot></slot>\n </a-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 <a-button v-bind=\"$attrs\" :loading=\"isLoadingOrDebouncing || undefined\" @click=\"handleClick\">\n <slot></slot>\n </a-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,YAEW,qBAFX,WAAkBA,KAEP,QAFa;IAAG,SAAS,sBAAA,SAAyB,KAAA;IAAY,SAAO;;2BACjE,CAAb,WAAa,KAAA,QAAA,UAAA,CAAA,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { computed, createBlock, createSlots, defineComponent, guardReactiveProps, mergeModels, mergeProps, normalizeProps, openBlock, renderList, renderSlot, 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, isLoading } = 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_a_checkbox_group = resolveComponent("a-checkbox-group");
33
+ return openBlock(), createBlock(_component_a_checkbox_group, mergeProps(_ctx.$attrs, {
34
+ value: model.value,
35
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => model.value = $event),
36
+ options: unref(innerOptions).map(toOption)
37
+ }), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, name) => {
38
+ return {
39
+ name,
40
+ fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps)))])
41
+ };
42
+ })]), 1040, ["value", "options"]);
43
+ };
44
+ }
45
+ });
46
+ export { ProCheckboxGroup_default as t };
47
+
48
+ //# sourceMappingURL=ProCheckboxGroup-Cgi80joE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProCheckboxGroup-Cgi80joE.js","names":["$attrs","$slots"],"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, isLoading } = 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 <a-checkbox-group v-bind=\"$attrs\" v-model:value=\"model\" :options=\"innerOptions.map(toOption)\">\n <template v-for=\"(_, name) in $slots\" #[name]=\"slotProps\" :key=\"name\">\n <slot :name=\"name\" v-bind=\"slotProps\"></slot>\n </template>\n </a-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, isLoading } = 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 <a-checkbox-group v-bind=\"$attrs\" v-model:value=\"model\" :options=\"innerOptions.map(toOption)\">\n <template v-for=\"(_, name) in $slots\" #[name]=\"slotProps\" :key=\"name\">\n <slot :name=\"name\" v-bind=\"slotProps\"></slot>\n </template>\n </a-checkbox-group>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;ECSA,MAAM,QAAQ;EAUd,MAAM,QAAQ,SAAkB,SAAA,aAAE;EAElC,MAAM,EAAE,SAAS,cAAc,cAAc,WAAW;GACtD,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,YAImB,6BAJnB,WAA0BA,KAIP,QAJa;IAAU,OAAO,MAAA;kEAAK,QAAA;IAAG,SAAS,MAAA,aAAY,CAAC,IAAI,SAAQ;yCAC3DC,KAAAA,SAAZ,GAAG,SAAI;;KAAc;kBAAQ,cAAS,CACtD,WAA6C,KAAA,QAAhC,MAAI,eAAA,mBAAU,UAAS,CAAA,CAAA,CAAA,CAAA"}
@@ -0,0 +1,44 @@
1
+ import { createBlock, createVNode, defineComponent, guardReactiveProps, normalizeProps, openBlock, ref, renderSlot, resolveComponent, withCtx } from "vue";
2
+ var ProConfirmButton_default = /* @__PURE__ */ defineComponent({
3
+ name: "ProConfirmButton",
4
+ inheritAttrs: false,
5
+ __name: "index",
6
+ props: {
7
+ title: { default: "确定执行此操作吗?" },
8
+ onConfirm: {}
9
+ },
10
+ setup(__props) {
11
+ const props = __props;
12
+ const isLoading = ref(false);
13
+ async function handleConfirm() {
14
+ if (!props.onConfirm) return;
15
+ const result = props.onConfirm();
16
+ if (result instanceof Promise) {
17
+ isLoading.value = true;
18
+ try {
19
+ await result;
20
+ } finally {
21
+ isLoading.value = false;
22
+ }
23
+ }
24
+ }
25
+ return (_ctx, _cache) => {
26
+ const _component_a_button = resolveComponent("a-button");
27
+ const _component_a_popconfirm = resolveComponent("a-popconfirm");
28
+ return openBlock(), createBlock(_component_a_popconfirm, {
29
+ title: _ctx.title,
30
+ "ok-button-props": { loading: isLoading.value },
31
+ onConfirm: handleConfirm
32
+ }, {
33
+ default: withCtx(() => [createVNode(_component_a_button, normalizeProps(guardReactiveProps(_ctx.$attrs)), {
34
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
35
+ _: 3
36
+ }, 16)]),
37
+ _: 3
38
+ }, 8, ["title", "ok-button-props"]);
39
+ };
40
+ }
41
+ });
42
+ export { ProConfirmButton_default as t };
43
+
44
+ //# sourceMappingURL=ProConfirmButton-BwTUXN3q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProConfirmButton-BwTUXN3q.js","names":["title","$attrs"],"sources":["../src/components/ProConfirmButton/index.vue","../src/components/ProConfirmButton/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from \"vue\";\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 handleConfirm() {\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 <a-popconfirm :title=\"title\" :ok-button-props=\"{ loading: isLoading }\" @confirm=\"handleConfirm\">\n <a-button v-bind=\"$attrs\">\n <slot></slot>\n </a-button>\n </a-popconfirm>\n</template>\n","<script setup lang=\"ts\">\nimport { ref } from \"vue\";\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 handleConfirm() {\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 <a-popconfirm :title=\"title\" :ok-button-props=\"{ loading: isLoading }\" @confirm=\"handleConfirm\">\n <a-button v-bind=\"$attrs\">\n <slot></slot>\n </a-button>\n </a-popconfirm>\n</template>\n"],"mappings":";;;;;;;;;;ECQA,MAAM,QAAQ;EAYd,MAAM,YAAY,IAAI,MAAM;EAE5B,eAAe,gBAAgB;AAC7B,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,YAIe,yBAAA;IAJA,OAAOA,KAAAA;IAAQ,mBAAe,EAAA,SAAa,UAAA,OAAS;IAAK,WAAS;;2BAGpE,CAFX,YAEW,qBAAA,eAAA,mBAFOC,KAAAA,OAAM,CAAA,EAAA;4BACT,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_a_descriptions_item = resolveComponent("a-descriptions-item");
25
+ const _component_a_descriptions = resolveComponent("a-descriptions");
26
+ return openBlock(), createBlock(_component_a_descriptions, normalizeProps(guardReactiveProps(_ctx.$attrs)), {
27
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(rows.value, (row) => {
28
+ return openBlock(), createBlock(_component_a_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-Bt7-Bj8s.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProDescriptions-Bt7-Bj8s.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 <a-descriptions v-bind=\"$attrs\">\n <a-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 </a-descriptions-item>\n </a-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 <a-descriptions v-bind=\"$attrs\">\n <a-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 </a-descriptions-item>\n </a-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,YAMiB,2BAAA,eAAA,mBANOA,KAAAA,OAAM,CAAA,EAAA;2BACY,EAAA,UAAA,KAAA,EAAxC,mBAIsB,UAAA,MAAA,WAJa,KAAA,QAAP,QAAG;yBAA/B,YAIsB,gCAAA;MAJoB,KAAK,IAAI;MAAQ,OAAO,IAAI;;6BAG7D,CAFP,WAEO,KAAA,QAAA,SAAA;OAFa,OAAO,IAAI;OAAQ,OAAO,IAAI;eAE3C,CAAA,gBAAA,gBADF,IAAI,MAAK,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA"}