m-eleplus-crud 0.0.2 → 0.0.4

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/dist/index.full.js +28 -17
  2. package/dist/index.full.min.js +15 -15
  3. package/dist/index.full.min.js.map +1 -1
  4. package/dist/index.full.min.mjs +16 -16
  5. package/dist/index.full.min.mjs.map +1 -1
  6. package/dist/index.full.mjs +29 -18
  7. package/es/components/form/src/form.d.ts +5 -1
  8. package/es/index.mjs +3 -3
  9. package/es/packages/components/dialog/index.mjs +2 -2
  10. package/es/packages/components/dialog/src/dialog.mjs +75 -116
  11. package/es/packages/components/dialog/src/dialog.mjs.map +1 -1
  12. package/es/packages/components/dialog/src/dialog2.mjs +116 -75
  13. package/es/packages/components/dialog/src/dialog2.mjs.map +1 -1
  14. package/es/packages/components/form/src/form.mjs.map +1 -1
  15. package/es/packages/components/form/src/form2.mjs +28 -17
  16. package/es/packages/components/form/src/form2.mjs.map +1 -1
  17. package/es/packages/components/index.mjs +3 -3
  18. package/es/packages/components/picture/index.mjs +2 -2
  19. package/es/packages/components/picture/src/picture.mjs +19 -26
  20. package/es/packages/components/picture/src/picture.mjs.map +1 -1
  21. package/es/packages/components/picture/src/picture2.mjs +26 -19
  22. package/es/packages/components/picture/src/picture2.mjs.map +1 -1
  23. package/es/packages/components/search/index.mjs +2 -2
  24. package/es/packages/components/search/src/search.mjs +423 -25
  25. package/es/packages/components/search/src/search.mjs.map +1 -1
  26. package/es/packages/components/search/src/search2.mjs +25 -423
  27. package/es/packages/components/search/src/search2.mjs.map +1 -1
  28. package/es/packages/components/table/src/table2.mjs +1 -1
  29. package/es/packages/components/table/src/table2.mjs.map +1 -1
  30. package/lib/components/form/src/form.d.ts +5 -1
  31. package/lib/index.js +3 -3
  32. package/lib/packages/components/dialog/index.js +2 -2
  33. package/lib/packages/components/dialog/src/dialog.js +76 -116
  34. package/lib/packages/components/dialog/src/dialog.js.map +1 -1
  35. package/lib/packages/components/dialog/src/dialog2.js +116 -76
  36. package/lib/packages/components/dialog/src/dialog2.js.map +1 -1
  37. package/lib/packages/components/form/src/form.js.map +1 -1
  38. package/lib/packages/components/form/src/form2.js +27 -16
  39. package/lib/packages/components/form/src/form2.js.map +1 -1
  40. package/lib/packages/components/index.js +3 -3
  41. package/lib/packages/components/picture/index.js +2 -2
  42. package/lib/packages/components/picture/src/picture.js +20 -26
  43. package/lib/packages/components/picture/src/picture.js.map +1 -1
  44. package/lib/packages/components/picture/src/picture2.js +26 -20
  45. package/lib/packages/components/picture/src/picture2.js.map +1 -1
  46. package/lib/packages/components/search/index.js +2 -2
  47. package/lib/packages/components/search/src/search.js +423 -26
  48. package/lib/packages/components/search/src/search.js.map +1 -1
  49. package/lib/packages/components/search/src/search2.js +26 -423
  50. package/lib/packages/components/search/src/search2.js.map +1 -1
  51. package/lib/packages/components/table/src/table2.js +1 -1
  52. package/lib/packages/components/table/src/table2.js.map +1 -1
  53. package/package.json +1 -1
  54. package/web-types.json +1 -1
@@ -1,6 +1,6 @@
1
1
  /*! M ElePlus Crud v0.0.1 */
2
2
 
3
- import { shallowRef, watchEffect, readonly, getCurrentScope, onScopeDispose, unref, getCurrentInstance, onMounted, nextTick, watch, ref, defineComponent, openBlock, createElementBlock, createElementVNode, warn, inject, computed, isRef, provide, renderSlot, useSlots, resolveComponent, createVNode, withModifiers, withCtx, Fragment, renderList, createBlock, createCommentVNode, mergeProps, withKeys, createTextVNode, toDisplayString, normalizeStyle, toRef, onUnmounted, useAttrs as useAttrs$1, normalizeClass, resolveDynamicComponent, onBeforeUnmount, Text, reactive, h, markRaw, toRefs, Transition, withDirectives, vShow, isVNode, render as render$1, createSlots, normalizeProps, guardReactiveProps, resolveDirective } from 'vue';
3
+ import { shallowRef, watchEffect, readonly, getCurrentScope, onScopeDispose, unref, getCurrentInstance, onMounted, nextTick, watch, ref, defineComponent, openBlock, createElementBlock, createElementVNode, warn, inject, computed, isRef, provide, renderSlot, useSlots, resolveComponent, createVNode, withModifiers, withCtx, Fragment, renderList, createBlock, createCommentVNode, mergeProps, withKeys, createTextVNode, toDisplayString, normalizeStyle, toHandlers, toRef, onUnmounted, useAttrs as useAttrs$1, normalizeClass, resolveDynamicComponent, onBeforeUnmount, Text, reactive, h, markRaw, toRefs, Transition, withDirectives, vShow, isVNode, render as render$1, createSlots, normalizeProps, guardReactiveProps, resolveDirective } from 'vue';
4
4
 
5
5
  const INSTALLED_KEY = Symbol("INSTALLED_KEY");
6
6
 
@@ -12804,6 +12804,17 @@ const _sfc_main$9 = defineComponent({
12804
12804
  }
12805
12805
  }
12806
12806
  };
12807
+ const getFormItemEventBind = (column) => {
12808
+ const result = {};
12809
+ for (const key in column) {
12810
+ if (key.startsWith("event")) {
12811
+ let funName = key.replace("event", "");
12812
+ funName = funName.charAt(0).toLowerCase() + funName.slice(1);
12813
+ result[funName] = column[key];
12814
+ }
12815
+ }
12816
+ return result;
12817
+ };
12807
12818
  const formatDicValue = (row, column) => {
12808
12819
  let dictLabel = "";
12809
12820
  const findLabelByValue = (dicData, value) => {
@@ -12955,7 +12966,7 @@ const _sfc_main$9 = defineComponent({
12955
12966
  [
12956
12967
  createCommentVNode(""),
12957
12968
  createCommentVNode("\u8F93\u5165\u6846"),
12958
- createVNode(_component_el_input, {
12969
+ createVNode(_component_el_input, mergeProps({
12959
12970
  modelValue: unref(proxys)[column.prop || ""],
12960
12971
  "onUpdate:modelValue": ($event) => unref(proxys)[column.prop || ""] = $event,
12961
12972
  modelModifiers: { trim: true },
@@ -12965,7 +12976,7 @@ const _sfc_main$9 = defineComponent({
12965
12976
  "show-word-limit": column.showWordLimit,
12966
12977
  "show-password": column.showPassword,
12967
12978
  type: !column.type || column.type === "input" ? "text" : column.type
12968
- }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "maxlength", "show-word-limit", "show-password", "type"])
12979
+ }, toHandlers(getFormItemEventBind(column))), null, 16, ["modelValue", "onUpdate:modelValue", "placeholder", "maxlength", "show-word-limit", "show-password", "type"])
12969
12980
  ],
12970
12981
  2112
12971
12982
  )) : column.type === "select" ? (openBlock(), createElementBlock(
@@ -12974,7 +12985,7 @@ const _sfc_main$9 = defineComponent({
12974
12985
  [
12975
12986
  createCommentVNode(""),
12976
12987
  createCommentVNode("\u4E0B\u62C9\u6846"),
12977
- createVNode(_component_el_select, {
12988
+ createVNode(_component_el_select, mergeProps({
12978
12989
  modelValue: unref(proxys)[column.prop || ""],
12979
12990
  "onUpdate:modelValue": ($event) => unref(proxys)[column.prop || ""] = $event,
12980
12991
  modelModifiers: { trim: true },
@@ -12987,7 +12998,7 @@ const _sfc_main$9 = defineComponent({
12987
12998
  remote: column.remote,
12988
12999
  "remote-method": column.remoteMethod,
12989
13000
  loading: column.loading
12990
- }, {
13001
+ }, toHandlers(getFormItemEventBind(column))), {
12991
13002
  default: withCtx(() => [
12992
13003
  (openBlock(true), createElementBlock(
12993
13004
  Fragment,
@@ -13003,7 +13014,7 @@ const _sfc_main$9 = defineComponent({
13003
13014
  ))
13004
13015
  ]),
13005
13016
  _: 2
13006
- }, 1032, ["modelValue", "onUpdate:modelValue", "placeholder", "multiple", "clearable", "filterable", "filter-method", "remote", "remote-method", "loading"])
13017
+ }, 1040, ["modelValue", "onUpdate:modelValue", "placeholder", "multiple", "clearable", "filterable", "filter-method", "remote", "remote-method", "loading"])
13007
13018
  ],
13008
13019
  2112
13009
13020
  )) : column.type === "radio" ? (openBlock(), createElementBlock(
@@ -13012,11 +13023,11 @@ const _sfc_main$9 = defineComponent({
13012
13023
  [
13013
13024
  createCommentVNode(""),
13014
13025
  createCommentVNode("radio"),
13015
- createVNode(_component_el_radio_group, {
13026
+ createVNode(_component_el_radio_group, mergeProps({
13016
13027
  modelValue: unref(proxys)[column.prop || ""],
13017
13028
  "onUpdate:modelValue": ($event) => unref(proxys)[column.prop || ""] = $event,
13018
13029
  style: { "width": "100%" }
13019
- }, {
13030
+ }, toHandlers(getFormItemEventBind(column))), {
13020
13031
  default: withCtx(() => [
13021
13032
  (openBlock(true), createElementBlock(
13022
13033
  Fragment,
@@ -13040,7 +13051,7 @@ const _sfc_main$9 = defineComponent({
13040
13051
  ))
13041
13052
  ]),
13042
13053
  _: 2
13043
- }, 1032, ["modelValue", "onUpdate:modelValue"])
13054
+ }, 1040, ["modelValue", "onUpdate:modelValue"])
13044
13055
  ],
13045
13056
  2112
13046
13057
  )) : column.type === "checkbox" ? (openBlock(), createElementBlock(
@@ -13049,11 +13060,11 @@ const _sfc_main$9 = defineComponent({
13049
13060
  [
13050
13061
  createCommentVNode(""),
13051
13062
  createCommentVNode("checkbox"),
13052
- createVNode(_component_el_checkbox_group, {
13063
+ createVNode(_component_el_checkbox_group, mergeProps({
13053
13064
  modelValue: unref(proxys)[column.prop || ""],
13054
13065
  "onUpdate:modelValue": ($event) => unref(proxys)[column.prop || ""] = $event,
13055
13066
  style: { "width": "100%" }
13056
- }, {
13067
+ }, toHandlers(getFormItemEventBind(column))), {
13057
13068
  default: withCtx(() => [
13058
13069
  (openBlock(true), createElementBlock(
13059
13070
  Fragment,
@@ -13069,7 +13080,7 @@ const _sfc_main$9 = defineComponent({
13069
13080
  ))
13070
13081
  ]),
13071
13082
  _: 2
13072
- }, 1032, ["modelValue", "onUpdate:modelValue"])
13083
+ }, 1040, ["modelValue", "onUpdate:modelValue"])
13073
13084
  ],
13074
13085
  2112
13075
13086
  )) : column.type === "switch" ? (openBlock(), createElementBlock(
@@ -13085,12 +13096,12 @@ const _sfc_main$9 = defineComponent({
13085
13096
  Fragment,
13086
13097
  { key: 1 },
13087
13098
  [
13088
- createVNode(_component_el_switch, {
13099
+ createVNode(_component_el_switch, mergeProps({
13089
13100
  modelValue: unref(proxys)[column.prop || ""],
13090
13101
  "onUpdate:modelValue": ($event) => unref(proxys)[column.prop || ""] = $event,
13091
13102
  "active-value": column.dicData[0].value,
13092
13103
  "inactive-value": column.dicData[1].value
13093
- }, null, 8, ["modelValue", "onUpdate:modelValue", "active-value", "inactive-value"]),
13104
+ }, toHandlers(getFormItemEventBind(column))), null, 16, ["modelValue", "onUpdate:modelValue", "active-value", "inactive-value"]),
13094
13105
  createElementVNode(
13095
13106
  "span",
13096
13107
  { style: { "font-size": "var(--el-font-size-base)", "color": "var(--el-text-color-regular)", "margin-left": "6px" } },
@@ -13108,7 +13119,7 @@ const _sfc_main$9 = defineComponent({
13108
13119
  [
13109
13120
  createCommentVNode(""),
13110
13121
  createCommentVNode("\u65F6\u95F4"),
13111
- column.type !== "time" && column.type !== "timerange" ? (openBlock(), createBlock(_component_el_date_picker, {
13122
+ column.type !== "time" && column.type !== "timerange" ? (openBlock(), createBlock(_component_el_date_picker, mergeProps({
13112
13123
  key: 0,
13113
13124
  modelValue: unref(proxys)[column.prop || ""],
13114
13125
  "onUpdate:modelValue": ($event) => unref(proxys)[column.prop || ""] = $event,
@@ -13118,7 +13129,7 @@ const _sfc_main$9 = defineComponent({
13118
13129
  "end-placeholder": column.endPlaceholder,
13119
13130
  format: column.format,
13120
13131
  "value-format": column.valueFormat || getValueFormatByType(column.type)
13121
- }, null, 8, ["modelValue", "onUpdate:modelValue", "type", "clearable", "start-placeholder", "end-placeholder", "format", "value-format"])) : (openBlock(), createBlock(_component_el_time_picker, {
13132
+ }, toHandlers(getFormItemEventBind(column))), null, 16, ["modelValue", "onUpdate:modelValue", "type", "clearable", "start-placeholder", "end-placeholder", "format", "value-format"])) : (openBlock(), createBlock(_component_el_time_picker, mergeProps({
13122
13133
  key: 1,
13123
13134
  modelValue: unref(proxys)[column.prop || ""],
13124
13135
  "onUpdate:modelValue": ($event) => unref(proxys)[column.prop || ""] = $event,
@@ -13127,7 +13138,7 @@ const _sfc_main$9 = defineComponent({
13127
13138
  "start-placeholder": column.startPlaceholder,
13128
13139
  "end-placeholder": column.endPlaceholder,
13129
13140
  "value-format": column.valueFormat || getValueFormatByType(column.type)
13130
- }, null, 8, ["modelValue", "onUpdate:modelValue", "is-range", "clearable", "start-placeholder", "end-placeholder", "value-format"]))
13141
+ }, toHandlers(getFormItemEventBind(column))), null, 16, ["modelValue", "onUpdate:modelValue", "is-range", "clearable", "start-placeholder", "end-placeholder", "value-format"]))
13131
13142
  ],
13132
13143
  64
13133
13144
  )) : column.type === "picture" ? (openBlock(), createElementBlock(
@@ -18275,7 +18286,7 @@ const _sfc_main = defineComponent({
18275
18286
  renderList(tableOption.value.column, (column, columnIndex) => {
18276
18287
  return openBlock(), createBlock(_component_el_table_column, {
18277
18288
  key: columnIndex,
18278
- type: ["index", "selection"].includes(column.type) ? column.type : null,
18289
+ type: ["index", "selection"].includes(column.type) ? column.type : "default",
18279
18290
  width: column.width,
18280
18291
  label: column.label,
18281
18292
  prop: column.prop,
@@ -1,10 +1,13 @@
1
1
  import type { ColumnType, ICommonColumn } from '../../common';
2
2
  import type { FormItemRule } from 'element-plus';
3
3
  import type { ExtractPropTypes } from 'vue';
4
+ type EventHandlers = {
5
+ [K in `event${string}`]?: (...args: any[]) => any;
6
+ };
4
7
  /**
5
8
  * @description 公开的form column配置
6
9
  */
7
- export interface IFormCommonColumn {
10
+ export interface IFormCommonColumn extends EventHandlers {
8
11
  /**
9
12
  * 表单校验规则
10
13
  */
@@ -89,3 +92,4 @@ export declare const formProps: {
89
92
  export type FormProps = ExtractPropTypes<typeof formProps>;
90
93
  export declare const formEmits: {};
91
94
  export type FormEmits = typeof formEmits;
95
+ export {};
package/es/index.mjs CHANGED
@@ -7,11 +7,11 @@ export { provideGlobalConfig, useGlobalComponentSettings, useGlobalConfig } from
7
7
  export { MConfigProvider } from './packages/components/config-provider/index.mjs';
8
8
  export { tableEmits, tableProps } from './packages/components/table/src/table.mjs';
9
9
  export { MTable } from './packages/components/table/index.mjs';
10
- export { searchEmits, searchProps } from './packages/components/search/src/search.mjs';
10
+ export { searchEmits, searchProps } from './packages/components/search/src/search2.mjs';
11
11
  export { MSearch } from './packages/components/search/index.mjs';
12
- export { pictureEmits, pictureProps } from './packages/components/picture/src/picture2.mjs';
12
+ export { pictureEmits, pictureProps } from './packages/components/picture/src/picture.mjs';
13
13
  export { MPicture } from './packages/components/picture/index.mjs';
14
- export { dialogEmits, dialogProps } from './packages/components/dialog/src/dialog2.mjs';
14
+ export { dialogEmits, dialogProps } from './packages/components/dialog/src/dialog.mjs';
15
15
  export { MDialog } from './packages/components/dialog/index.mjs';
16
16
  export { qrcodeEmits, qrcodeProps } from './packages/components/qrcode/src/qrcode.mjs';
17
17
  export { MQrcode } from './packages/components/qrcode/index.mjs';
@@ -1,5 +1,5 @@
1
- import Dialog from './src/dialog.mjs';
2
- export { dialogEmits, dialogProps } from './src/dialog2.mjs';
1
+ import Dialog from './src/dialog2.mjs';
2
+ export { dialogEmits, dialogProps } from './src/dialog.mjs';
3
3
  import { withInstall } from '../../utils/vue/install.mjs';
4
4
 
5
5
  const MDialog = withInstall(Dialog);
@@ -1,121 +1,80 @@
1
- import { defineComponent, useSlots, ref, resolveComponent, openBlock, createElementBlock, createVNode, withCtx, unref, createBlock, createTextVNode, toDisplayString, createCommentVNode, renderSlot } from 'vue';
2
- import { dialogProps, dialogEmits } from './dialog2.mjs';
3
- import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';
4
- import { useLocale } from '../../../hooks/use-locale/index.mjs';
5
- import { useGlobalConfig } from '../../config-provider/src/hooks/use-global-config.mjs';
1
+ import { isBoolean } from '../../../utils/types.mjs';
2
+ import { buildProps } from '../../../utils/vue/props/runtime.mjs';
3
+ import { useSizeProp } from '../../../hooks/use-size/index.mjs';
4
+ import { isFunction } from '@vue/shared';
6
5
 
7
- const COMPONENT_NAME = "MDialog";
8
- const __default__ = defineComponent({
9
- name: COMPONENT_NAME
10
- });
11
- const _sfc_main = defineComponent({
12
- ...__default__,
13
- props: dialogProps,
14
- emits: dialogEmits,
15
- setup(__props, { emit: __emit }) {
16
- const props = __props;
17
- const emit = __emit;
18
- const slots = useSlots();
19
- const { t } = useLocale();
20
- const globalConfig = useGlobalConfig();
21
- const dialogLoading = ref(false);
22
- const closeDialog = () => {
23
- emit("update:modelValue", false);
24
- emit("close");
25
- };
26
- const enter = () => {
27
- dialogLoading.value = true;
28
- const done = () => {
29
- emit("update:modelValue", false);
30
- };
31
- const loading = () => {
32
- dialogLoading.value = false;
33
- };
34
- emit("enter", done, loading);
35
- };
36
- const close = () => {
37
- emit("update:modelValue", false);
38
- emit("cancel");
39
- };
40
- const onBeforeClose = (done) => {
41
- if (dialogLoading.value) {
42
- return false;
43
- }
44
- if (props.beforeClose) {
45
- props.beforeClose(done);
46
- } else {
47
- done();
48
- }
49
- };
50
- return (_ctx, _cache) => {
51
- const _component_el_button = resolveComponent("el-button");
52
- const _component_el_dialog = resolveComponent("el-dialog");
53
- return openBlock(), createElementBlock("div", { class: "m-dialog" }, [
54
- createVNode(_component_el_dialog, {
55
- class: "m-dialog",
56
- "model-value": _ctx.modelValue,
57
- title: _ctx.title,
58
- width: _ctx.width,
59
- top: _ctx.top,
60
- "append-to-body": _ctx.appendToBody,
61
- "close-on-click-modal": _ctx.closeOnClickModal,
62
- "close-onn-press-escape": _ctx.closeOnnPressEscape,
63
- "before-close": onBeforeClose,
64
- draggable: _ctx.draggable,
65
- "destroy-on-close": _ctx.destroyOnClose,
66
- onClose: closeDialog
67
- }, {
68
- footer: withCtx(() => [
69
- !unref(slots).btns ? (openBlock(), createElementBlock("div", {
70
- key: 0,
71
- class: "dialog-footer"
72
- }, [
73
- _ctx.cancelBtn ? (openBlock(), createBlock(_component_el_button, {
74
- key: 0,
75
- size: _ctx.size || unref(globalConfig).size,
76
- icon: _ctx.cancelBtnIcon,
77
- loading: dialogLoading.value,
78
- onClick: close
79
- }, {
80
- default: withCtx(() => [
81
- createTextVNode(
82
- toDisplayString(_ctx.cancelBtnText || unref(t)("m.dialog.cancelText")),
83
- 1
84
- )
85
- ]),
86
- _: 1
87
- }, 8, ["size", "icon", "loading"])) : createCommentVNode("v-if", true),
88
- _ctx.saveBtn ? (openBlock(), createBlock(_component_el_button, {
89
- key: 1,
90
- size: _ctx.size || unref(globalConfig).size,
91
- icon: _ctx.saveBtnIcon,
92
- loading: dialogLoading.value,
93
- type: "primary",
94
- onClick: enter
95
- }, {
96
- default: withCtx(() => [
97
- createTextVNode(
98
- toDisplayString(_ctx.saveBtnText || unref(t)("m.dialog.confirmText")),
99
- 1
100
- )
101
- ]),
102
- _: 1
103
- }, 8, ["size", "icon", "loading"])) : createCommentVNode("v-if", true)
104
- ])) : renderSlot(_ctx.$slots, "btns", {
105
- key: 1,
106
- loading: dialogLoading.value
107
- })
108
- ]),
109
- default: withCtx(() => [
110
- renderSlot(_ctx.$slots, "default", { loading: dialogLoading.value })
111
- ]),
112
- _: 3
113
- }, 8, ["model-value", "title", "width", "top", "append-to-body", "close-on-click-modal", "close-onn-press-escape", "draggable", "destroy-on-close"])
114
- ]);
115
- };
6
+ const dialogProps = buildProps({
7
+ size: useSizeProp,
8
+ modelValue: {
9
+ type: Boolean,
10
+ required: true
11
+ },
12
+ title: {
13
+ type: String,
14
+ default: ""
15
+ },
16
+ width: {
17
+ type: String,
18
+ default: "600px"
19
+ },
20
+ top: {
21
+ type: String,
22
+ default: "2vh"
23
+ },
24
+ appendToBody: {
25
+ type: Boolean,
26
+ default: true
27
+ },
28
+ closeOnClickModal: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ closeOnnPressEscape: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ beforeClose: {
37
+ type: Function
38
+ },
39
+ draggable: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ destroyOnClose: {
44
+ type: Boolean,
45
+ default: true
46
+ },
47
+ saveBtn: {
48
+ type: Boolean,
49
+ default: true
50
+ },
51
+ cancelBtn: {
52
+ type: Boolean,
53
+ default: true
54
+ },
55
+ saveBtnText: {
56
+ type: String,
57
+ default: ""
58
+ },
59
+ saveBtnIcon: {
60
+ type: String,
61
+ default: "CircleCheck"
62
+ },
63
+ cancelBtnIcon: {
64
+ type: String,
65
+ default: "CircleClose"
66
+ },
67
+ cancelBtnText: {
68
+ type: String,
69
+ default: ""
116
70
  }
117
71
  });
118
- var Dialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "dialog.vue"]]);
72
+ const dialogEmits = {
73
+ "update:modelValue": (value) => isBoolean(value),
74
+ close: () => true,
75
+ cancel: () => true,
76
+ enter: (done, loading) => isFunction(done) && isFunction(loading)
77
+ };
119
78
 
120
- export { Dialog as default };
79
+ export { dialogEmits, dialogProps };
121
80
  //# sourceMappingURL=dialog.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.mjs","sources":["../../../../../../../packages/components/dialog/src/dialog.vue"],"sourcesContent":["<template>\r\n <div class=\"m-dialog\">\r\n <el-dialog\r\n class=\"m-dialog\"\r\n :model-value=\"modelValue\"\r\n :title=\"title\"\r\n :width=\"width\"\r\n :top=\"top\"\r\n :append-to-body=\"appendToBody\"\r\n :close-on-click-modal=\"closeOnClickModal\"\r\n :close-onn-press-escape=\"closeOnnPressEscape\"\r\n :before-close=\"onBeforeClose\"\r\n :draggable=\"draggable\"\r\n :destroy-on-close=\"destroyOnClose\"\r\n @close=\"closeDialog\"\r\n >\r\n <slot :loading=\"dialogLoading\" />\r\n <template #footer>\r\n <div v-if=\"!slots.btns\" class=\"dialog-footer\">\r\n <el-button\r\n v-if=\"cancelBtn\"\r\n :size=\"size || globalConfig.size\"\r\n :icon=\"cancelBtnIcon\"\r\n :loading=\"dialogLoading\"\r\n @click=\"close\"\r\n >\r\n {{ cancelBtnText || t('m.dialog.cancelText') }}\r\n </el-button>\r\n <el-button\r\n v-if=\"saveBtn\"\r\n :size=\"size || globalConfig.size\"\r\n :icon=\"saveBtnIcon\"\r\n :loading=\"dialogLoading\"\r\n type=\"primary\"\r\n @click=\"enter\"\r\n >\r\n {{ saveBtnText || t('m.dialog.confirmText') }}\r\n </el-button>\r\n </div>\r\n <slot v-else :loading=\"dialogLoading\" name=\"btns\" />\r\n </template>\r\n </el-dialog>\r\n </div>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, useSlots } from 'vue'\r\nimport { useGlobalConfig } from '@m-eleplus-crud/components'\r\nimport { useLocale } from '@m-eleplus-crud/hooks'\r\nimport { dialogEmits, dialogProps } from './dialog'\r\n\r\nconst COMPONENT_NAME = 'MDialog'\r\ndefineOptions({\r\n name: COMPONENT_NAME,\r\n})\r\n\r\nconst props = defineProps(dialogProps)\r\nconst emit = defineEmits(dialogEmits)\r\n\r\n// 插槽信息\r\nconst slots = useSlots()\r\n// 国际化\r\nconst { t } = useLocale()\r\n// 全局配置\r\nconst globalConfig = useGlobalConfig()\r\n\r\n// 弹窗内是否loading\r\nconst dialogLoading = ref(false)\r\n\r\n/**\r\n * @description 弹窗关闭\r\n */\r\nconst closeDialog = () => {\r\n emit('update:modelValue', false)\r\n emit('close')\r\n}\r\n\r\n/**\r\n * 确认\r\n */\r\nconst enter = () => {\r\n // 弹窗开始加载\r\n dialogLoading.value = true\r\n // 关闭表单\r\n const done = () => {\r\n emit('update:modelValue', false)\r\n }\r\n // 关闭加载\r\n const loading = () => {\r\n dialogLoading.value = false\r\n }\r\n\r\n emit('enter', done, loading)\r\n}\r\n\r\n/**\r\n * 关闭\r\n */\r\nconst close = () => {\r\n emit('update:modelValue', false)\r\n emit('cancel')\r\n}\r\n\r\n/**\r\n * 弹窗关闭前\r\n * @param done 完成回调\r\n */\r\nconst onBeforeClose = (done: () => void) => {\r\n if (dialogLoading.value) {\r\n return false\r\n }\r\n if (props.beforeClose) {\r\n props.beforeClose(done)\r\n } else {\r\n done()\r\n }\r\n}\r\n</script>\r\n"],"names":["DO_defineComponent"],"mappings":";;;;;;;AAoDc,MAAA,cAAAA,eAAA,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR;;;;;;AAEA,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AACd,IAAA,MAAM,IAAO,GAAA,MAAA,CAAA;AAGb,IAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AAEjB,IAAA,MAAA,EAAE,CAAE,EAAA,GAAI,SAAU,EAAA,CAAA;AAExB,IAAA,MAAM,eAAe,eAAgB,EAAA,CAAA;AAG/B,IAAA,MAAA,aAAA,GAAgB,IAAI,KAAK,CAAA,CAAA;AAK/B,IAAA,MAAM,cAAc,MAAM;AACxB,MAAA,IAAA,CAAK,qBAAqB,KAAK,CAAA,CAAA;AAC/B,MAAA,IAAA,CAAK,OAAO,CAAA,CAAA;AAAA,KACd,CAAA;AAKA,IAAA,MAAM,QAAQ,MAAM;AAElB,MAAA,aAAA,CAAc,KAAQ,GAAA,IAAA,CAAA;AAEtB,MAAA,MAAM,OAAO,MAAM;AACjB,QAAA,IAAA,CAAK,qBAAqB,KAAK,CAAA,CAAA;AAAA,OACjC,CAAA;AAEA,MAAA,MAAM,UAAU,MAAM;AACpB,QAAA,aAAA,CAAc,KAAQ,GAAA,KAAA,CAAA;AAAA,OACxB,CAAA;AAEK,MAAA,IAAA,CAAA,OAAA,EAAS,MAAM,OAAO,CAAA,CAAA;AAAA,KAC7B,CAAA;AAKA,IAAA,MAAM,QAAQ,MAAM;AAClB,MAAA,IAAA,CAAK,qBAAqB,KAAK,CAAA,CAAA;AAC/B,MAAA,IAAA,CAAK,QAAQ,CAAA,CAAA;AAAA,KACf,CAAA;AAMM,IAAA,MAAA,aAAA,GAAgB,CAAC,IAAqB,KAAA;AAC1C,MAAA,IAAI,cAAc,KAAO,EAAA;AAChB,QAAA,OAAA,KAAA,CAAA;AAAA,OACT;AACA,MAAA,IAAI,MAAM,WAAa,EAAA;AACrB,QAAA,KAAA,CAAM,YAAY,IAAI,CAAA,CAAA;AAAA,OACjB,MAAA;AACA,QAAA,IAAA,EAAA,CAAA;AAAA,OACP;AAAA,KACF,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"dialog.mjs","sources":["../../../../../../../packages/components/dialog/src/dialog.ts"],"sourcesContent":["import { buildProps, isBoolean, isFunction } from '@m-eleplus-crud/utils'\r\nimport { useSizeProp } from '@m-eleplus-crud/hooks'\r\n\r\nimport type { ExtractPropTypes } from 'vue'\r\n\r\nexport const dialogProps = buildProps({\r\n /**\r\n * @description 弹窗尺寸\r\n */\r\n size: useSizeProp,\r\n /**\r\n * @description 弹窗显示状态\r\n */\r\n modelValue: {\r\n type: Boolean,\r\n required: true,\r\n },\r\n /**\r\n * @description 弹窗标题\r\n */\r\n title: {\r\n type: String,\r\n default: '',\r\n },\r\n /**\r\n * @description 弹窗宽度\r\n */\r\n width: {\r\n type: String,\r\n default: '600px',\r\n },\r\n /**\r\n * @description 顶部距离\r\n */\r\n top: {\r\n type: String,\r\n default: '2vh',\r\n },\r\n /**\r\n * @description 插入body\r\n */\r\n appendToBody: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n /**\r\n * @description 是否可以通过点击modal关闭Dialog\r\n */\r\n closeOnClickModal: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n /**\r\n * @description 是否可以通过按下ESC关闭Dialog\r\n */\r\n closeOnnPressEscape: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n /**\r\n * @description 弹窗关闭前回调\r\n */\r\n beforeClose: {\r\n type: Function,\r\n },\r\n /**\r\n * @description 为dialog开启拖拽功能\r\n */\r\n draggable: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n /**\r\n * @description 当关闭Dialog时,销毁其中的元素\r\n */\r\n destroyOnClose: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n /**\r\n * @description 保存按钮是否展示\r\n */\r\n saveBtn: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n /**\r\n * @description 取消按钮是否展示\r\n */\r\n cancelBtn: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n /**\r\n * @description 保存按钮文字\r\n */\r\n saveBtnText: {\r\n type: String,\r\n default: '',\r\n },\r\n /**\r\n * @description 保存按钮图标\r\n */\r\n saveBtnIcon: {\r\n type: String,\r\n default: 'CircleCheck',\r\n },\r\n /**\r\n * @description 取消按钮图标\r\n */\r\n cancelBtnIcon: {\r\n type: String,\r\n default: 'CircleClose',\r\n },\r\n /**\r\n * @description 取消按钮文字\r\n */\r\n cancelBtnText: {\r\n type: String,\r\n default: '',\r\n },\r\n} as const)\r\nexport type DialogProps = ExtractPropTypes<typeof dialogProps>\r\n\r\nexport const dialogEmits = {\r\n /**\r\n * @description 更新弹窗状态\r\n * @param value 弹窗显示状态\r\n * @returns\r\n */\r\n 'update:modelValue': (value: boolean) => isBoolean(value),\r\n /**\r\n * @description 弹窗关闭\r\n * @returns\r\n */\r\n close: () => true,\r\n /**\r\n * @description 弹窗取消\r\n * @returns\r\n */\r\n cancel: () => true,\r\n /**\r\n * @description 弹窗确认\r\n * @param done 完成\r\n * @param loading 加载完毕\r\n * @returns\r\n */\r\n enter: (done: () => void, loading: () => void) =>\r\n isFunction(done) && isFunction(loading),\r\n}\r\nexport type DialogEmits = typeof dialogEmits\r\n"],"names":[],"mappings":";;;;;AAKO,MAAM,cAAc,UAAW,CAAA;AAAA,EAIpC,IAAM,EAAA,WAAA;AAAA,EAIN,UAAY,EAAA;AAAA,IACV,IAAM,EAAA,OAAA;AAAA,IACN,QAAU,EAAA,IAAA;AAAA,GACZ;AAAA,EAIA,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,OAAA;AAAA,GACX;AAAA,EAIA,GAAK,EAAA;AAAA,IACH,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,YAAc,EAAA;AAAA,IACZ,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,iBAAmB,EAAA;AAAA,IACjB,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,mBAAqB,EAAA;AAAA,IACnB,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,WAAa,EAAA;AAAA,IACX,IAAM,EAAA,QAAA;AAAA,GACR;AAAA,EAIA,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,cAAgB,EAAA;AAAA,IACd,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,WAAa,EAAA;AAAA,IACX,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,WAAa,EAAA;AAAA,IACX,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,aAAA;AAAA,GACX;AAAA,EAIA,aAAe,EAAA;AAAA,IACb,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,aAAA;AAAA,GACX;AAAA,EAIA,aAAe,EAAA;AAAA,IACb,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,EAAA;AAAA,GACX;AACF,CAAU,EAAA;AAGH,MAAM,WAAc,GAAA;AAAA,EAMzB,mBAAqB,EAAA,CAAC,KAAmB,KAAA,SAAA,CAAU,KAAK,CAAA;AAAA,EAKxD,OAAO,MAAM,IAAA;AAAA,EAKb,QAAQ,MAAM,IAAA;AAAA,EAOd,KAAA,EAAO,CAAC,IAAkB,EAAA,OAAA,KACxB,WAAW,IAAI,CAAA,IAAK,WAAW,OAAO,CAAA;AAC1C;;;;"}