el-plus 0.0.52 → 0.0.53
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/CHANGELOG.md +6 -0
- package/dist/index.css +1 -1
- package/dist/index.full.js +88 -48
- package/dist/index.full.min.js +1 -1
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +1 -1
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +88 -49
- package/es/hooks/dialog/use-confirm-dialog.d.ts +12 -0
- package/es/hooks/dialog/use-confirm-dialog.mjs +47 -0
- package/es/hooks/dialog/use-confirm-dialog.mjs.map +1 -0
- package/es/hooks/dialog/use-dialog.d.ts +2 -0
- package/es/hooks/dialog/use-dialog.mjs +28 -32
- package/es/hooks/dialog/use-dialog.mjs.map +1 -1
- package/es/hooks/dialog/use-form-dialog.d.ts +1 -0
- package/es/hooks/dialog/use-form-dialog.mjs +3 -2
- package/es/hooks/dialog/use-form-dialog.mjs.map +1 -1
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.mjs +1 -0
- package/es/hooks/index.mjs.map +1 -1
- package/es/index.mjs +1 -0
- package/es/index.mjs.map +1 -1
- package/es/package.json.mjs +1 -1
- package/lib/hooks/dialog/use-confirm-dialog.d.ts +12 -0
- package/lib/hooks/dialog/use-confirm-dialog.js +49 -0
- package/lib/hooks/dialog/use-confirm-dialog.js.map +1 -0
- package/lib/hooks/dialog/use-dialog.d.ts +2 -0
- package/lib/hooks/dialog/use-dialog.js +27 -31
- package/lib/hooks/dialog/use-dialog.js.map +1 -1
- package/lib/hooks/dialog/use-form-dialog.d.ts +1 -0
- package/lib/hooks/dialog/use-form-dialog.js +3 -2
- package/lib/hooks/dialog/use-form-dialog.js.map +1 -1
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json.js +1 -1
- package/package.json +1 -1
- package/theme-chalk/dialog.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/dialog.scss +7 -0
package/dist/index.full.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! ElPlus v0.0.
|
|
1
|
+
/*! ElPlus v0.0.53 */
|
|
2
2
|
|
|
3
3
|
import { useAttrs, getCurrentInstance, inject, provide, ref, nextTick, defineComponent, computed, createVNode, Fragment, withDirectives, resolveComponent, mergeProps, resolveDirective, useTemplateRef, createTextVNode, h, mergeModels, useModel, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createCommentVNode, withCtx, renderSlot, renderList, createBlock, vShow, toDisplayString, reactive, useSlots, watch, onMounted, createSlots, normalizeProps, guardReactiveProps, markRaw, Transition, shallowReactive, isVNode, render, createElementVNode, toRaw } from 'vue';
|
|
4
4
|
import { buttonProps, useLocale as useLocale$1, ElLoading, ElMessage, ElMessageBox, formProps as formProps$1, formEmits as formEmits$1, ElTooltip, formItemProps as formItemProps$1, ElFormItem, ElForm, ElRow, ElCol, inputProps as inputProps$1, inputEmits as inputEmits$1, configProviderContextKey, ElConfigProvider, ElDialog, ElButton, ElTable, ElIcon, selectProps as selectProps$1, selectEmits as selectEmits$1, ElPageHeader, datePickerProps, linkProps as linkProps$1, ElSkeleton } from 'element-plus';
|
|
@@ -711,7 +711,7 @@ async function queryRoles() {
|
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
|
|
714
|
-
const bem$
|
|
714
|
+
const bem$5 = createNameSpace("button");
|
|
715
715
|
var Buttons = /* @__PURE__ */ defineComponent({
|
|
716
716
|
name: "EpButtons",
|
|
717
717
|
directives: {
|
|
@@ -763,7 +763,7 @@ var Buttons = /* @__PURE__ */ defineComponent({
|
|
|
763
763
|
return () => createVNode(Fragment, null, [customList.value.map((item) => {
|
|
764
764
|
const permissionArr = item.permission?.split(":") || [];
|
|
765
765
|
return withDirectives(createVNode(resolveComponent("el-button"), mergeProps({
|
|
766
|
-
"class": [bem$
|
|
766
|
+
"class": [bem$5.b(), prepareClassNames()],
|
|
767
767
|
"style": prepareStyles(),
|
|
768
768
|
"key": item.prop || item.name
|
|
769
769
|
}, {
|
|
@@ -1024,7 +1024,7 @@ const formItemProps = {
|
|
|
1024
1024
|
};
|
|
1025
1025
|
const expandFormItemPropsKeys = Object.keys(expandFormItemProps);
|
|
1026
1026
|
|
|
1027
|
-
const bem$
|
|
1027
|
+
const bem$4 = createNameSpace("form-item");
|
|
1028
1028
|
var EpFormItem = /* @__PURE__ */ defineComponent({
|
|
1029
1029
|
name: "EpFormItem",
|
|
1030
1030
|
inheritAttrs: false,
|
|
@@ -1046,7 +1046,7 @@ var EpFormItem = /* @__PURE__ */ defineComponent({
|
|
|
1046
1046
|
} = props;
|
|
1047
1047
|
return () => {
|
|
1048
1048
|
return createVNode(ElFormItem, mergeProps({
|
|
1049
|
-
"class": [bem$
|
|
1049
|
+
"class": [bem$4.b(), prepareClassNames()],
|
|
1050
1050
|
"style": prepareStyles()
|
|
1051
1051
|
}, {
|
|
1052
1052
|
...prepareProps(formItemProps2, [...expandFormItemPropsKeys]),
|
|
@@ -1320,7 +1320,7 @@ var _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
1320
1320
|
|
|
1321
1321
|
const EpInput = withInstall(_sfc_main$a);
|
|
1322
1322
|
|
|
1323
|
-
function _isSlot
|
|
1323
|
+
function _isSlot(s) {
|
|
1324
1324
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
1325
1325
|
}
|
|
1326
1326
|
const useTemplatePromise = (options = {}) => {
|
|
@@ -1394,7 +1394,7 @@ const useTemplatePromise = (options = {}) => {
|
|
|
1394
1394
|
});
|
|
1395
1395
|
if (transition) return () => {
|
|
1396
1396
|
let _slot;
|
|
1397
|
-
return createVNode(Transition, transition, _isSlot
|
|
1397
|
+
return createVNode(Transition, transition, _isSlot(_slot = renderList()) ? _slot : {
|
|
1398
1398
|
default: () => [_slot]
|
|
1399
1399
|
});
|
|
1400
1400
|
};
|
|
@@ -1404,10 +1404,7 @@ const useTemplatePromise = (options = {}) => {
|
|
|
1404
1404
|
return markRaw(component);
|
|
1405
1405
|
};
|
|
1406
1406
|
|
|
1407
|
-
|
|
1408
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
1409
|
-
}
|
|
1410
|
-
const bem$2 = createNameSpace("dialog");
|
|
1407
|
+
const bem$3 = createNameSpace("dialog");
|
|
1411
1408
|
const useDialog = (options = {}) => {
|
|
1412
1409
|
const {
|
|
1413
1410
|
t
|
|
@@ -1418,7 +1415,9 @@ const useDialog = (options = {}) => {
|
|
|
1418
1415
|
render: render$1,
|
|
1419
1416
|
destroyOnClose,
|
|
1420
1417
|
onConfirm,
|
|
1418
|
+
confirmText,
|
|
1421
1419
|
onCancel,
|
|
1420
|
+
cancelText,
|
|
1422
1421
|
showFooter = true,
|
|
1423
1422
|
...dialogProps
|
|
1424
1423
|
} = options;
|
|
@@ -1438,38 +1437,35 @@ const useDialog = (options = {}) => {
|
|
|
1438
1437
|
};
|
|
1439
1438
|
const slots = {};
|
|
1440
1439
|
if (showFooter) {
|
|
1441
|
-
slots.footer = () => {
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
} else {
|
|
1451
|
-
reject("cancel");
|
|
1452
|
-
}
|
|
1440
|
+
slots.footer = () => createVNode("div", {
|
|
1441
|
+
"class": bem$3.e("footer")
|
|
1442
|
+
}, [scopedSlots.footerPrepend?.(promiseOptions), createVNode(ElButton, {
|
|
1443
|
+
"size": "default",
|
|
1444
|
+
"onClick": () => {
|
|
1445
|
+
if (onCancel) {
|
|
1446
|
+
onCancel(reject);
|
|
1447
|
+
} else {
|
|
1448
|
+
reject("cancel");
|
|
1453
1449
|
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
};
|
|
1450
|
+
}
|
|
1451
|
+
}, {
|
|
1452
|
+
default: () => [cancelText || t("ep.dialog.cancel")]
|
|
1453
|
+
}), scopedSlots.footerInner?.(promiseOptions), createVNode(ElButton, {
|
|
1454
|
+
"type": "primary",
|
|
1455
|
+
"onClick": async () => {
|
|
1456
|
+
if (onConfirm) {
|
|
1457
|
+
onConfirm(resolve);
|
|
1458
|
+
} else {
|
|
1459
|
+
resolve("confirm");
|
|
1460
|
+
}
|
|
1461
|
+
},
|
|
1462
|
+
"loading": isResolving
|
|
1463
|
+
}, {
|
|
1464
|
+
default: () => [confirmText || t("ep.dialog.confirm")]
|
|
1465
|
+
}), scopedSlots.footerAppend?.(promiseOptions)]);
|
|
1470
1466
|
}
|
|
1471
1467
|
return createVNode(ElDialog, mergeProps({
|
|
1472
|
-
"class": bem$
|
|
1468
|
+
"class": bem$3.b(),
|
|
1473
1469
|
"modelValue": true
|
|
1474
1470
|
}, {
|
|
1475
1471
|
closeOnClickModal: false,
|
|
@@ -1962,11 +1958,12 @@ const expandTablePropsKeys = Object.keys(expandTableProps);
|
|
|
1962
1958
|
const tableEmits = [...ElTable.emits, "single-selection-change"];
|
|
1963
1959
|
const tableEmitsKeys = tableEmits;
|
|
1964
1960
|
|
|
1965
|
-
const bem$
|
|
1961
|
+
const bem$2 = createNameSpace("form-dialog");
|
|
1966
1962
|
const useFormDialog = (options = {}) => {
|
|
1967
1963
|
const {
|
|
1968
1964
|
dialogProps,
|
|
1969
1965
|
title,
|
|
1966
|
+
width = "80%",
|
|
1970
1967
|
...formProps
|
|
1971
1968
|
} = options;
|
|
1972
1969
|
const formRef = ref();
|
|
@@ -1979,10 +1976,10 @@ const useFormDialog = (options = {}) => {
|
|
|
1979
1976
|
}
|
|
1980
1977
|
};
|
|
1981
1978
|
return useDialog({
|
|
1982
|
-
class: bem$
|
|
1983
|
-
width
|
|
1979
|
+
class: bem$2.b(),
|
|
1980
|
+
width,
|
|
1984
1981
|
title,
|
|
1985
|
-
render: (
|
|
1982
|
+
render: () => {
|
|
1986
1983
|
return createVNode(EpForm, mergeProps({
|
|
1987
1984
|
"ref": formRef,
|
|
1988
1985
|
"modelValue": formData,
|
|
@@ -4172,7 +4169,7 @@ var components = [
|
|
|
4172
4169
|
EpUniVue
|
|
4173
4170
|
];
|
|
4174
4171
|
|
|
4175
|
-
var version = "0.0.
|
|
4172
|
+
var version = "0.0.53";
|
|
4176
4173
|
|
|
4177
4174
|
var globalProperties = {
|
|
4178
4175
|
install(app) {
|
|
@@ -4185,7 +4182,7 @@ var plugins = /*#__PURE__*/Object.freeze({
|
|
|
4185
4182
|
globalProperties: globalProperties
|
|
4186
4183
|
});
|
|
4187
4184
|
|
|
4188
|
-
const bem = createNameSpace("choose-dialog");
|
|
4185
|
+
const bem$1 = createNameSpace("choose-dialog");
|
|
4189
4186
|
const useChooseDialog = (options = {}) => {
|
|
4190
4187
|
const {
|
|
4191
4188
|
t
|
|
@@ -4202,7 +4199,7 @@ const useChooseDialog = (options = {}) => {
|
|
|
4202
4199
|
if (!showSingleSelectionCol) {
|
|
4203
4200
|
scopedSlots.footerPrepend = () => {
|
|
4204
4201
|
return createVNode("span", {
|
|
4205
|
-
"class": bem.e("selected-count")
|
|
4202
|
+
"class": bem$1.e("selected-count")
|
|
4206
4203
|
}, [t("ep.chooseDialog.selected"), selections.value.length, t("ep.chooseDialog.unit")]);
|
|
4207
4204
|
};
|
|
4208
4205
|
}
|
|
@@ -4212,7 +4209,7 @@ const useChooseDialog = (options = {}) => {
|
|
|
4212
4209
|
};
|
|
4213
4210
|
let searchListPageRef;
|
|
4214
4211
|
return useDialog({
|
|
4215
|
-
class: bem.b(),
|
|
4212
|
+
class: bem$1.b(),
|
|
4216
4213
|
width: "80%",
|
|
4217
4214
|
showFooter: !showSingleSelectionCol,
|
|
4218
4215
|
scopedSlots,
|
|
@@ -4259,6 +4256,48 @@ const useChooseDialog = (options = {}) => {
|
|
|
4259
4256
|
});
|
|
4260
4257
|
};
|
|
4261
4258
|
|
|
4259
|
+
const bem = createNameSpace("confirm-dialog");
|
|
4260
|
+
const useConfirmDialog = (options = {}) => {
|
|
4261
|
+
const {
|
|
4262
|
+
dialogProps = {},
|
|
4263
|
+
width = "50%",
|
|
4264
|
+
title,
|
|
4265
|
+
/** TextareaProps */
|
|
4266
|
+
rows = 5,
|
|
4267
|
+
maxlength = 500,
|
|
4268
|
+
minlength,
|
|
4269
|
+
showWordLimit = true,
|
|
4270
|
+
/** TextareaFormItemProps */
|
|
4271
|
+
rules,
|
|
4272
|
+
required = true,
|
|
4273
|
+
placeholder
|
|
4274
|
+
} = options;
|
|
4275
|
+
const formItemList = [{
|
|
4276
|
+
rules,
|
|
4277
|
+
prop: "value",
|
|
4278
|
+
label: " ",
|
|
4279
|
+
required,
|
|
4280
|
+
props: {
|
|
4281
|
+
placeholder,
|
|
4282
|
+
type: "textarea",
|
|
4283
|
+
rows,
|
|
4284
|
+
maxlength,
|
|
4285
|
+
minlength,
|
|
4286
|
+
showWordLimit
|
|
4287
|
+
}
|
|
4288
|
+
}];
|
|
4289
|
+
return useFormDialog({
|
|
4290
|
+
title,
|
|
4291
|
+
width,
|
|
4292
|
+
formItemList,
|
|
4293
|
+
dialogProps: {
|
|
4294
|
+
...dialogProps,
|
|
4295
|
+
class: bem.b(),
|
|
4296
|
+
destroyOnClose: true
|
|
4297
|
+
}
|
|
4298
|
+
});
|
|
4299
|
+
};
|
|
4300
|
+
|
|
4262
4301
|
const INSTALLED_KEY = /* @__PURE__ */ Symbol("INSTALLED_KEY");
|
|
4263
4302
|
const install = (app, options) => {
|
|
4264
4303
|
if (app[INSTALLED_KEY]) return;
|
|
@@ -4271,4 +4310,4 @@ const plugin = {
|
|
|
4271
4310
|
version
|
|
4272
4311
|
};
|
|
4273
4312
|
|
|
4274
|
-
export { EpAttachment, EpButtons, EpCustomColumn, EpDatePickerRange, EpForm, EpFormItem, EpHeader, EpInput, EpLink, EpSearchListPage, EpSelect, EpTable, EpTitle, EpUniVue, attachmentProps, buttonsProps, componentType, customColumnEmits, customColumnProps, datePickerRangeEmits, datePickerRangeProps, plugin as default, expandFormItemPropsKeys, expandFormPropsKeys, expandSelectPropsKeys, expandTablePropsKeys, formEmits, formEmitsKeys, formItemProps, formProps, headerEmits, headerProps, inheritSelectProps, inputEmits, inputEmitsKeys, inputProps, install, linkProps, searchListPageProps, selectEmits, selectEmitsKeys, selectProps, tableEmits, tableEmitsKeys, tableProps, titleEmits, titleProps, uniVueProps, useChooseDialog, useDialog, useFormDialog, useLocale, useNavigation, useRequest, useTemplatePromise, vPermisson as vPermission, vRepeatClick };
|
|
4313
|
+
export { EpAttachment, EpButtons, EpCustomColumn, EpDatePickerRange, EpForm, EpFormItem, EpHeader, EpInput, EpLink, EpSearchListPage, EpSelect, EpTable, EpTitle, EpUniVue, attachmentProps, buttonsProps, componentType, customColumnEmits, customColumnProps, datePickerRangeEmits, datePickerRangeProps, plugin as default, expandFormItemPropsKeys, expandFormPropsKeys, expandSelectPropsKeys, expandTablePropsKeys, formEmits, formEmitsKeys, formItemProps, formProps, headerEmits, headerProps, inheritSelectProps, inputEmits, inputEmitsKeys, inputProps, install, linkProps, searchListPageProps, selectEmits, selectEmitsKeys, selectProps, tableEmits, tableEmitsKeys, tableProps, titleEmits, titleProps, uniVueProps, useChooseDialog, useConfirmDialog, useDialog, useFormDialog, useLocale, useNavigation, useRequest, useTemplatePromise, vPermisson as vPermission, vRepeatClick };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DialogOptions } from './use-dialog';
|
|
2
|
+
import type { FormItemProps } from 'el-plus/es/components/form';
|
|
3
|
+
import type { InputProps } from 'element-plus';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
title?: string;
|
|
6
|
+
width?: string;
|
|
7
|
+
dialogProps?: DialogOptions;
|
|
8
|
+
} & TextareaProps & TextareaFormItemProps>;
|
|
9
|
+
type TextareaProps = Pick<InputProps, 'rows' | 'maxlength' | 'minlength' | 'showWordLimit' | 'placeholder'>;
|
|
10
|
+
type TextareaFormItemProps = Pick<FormItemProps, 'rules' | 'required'>;
|
|
11
|
+
export declare const useConfirmDialog: (options?: Options) => import("el-plus/es").TemplatePromise<any, []>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useFormDialog } from './use-form-dialog.mjs';
|
|
2
|
+
import { createNameSpace } from '../../utils/bem.mjs';
|
|
3
|
+
|
|
4
|
+
const bem = createNameSpace("confirm-dialog");
|
|
5
|
+
const useConfirmDialog = (options = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
dialogProps = {},
|
|
8
|
+
width = "50%",
|
|
9
|
+
title,
|
|
10
|
+
/** TextareaProps */
|
|
11
|
+
rows = 5,
|
|
12
|
+
maxlength = 500,
|
|
13
|
+
minlength,
|
|
14
|
+
showWordLimit = true,
|
|
15
|
+
/** TextareaFormItemProps */
|
|
16
|
+
rules,
|
|
17
|
+
required = true,
|
|
18
|
+
placeholder
|
|
19
|
+
} = options;
|
|
20
|
+
const formItemList = [{
|
|
21
|
+
rules,
|
|
22
|
+
prop: "value",
|
|
23
|
+
label: " ",
|
|
24
|
+
required,
|
|
25
|
+
props: {
|
|
26
|
+
placeholder,
|
|
27
|
+
type: "textarea",
|
|
28
|
+
rows,
|
|
29
|
+
maxlength,
|
|
30
|
+
minlength,
|
|
31
|
+
showWordLimit
|
|
32
|
+
}
|
|
33
|
+
}];
|
|
34
|
+
return useFormDialog({
|
|
35
|
+
title,
|
|
36
|
+
width,
|
|
37
|
+
formItemList,
|
|
38
|
+
dialogProps: {
|
|
39
|
+
...dialogProps,
|
|
40
|
+
class: bem.b(),
|
|
41
|
+
destroyOnClose: true
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { useConfirmDialog };
|
|
47
|
+
//# sourceMappingURL=use-confirm-dialog.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-confirm-dialog.mjs","sources":["../../../../../packages/hooks/dialog/use-confirm-dialog.tsx"],"sourcesContent":["import { useFormDialog } from './use-form-dialog'\nimport type { DialogOptions } from './use-dialog'\nimport type { FormItemProps } from '@el-plus/components/form'\nimport { createNameSpace } from '@el-plus/utils/bem'\nimport type { InputProps } from 'element-plus'\nconst bem = createNameSpace('confirm-dialog')\ntype Options = Partial<\n {\n title?: string\n width?: string\n dialogProps?: DialogOptions\n } & TextareaProps &\n TextareaFormItemProps\n>\ntype TextareaProps = Pick<\n InputProps,\n 'rows' | 'maxlength' | 'minlength' | 'showWordLimit' | 'placeholder'\n>\ntype TextareaFormItemProps = Pick<FormItemProps, 'rules' | 'required'>\nexport const useConfirmDialog = (options: Options = {}) => {\n const {\n dialogProps = {},\n width = '50%',\n title,\n /** TextareaProps */\n rows = 5,\n maxlength = 500,\n minlength,\n showWordLimit = true,\n /** TextareaFormItemProps */\n rules,\n required = true,\n placeholder,\n } = options\n const formItemList: FormItemProps[] = [\n {\n rules,\n prop: 'value',\n label: ' ',\n required,\n props: {\n placeholder,\n type: 'textarea',\n rows,\n maxlength,\n minlength,\n showWordLimit,\n },\n },\n ]\n return useFormDialog({\n title,\n width,\n formItemList,\n dialogProps: {\n ...dialogProps,\n class: bem.b(),\n destroyOnClose: true,\n },\n })\n}\n"],"names":["bem","createNameSpace","useConfirmDialog","options","dialogProps","width","title","rows","maxlength","minlength","showWordLimit","rules","required","placeholder","formItemList","prop","label","props","type","useFormDialog","class","b","destroyOnClose"],"mappings":";;;AAKA,MAAMA,GAAAA,GAAMC,gBAAgB,gBAAgB,CAAA;AAcrC,MAAMC,gBAAAA,GAAmBA,CAACC,OAAAA,GAAmB,EAAC,KAAM;AACzD,EAAA,MAAM;AAAA,IACJC,cAAc,EAAC;AAAA,IACfC,KAAAA,GAAQ,KAAA;AAAA,IACRC,KAAAA;AAAAA;AAAAA,IAEAC,IAAAA,GAAO,CAAA;AAAA,IACPC,SAAAA,GAAY,GAAA;AAAA,IACZC,SAAAA;AAAAA,IACAC,aAAAA,GAAgB,IAAA;AAAA;AAAA,IAEhBC,KAAAA;AAAAA,IACAC,QAAAA,GAAW,IAAA;AAAA,IACXC;AAAAA,GACF,GAAIV,OAAAA;AACJ,EAAA,MAAMW,eAAgC,CACpC;AAAA,IACEH,KAAAA;AAAAA,IACAI,IAAAA,EAAM,OAAA;AAAA,IACNC,KAAAA,EAAO,GAAA;AAAA,IACPJ,QAAAA;AAAAA,IACAK,KAAAA,EAAO;AAAA,MACLJ,WAAAA;AAAAA,MACAK,IAAAA,EAAM,UAAA;AAAA,MACNX,IAAAA;AAAAA,MACAC,SAAAA;AAAAA,MACAC,SAAAA;AAAAA,MACAC;AAAAA;AACF,GACD,CAAA;AAEH,EAAA,OAAOS,aAAAA,CAAc;AAAA,IACnBb,KAAAA;AAAAA,IACAD,KAAAA;AAAAA,IACAS,YAAAA;AAAAA,IACAV,WAAAA,EAAa;AAAA,MACX,GAAGA,WAAAA;AAAAA,MACHgB,KAAAA,EAAOpB,IAAIqB,CAAAA,EAAE;AAAA,MACbC,cAAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AACH;;;;"}
|
|
@@ -7,7 +7,9 @@ export type DialogOptions = Partial<DialogProps & {
|
|
|
7
7
|
scopedSlots: Record<string, (props: any) => VNode>;
|
|
8
8
|
class: string;
|
|
9
9
|
onCancel: (reject: any) => void;
|
|
10
|
+
cancelText?: string;
|
|
10
11
|
onConfirm: (resolve: any) => void;
|
|
12
|
+
confirmText?: string;
|
|
11
13
|
showFooter: boolean;
|
|
12
14
|
}>;
|
|
13
15
|
export type ExpandDialogOptions = {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { getCurrentInstance, inject, h, nextTick, render, createVNode, mergeProps
|
|
1
|
+
import { getCurrentInstance, inject, h, nextTick, render, createVNode, mergeProps } from 'vue';
|
|
2
2
|
import { useTemplatePromise } from '../use-template-promise.mjs';
|
|
3
3
|
import { configProviderContextKey, ElConfigProvider, ElDialog, ElButton } from 'element-plus';
|
|
4
4
|
import { createNameSpace } from '../../utils/bem.mjs';
|
|
5
5
|
import { prepareProps } from '../../utils/props.mjs';
|
|
6
6
|
import { useLocale } from '../use-locale.mjs';
|
|
7
7
|
|
|
8
|
-
function _isSlot(s) {
|
|
9
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
|
-
}
|
|
11
8
|
const bem = createNameSpace("dialog");
|
|
12
9
|
const useDialog = (options = {}) => {
|
|
13
10
|
const {
|
|
@@ -19,7 +16,9 @@ const useDialog = (options = {}) => {
|
|
|
19
16
|
render: render$1,
|
|
20
17
|
destroyOnClose,
|
|
21
18
|
onConfirm,
|
|
19
|
+
confirmText,
|
|
22
20
|
onCancel,
|
|
21
|
+
cancelText,
|
|
23
22
|
showFooter = true,
|
|
24
23
|
...dialogProps
|
|
25
24
|
} = options;
|
|
@@ -39,35 +38,32 @@ const useDialog = (options = {}) => {
|
|
|
39
38
|
};
|
|
40
39
|
const slots = {};
|
|
41
40
|
if (showFooter) {
|
|
42
|
-
slots.footer = () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} else {
|
|
52
|
-
reject("cancel");
|
|
53
|
-
}
|
|
41
|
+
slots.footer = () => createVNode("div", {
|
|
42
|
+
"class": bem.e("footer")
|
|
43
|
+
}, [scopedSlots.footerPrepend?.(promiseOptions), createVNode(ElButton, {
|
|
44
|
+
"size": "default",
|
|
45
|
+
"onClick": () => {
|
|
46
|
+
if (onCancel) {
|
|
47
|
+
onCancel(reject);
|
|
48
|
+
} else {
|
|
49
|
+
reject("cancel");
|
|
54
50
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
default: () => [cancelText || t("ep.dialog.cancel")]
|
|
54
|
+
}), scopedSlots.footerInner?.(promiseOptions), createVNode(ElButton, {
|
|
55
|
+
"type": "primary",
|
|
56
|
+
"onClick": async () => {
|
|
57
|
+
if (onConfirm) {
|
|
58
|
+
onConfirm(resolve);
|
|
59
|
+
} else {
|
|
60
|
+
resolve("confirm");
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"loading": isResolving
|
|
64
|
+
}, {
|
|
65
|
+
default: () => [confirmText || t("ep.dialog.confirm")]
|
|
66
|
+
}), scopedSlots.footerAppend?.(promiseOptions)]);
|
|
71
67
|
}
|
|
72
68
|
return createVNode(ElDialog, mergeProps({
|
|
73
69
|
"class": bem.b(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dialog.mjs","sources":["../../../../../packages/hooks/dialog/use-dialog.tsx"],"sourcesContent":["import { useTemplatePromise } from '../use-template-promise'\nimport { h, getCurrentInstance, render as vRender, inject, nextTick } from 'vue'\nimport type { ComponentInternalInstance } from 'vue'\nimport {\n ElDialog,\n ElButton,\n configProviderContextKey,\n ElConfigProvider,\n} from 'element-plus'\nimport type { VNode } from 'vue'\nimport type { DialogProps } from 'element-plus'\nimport { createNameSpace } from '@el-plus/utils/bem'\nimport { prepareProps } from '@el-plus/utils/props'\nimport { useLocale } from '../use-locale'\n\nexport type DialogOptions = Partial<\n DialogProps & {\n instance: ComponentInternalInstance | null\n render: (props) => VNode\n scopedSlots: Record<string, (props) => VNode>\n class: string\n onCancel: (reject) => void\n onConfirm: (resolve) => void\n showFooter: boolean\n }\n>\nexport type ExpandDialogOptions = {\n title?: string\n dialogProps?: DialogOptions\n}\nconst bem = createNameSpace('dialog')\n\nexport const useDialog = (options: DialogOptions = {}) => {\n const { t } = useLocale()\n const {\n scopedSlots = {},\n instance,\n render,\n destroyOnClose,\n onConfirm,\n onCancel,\n showFooter = true,\n ...dialogProps\n } = options\n\n const Dialog = useTemplatePromise<any>({\n destroy: destroyOnClose,\n render: (promiseOptions, ctx) => {\n // 插槽参数增加promiseOptions\n for (const key in scopedSlots) {\n scopedSlots[key] = scopedSlots[key].bind(null, promiseOptions)\n }\n const { resolve, reject, isResolving } = promiseOptions\n const renderFunc = () => {\n return render\n ? render(promiseOptions)\n : ctx.slots.default?.(promiseOptions)\n }\n const slots: DialogOptions['scopedSlots'] = {}\n if (showFooter) {\n slots.footer = () => (\n <div class={bem.e('footer')}>\n {scopedSlots.footerPrepend?.(promiseOptions)}\n <ElButton\n size=\"default\"\n onClick={() => {\n if (onCancel) {\n onCancel(reject)\n } else {\n reject('cancel')\n }\n }}\n >\n {t('ep.dialog.cancel')}\n </ElButton>\n {scopedSlots.footerInner?.(promiseOptions)}\n <ElButton\n type=\"primary\"\n onClick={async () => {\n if (onConfirm) {\n onConfirm(resolve)\n } else {\n resolve('confirm')\n }\n }}\n loading={isResolving}\n >\n {t('ep.dialog.confirm')}\n </ElButton>\n {scopedSlots.footerAppend?.(promiseOptions)}\n </div>\n )\n }\n return (\n <ElDialog\n class={bem.b()}\n modelValue={true}\n {...{\n closeOnClickModal: false,\n closeOnPressEscape: false,\n title: t('ep.dialog.title'),\n center: false,\n // 'append-to-body': true,\n beforeClose: () => {\n reject('cancel')\n },\n ...prepareProps(dialogProps, ['modelValue']),\n }}\n v-slots={{\n ...slots,\n ...scopedSlots,\n }}\n >\n {renderFunc()}\n </ElDialog>\n )\n },\n })\n if (render) {\n // const app = createApp(component)\n // Object.assign(app._context, parentInstance.appContext)\n // app.mount(container)\n const container = document.createElement('div')\n // container.setAttribute('id', 'ep-dialog-container')\n const newInstance = instance || getCurrentInstance()\n const config = inject(configProviderContextKey) as any\n // const parentConfig =\n // newInstance?.provides[configProviderContextKey] ||\n // newInstance?.appContext?.provides[configProviderContextKey]\n // const vnode = h(Dialog)\n const vnode = h(\n ElConfigProvider,\n { locale: config?.locale },\n { default: () => h(Dialog) },\n )\n if (newInstance && newInstance.appContext) {\n // 强制继承父应用的全局组件、指令和插件\n vnode.appContext = newInstance.appContext\n }\n nextTick(() => {\n vRender(vnode, container)\n document.body.appendChild(container)\n })\n }\n\n return Dialog\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"use-dialog.mjs","sources":["../../../../../packages/hooks/dialog/use-dialog.tsx"],"sourcesContent":["import { useTemplatePromise } from '../use-template-promise'\nimport { h, getCurrentInstance, render as vRender, inject, nextTick } from 'vue'\nimport type { ComponentInternalInstance } from 'vue'\nimport {\n ElDialog,\n ElButton,\n configProviderContextKey,\n ElConfigProvider,\n} from 'element-plus'\nimport type { VNode } from 'vue'\nimport type { DialogProps } from 'element-plus'\nimport { createNameSpace } from '@el-plus/utils/bem'\nimport { prepareProps } from '@el-plus/utils/props'\nimport { useLocale } from '../use-locale'\n\nexport type DialogOptions = Partial<\n DialogProps & {\n instance: ComponentInternalInstance | null\n render: (props) => VNode\n scopedSlots: Record<string, (props) => VNode>\n class: string\n onCancel: (reject) => void\n cancelText?: string\n onConfirm: (resolve) => void\n confirmText?: string\n showFooter: boolean\n }\n>\nexport type ExpandDialogOptions = {\n title?: string\n dialogProps?: DialogOptions\n}\nconst bem = createNameSpace('dialog')\n\nexport const useDialog = (options: DialogOptions = {}) => {\n const { t } = useLocale()\n const {\n scopedSlots = {},\n instance,\n render,\n destroyOnClose,\n onConfirm,\n confirmText,\n onCancel,\n cancelText,\n showFooter = true,\n ...dialogProps\n } = options\n\n const Dialog = useTemplatePromise<any>({\n destroy: destroyOnClose,\n render: (promiseOptions, ctx) => {\n // 插槽参数增加promiseOptions\n for (const key in scopedSlots) {\n scopedSlots[key] = scopedSlots[key].bind(null, promiseOptions)\n }\n const { resolve, reject, isResolving } = promiseOptions\n const renderFunc = () => {\n return render\n ? render(promiseOptions)\n : ctx.slots.default?.(promiseOptions)\n }\n const slots: DialogOptions['scopedSlots'] = {}\n if (showFooter) {\n slots.footer = () => (\n <div class={bem.e('footer')}>\n {scopedSlots.footerPrepend?.(promiseOptions)}\n <ElButton\n size=\"default\"\n onClick={() => {\n if (onCancel) {\n onCancel(reject)\n } else {\n reject('cancel')\n }\n }}\n >\n {cancelText || t('ep.dialog.cancel')}\n </ElButton>\n {scopedSlots.footerInner?.(promiseOptions)}\n <ElButton\n type=\"primary\"\n onClick={async () => {\n if (onConfirm) {\n onConfirm(resolve)\n } else {\n resolve('confirm')\n }\n }}\n loading={isResolving}\n >\n {confirmText || t('ep.dialog.confirm')}\n </ElButton>\n {scopedSlots.footerAppend?.(promiseOptions)}\n </div>\n )\n }\n return (\n <ElDialog\n class={bem.b()}\n modelValue={true}\n {...{\n closeOnClickModal: false,\n closeOnPressEscape: false,\n title: t('ep.dialog.title'),\n center: false,\n // 'append-to-body': true,\n beforeClose: () => {\n reject('cancel')\n },\n ...prepareProps(dialogProps, ['modelValue']),\n }}\n v-slots={{\n ...slots,\n ...scopedSlots,\n }}\n >\n {renderFunc()}\n </ElDialog>\n )\n },\n })\n if (render) {\n // const app = createApp(component)\n // Object.assign(app._context, parentInstance.appContext)\n // app.mount(container)\n const container = document.createElement('div')\n // container.setAttribute('id', 'ep-dialog-container')\n const newInstance = instance || getCurrentInstance()\n const config = inject(configProviderContextKey) as any\n // const parentConfig =\n // newInstance?.provides[configProviderContextKey] ||\n // newInstance?.appContext?.provides[configProviderContextKey]\n // const vnode = h(Dialog)\n const vnode = h(\n ElConfigProvider,\n { locale: config?.locale },\n { default: () => h(Dialog) },\n )\n if (newInstance && newInstance.appContext) {\n // 强制继承父应用的全局组件、指令和插件\n vnode.appContext = newInstance.appContext\n }\n nextTick(() => {\n vRender(vnode, container)\n document.body.appendChild(container)\n })\n }\n\n return Dialog\n}\n"],"names":["bem","createNameSpace","useDialog","options","t","useLocale","scopedSlots","instance","render","destroyOnClose","onConfirm","confirmText","onCancel","cancelText","showFooter","dialogProps","Dialog","useTemplatePromise","destroy","promiseOptions","ctx","key","bind","resolve","reject","isResolving","renderFunc","slots","default","footer","_createVNode","e","footerPrepend","ElButton","onClick","footerInner","footerAppend","ElDialog","_mergeProps","b","closeOnClickModal","closeOnPressEscape","title","center","beforeClose","prepareProps","container","document","createElement","newInstance","getCurrentInstance","config","inject","configProviderContextKey","vnode","h","ElConfigProvider","locale","appContext","nextTick","vRender","body","appendChild"],"mappings":";;;;;;;AAgCA,MAAMA,GAAAA,GAAMC,gBAAgB,QAAQ,CAAA;AAE7B,MAAMC,SAAAA,GAAYA,CAACC,OAAAA,GAAyB,EAAC,KAAM;AACxD,EAAA,MAAM;AAAA,IAAEC;AAAAA,MAAMC,SAAAA,EAAU;AACxB,EAAA,MAAM;AAAA,IACJC,cAAc,EAAC;AAAA,IACfC,QAAAA;AAAAA,YACAC,QAAAA;AAAAA,IACAC,cAAAA;AAAAA,IACAC,SAAAA;AAAAA,IACAC,WAAAA;AAAAA,IACAC,QAAAA;AAAAA,IACAC,UAAAA;AAAAA,IACAC,UAAAA,GAAa,IAAA;AAAA,IACb,GAAGC;AAAAA,GACL,GAAIZ,OAAAA;AAEJ,EAAA,MAAMa,SAASC,kBAAAA,CAAwB;AAAA,IACrCC,OAAAA,EAAST,cAAAA;AAAAA,IACTD,MAAAA,EAAQA,CAACW,cAAAA,EAAgBC,GAAAA,KAAQ;AAE/B,MAAA,KAAA,MAAWC,OAAOf,WAAAA,EAAa;AAC7BA,QAAAA,WAAAA,CAAYe,GAAG,CAAA,GAAIf,WAAAA,CAAYe,GAAG,CAAA,CAAEC,IAAAA,CAAK,MAAMH,cAAc,CAAA;AAAA,MAC/D;AACA,MAAA,MAAM;AAAA,QAAEI,OAAAA;AAAAA,QAASC,MAAAA;AAAAA,QAAQC;AAAAA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AAAA,QAAAA,CAAS,MAAM;AACbC,MAAAA,MAAAA,CAAQN,OAAOR,SAAS,CAAA;AACxBC,MAAAA,QAAAA,CAASc,IAAAA,CAAKC,YAAYhB,SAAS,CAAA;AAAA,IACrC,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO9B,MAAAA;AACT;;;;"}
|
|
@@ -8,6 +8,7 @@ const useFormDialog = (options = {}) => {
|
|
|
8
8
|
const {
|
|
9
9
|
dialogProps,
|
|
10
10
|
title,
|
|
11
|
+
width = "80%",
|
|
11
12
|
...formProps
|
|
12
13
|
} = options;
|
|
13
14
|
const formRef = ref();
|
|
@@ -21,9 +22,9 @@ const useFormDialog = (options = {}) => {
|
|
|
21
22
|
};
|
|
22
23
|
return useDialog({
|
|
23
24
|
class: bem.b(),
|
|
24
|
-
width
|
|
25
|
+
width,
|
|
25
26
|
title,
|
|
26
|
-
render: (
|
|
27
|
+
render: () => {
|
|
27
28
|
return createVNode(EpForm, mergeProps({
|
|
28
29
|
"ref": formRef,
|
|
29
30
|
"modelValue": formData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form-dialog.mjs","sources":["../../../../../packages/hooks/dialog/use-form-dialog.tsx"],"sourcesContent":["import type { DialogOptions } from './use-dialog'\nimport type { FormProps } from '@el-plus/components/form'\nimport EpForm from '@el-plus/components/form'\nimport { createNameSpace } from '@el-plus/utils/bem'\nimport { useDialog } from './use-dialog'\nimport { reactive, ref, toRaw } from 'vue'\nconst bem = createNameSpace('form-dialog')\n\ntype Options = {\n title?: string\n dialogProps?: DialogOptions\n formData?: FormProps['model']\n} & FormProps\nexport const useFormDialog = (options: Options = {}) => {\n const { dialogProps, title, ...formProps } = options\n const formRef = ref()\n const isUseComFormData = !formProps.formData\n let formData = isUseComFormData ? reactive({}) : formProps.formData // eslint-disable-line\n const isDestroy = dialogProps?.destroyOnClose\n const resetForm = async () => {\n if (isDestroy) {\n await formRef.value?.resetFields()\n }\n }\n return useDialog({\n class: bem.b(),\n width
|
|
1
|
+
{"version":3,"file":"use-form-dialog.mjs","sources":["../../../../../packages/hooks/dialog/use-form-dialog.tsx"],"sourcesContent":["import type { DialogOptions } from './use-dialog'\nimport type { FormProps } from '@el-plus/components/form'\nimport EpForm from '@el-plus/components/form'\nimport { createNameSpace } from '@el-plus/utils/bem'\nimport { useDialog } from './use-dialog'\nimport { reactive, ref, toRaw } from 'vue'\nconst bem = createNameSpace('form-dialog')\n\ntype Options = {\n title?: string\n width?: string\n dialogProps?: DialogOptions\n formData?: FormProps['model']\n} & FormProps\nexport const useFormDialog = (options: Options = {}) => {\n const { dialogProps, title, width = '80%', ...formProps } = options\n const formRef = ref()\n const isUseComFormData = !formProps.formData\n let formData = isUseComFormData ? reactive({}) : formProps.formData // eslint-disable-line\n const isDestroy = dialogProps?.destroyOnClose\n const resetForm = async () => {\n if (isDestroy) {\n await formRef.value?.resetFields()\n }\n }\n return useDialog({\n class: bem.b(),\n width,\n title,\n render: () => {\n return (\n <EpForm\n ref={formRef}\n v-model={formData}\n {...{\n col: 1,\n 'label-width': 'auto',\n ...formProps,\n }}\n />\n )\n },\n onConfirm: async (resolve) => {\n await formRef.value.validate()\n resolve(\n isUseComFormData ? JSON.parse(JSON.stringify(formData)) : formData,\n )\n resetForm()\n },\n onCancel: async (resolve) => {\n await resetForm()\n resolve('cancel')\n },\n ...dialogProps,\n })\n}\n"],"names":["bem","createNameSpace","useFormDialog","options","dialogProps","title","width","formProps","formRef","ref","isUseComFormData","formData","reactive","isDestroy","destroyOnClose","resetForm","value","resetFields","useDialog","class","b","render","_createVNode","EpForm","_mergeProps","$event","col","onConfirm","resolve","validate","JSON","parse","stringify","onCancel"],"mappings":";;;;;AAMA,MAAMA,GAAAA,GAAMC,gBAAgB,aAAa,CAAA;AAQlC,MAAMC,aAAAA,GAAgBA,CAACC,OAAAA,GAAmB,EAAC,KAAM;AACtD,EAAA,MAAM;AAAA,IAAEC,WAAAA;AAAAA,IAAaC,KAAAA;AAAAA,IA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OAAOL,OAAAA,KAAY;AAC3B,MAAA,MAAMb,SAAAA,EAAU;AAChBa,MAAAA,OAAAA,CAAQ,QAAQ,CAAA;AAAA,IAClB,CAAA;AAAA,IACA,GAAGxB;AAAAA,GACJ,CAAA;AACH;;;;"}
|
package/es/hooks/index.d.ts
CHANGED
package/es/hooks/index.mjs
CHANGED
|
@@ -5,4 +5,5 @@ export { useChooseDialog } from './dialog/use-choose-dialog.mjs';
|
|
|
5
5
|
export { useFormDialog } from './dialog/use-form-dialog.mjs';
|
|
6
6
|
export { useLocale } from './use-locale.mjs';
|
|
7
7
|
export { useNavigation } from './use-navigation.mjs';
|
|
8
|
+
export { useConfirmDialog } from './dialog/use-confirm-dialog.mjs';
|
|
8
9
|
//# sourceMappingURL=index.mjs.map
|
package/es/hooks/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/es/index.mjs
CHANGED
|
@@ -38,6 +38,7 @@ export { useChooseDialog } from './hooks/dialog/use-choose-dialog.mjs';
|
|
|
38
38
|
export { useFormDialog } from './hooks/dialog/use-form-dialog.mjs';
|
|
39
39
|
export { useLocale } from './hooks/use-locale.mjs';
|
|
40
40
|
export { useNavigation } from './hooks/use-navigation.mjs';
|
|
41
|
+
export { useConfirmDialog } from './hooks/dialog/use-confirm-dialog.mjs';
|
|
41
42
|
|
|
42
43
|
const INSTALLED_KEY = /* @__PURE__ */ Symbol("INSTALLED_KEY");
|
|
43
44
|
const install = (app, options) => {
|
package/es/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../packages/el-plus/index.ts"],"sourcesContent":["import type { App, Plugin } from 'vue'\nimport components from './components'\nimport { version } from './package.json'\nimport * as plugins from './plugins'\n// import type { RouteRecordRaw } from 'vue-router'\n\nconst INSTALLED_KEY = Symbol('INSTALLED_KEY')\nconst provideGlobalConfig = (config, app) => {}\nexport type EpOptions = {\n // routes?: RouteRecordRaw\n}\nexport const install = (app: App, options?: EpOptions) => {\n if (app[INSTALLED_KEY]) return // 防止多次use导致重复安装注册,控制台警告\n app[INSTALLED_KEY] = true\n components.forEach((c) => app.use(c))\n Object.values(plugins).forEach((p) => app.use(p))\n if (options) {\n provideGlobalConfig(options, app)\n }\n}\n\nconst plugin: Plugin & { version: string } = {\n install,\n version,\n}\nexport default plugin\nexport * from '@el-plus/components/index'\nexport * from '@el-plus/hooks'\nexport * from '@el-plus/directives'\n"],"names":["plugins"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../packages/el-plus/index.ts"],"sourcesContent":["import type { App, Plugin } from 'vue'\nimport components from './components'\nimport { version } from './package.json'\nimport * as plugins from './plugins'\n// import type { RouteRecordRaw } from 'vue-router'\n\nconst INSTALLED_KEY = Symbol('INSTALLED_KEY')\nconst provideGlobalConfig = (config, app) => {}\nexport type EpOptions = {\n // routes?: RouteRecordRaw\n}\nexport const install = (app: App, options?: EpOptions) => {\n if (app[INSTALLED_KEY]) return // 防止多次use导致重复安装注册,控制台警告\n app[INSTALLED_KEY] = true\n components.forEach((c) => app.use(c))\n Object.values(plugins).forEach((p) => app.use(p))\n if (options) {\n provideGlobalConfig(options, app)\n }\n}\n\nconst plugin: Plugin & { version: string } = {\n install,\n version,\n}\nexport default plugin\nexport * from '@el-plus/components/index'\nexport * from '@el-plus/hooks'\nexport * from '@el-plus/directives'\n"],"names":["plugins"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,aAAA,0BAAuB,eAAe,CAAA;AAKrC,MAAM,OAAA,GAAU,CAAC,GAAA,EAAU,OAAA,KAAwB;AACxD,EAAA,IAAI,GAAA,CAAI,aAAa,CAAA,EAAG;AACxB,EAAA,GAAA,CAAI,aAAa,CAAA,GAAI,IAAA;AACrB,EAAA,UAAA,CAAW,QAAQ,CAAC,CAAA,KAAM,GAAA,CAAI,GAAA,CAAI,CAAC,CAAC,CAAA;AACpC,EAAA,MAAA,CAAO,MAAA,CAAOA,KAAO,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAA,KAAM,GAAA,CAAI,GAAA,CAAI,CAAC,CAAC,CAAA;AAIlD;AAEA,MAAM,MAAA,GAAuC;AAAA,EAC3C,OAAA;AAAA,EACA;AACF;;;;"}
|
package/es/package.json.mjs
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DialogOptions } from './use-dialog';
|
|
2
|
+
import type { FormItemProps } from 'el-plus/es/components/form';
|
|
3
|
+
import type { InputProps } from 'element-plus';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
title?: string;
|
|
6
|
+
width?: string;
|
|
7
|
+
dialogProps?: DialogOptions;
|
|
8
|
+
} & TextareaProps & TextareaFormItemProps>;
|
|
9
|
+
type TextareaProps = Pick<InputProps, 'rows' | 'maxlength' | 'minlength' | 'showWordLimit' | 'placeholder'>;
|
|
10
|
+
type TextareaFormItemProps = Pick<FormItemProps, 'rules' | 'required'>;
|
|
11
|
+
export declare const useConfirmDialog: (options?: Options) => import("el-plus/es").TemplatePromise<any, []>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useFormDialog = require('./use-form-dialog.js');
|
|
4
|
+
var bem$1 = require('../../utils/bem.js');
|
|
5
|
+
|
|
6
|
+
const bem = bem$1.createNameSpace("confirm-dialog");
|
|
7
|
+
const useConfirmDialog = (options = {}) => {
|
|
8
|
+
const {
|
|
9
|
+
dialogProps = {},
|
|
10
|
+
width = "50%",
|
|
11
|
+
title,
|
|
12
|
+
/** TextareaProps */
|
|
13
|
+
rows = 5,
|
|
14
|
+
maxlength = 500,
|
|
15
|
+
minlength,
|
|
16
|
+
showWordLimit = true,
|
|
17
|
+
/** TextareaFormItemProps */
|
|
18
|
+
rules,
|
|
19
|
+
required = true,
|
|
20
|
+
placeholder
|
|
21
|
+
} = options;
|
|
22
|
+
const formItemList = [{
|
|
23
|
+
rules,
|
|
24
|
+
prop: "value",
|
|
25
|
+
label: " ",
|
|
26
|
+
required,
|
|
27
|
+
props: {
|
|
28
|
+
placeholder,
|
|
29
|
+
type: "textarea",
|
|
30
|
+
rows,
|
|
31
|
+
maxlength,
|
|
32
|
+
minlength,
|
|
33
|
+
showWordLimit
|
|
34
|
+
}
|
|
35
|
+
}];
|
|
36
|
+
return useFormDialog.useFormDialog({
|
|
37
|
+
title,
|
|
38
|
+
width,
|
|
39
|
+
formItemList,
|
|
40
|
+
dialogProps: {
|
|
41
|
+
...dialogProps,
|
|
42
|
+
class: bem.b(),
|
|
43
|
+
destroyOnClose: true
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.useConfirmDialog = useConfirmDialog;
|
|
49
|
+
//# sourceMappingURL=use-confirm-dialog.js.map
|