@done-coding/admin-core 0.21.0 → 0.21.1-alpha.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 (136) hide show
  1. package/es/components/app-layout/AppLayout.vue.mjs +1 -1
  2. package/es/components/app-layout/AppLayout.vue2.mjs +51 -6
  3. package/es/components/app-layout/AppPage.vue.mjs +1 -1
  4. package/es/components/app-layout/AppPage.vue2.mjs +16 -9
  5. package/es/components/display/ShadowClone.vue.mjs +32 -0
  6. package/es/components/display/ShadowClone.vue2.mjs +4 -0
  7. package/es/components/display/use-shadow-target.mjs +76 -0
  8. package/es/components/form/FormActiveFilter.vue.mjs +7 -0
  9. package/es/components/form/FormActiveFilter.vue2.mjs +62 -0
  10. package/es/components/form/FormInput.vue.mjs +27 -0
  11. package/es/components/form/FormInput.vue2.mjs +4 -0
  12. package/es/components/form/FormInputShadowClone.vue.mjs +47 -0
  13. package/es/components/form/FormInputShadowClone.vue2.mjs +4 -0
  14. package/es/components/form/FormMain.vue.mjs +1 -1
  15. package/es/components/form/FormMain.vue2.mjs +5 -25
  16. package/es/components/form/FormSelectShadowClone.vue.mjs +57 -0
  17. package/es/components/form/FormSelectShadowClone.vue2.mjs +4 -0
  18. package/es/components/form/FormShadowCloneDispatch.vue.mjs +7 -0
  19. package/es/components/form/FormShadowCloneDispatch.vue2.mjs +74 -0
  20. package/es/components/form/FormSortSwitch.vue.mjs +7 -0
  21. package/es/components/form/FormSortSwitch.vue2.mjs +188 -0
  22. package/es/components/form/FormSortSwitchGroup.vue.mjs +7 -0
  23. package/es/components/form/FormSortSwitchGroup.vue2.mjs +68 -0
  24. package/es/components/form/FormUpload.vue.mjs +8 -0
  25. package/es/components/form/FormUpload.vue2.mjs +112 -0
  26. package/es/components/form/FormUploadAudio.vue.mjs +7 -0
  27. package/es/components/form/FormUploadAudio.vue2.mjs +88 -0
  28. package/es/components/form/FormUploadCard.vue.mjs +7 -0
  29. package/es/components/form/FormUploadCard.vue2.mjs +56 -0
  30. package/es/components/form/FormUploadFileInfo.vue.mjs +7 -0
  31. package/es/components/form/FormUploadFileInfo.vue2.mjs +36 -0
  32. package/es/components/form/FormUploadImage.vue.mjs +7 -0
  33. package/es/components/form/FormUploadImage.vue2.mjs +77 -0
  34. package/es/components/form/FormUploadTrigger.vue.mjs +7 -0
  35. package/es/components/form/FormUploadTrigger.vue2.mjs +34 -0
  36. package/es/components/form/FormUploadVideo.vue.mjs +7 -0
  37. package/es/components/form/FormUploadVideo.vue2.mjs +74 -0
  38. package/es/components/form/use-password-autofill.mjs +34 -0
  39. package/es/components/form/use-upload-state.mjs +98 -0
  40. package/es/components/list-layout/ListLayout.vue.mjs +1 -1
  41. package/es/components/list-layout/ListLayout.vue2.mjs +36 -9
  42. package/es/components/list-layout/use-active-filter.mjs +133 -0
  43. package/es/components/modal/ImagePreviewTrigger.vue.mjs +34 -0
  44. package/es/components/modal/ImagePreviewTrigger.vue2.mjs +4 -0
  45. package/es/components/modal/ModalImagePreview.vue.mjs +52 -0
  46. package/es/components/modal/ModalImagePreview.vue2.mjs +4 -0
  47. package/es/components/modal/ModalPorter.vue.mjs +49 -2
  48. package/es/components/modal/ModalShelf.vue.mjs +13 -4
  49. package/es/components/modal/ModalVideoPreview.vue.mjs +8 -0
  50. package/es/components/modal/ModalVideoPreview.vue2.mjs +93 -0
  51. package/es/components/modal/VideoPreviewTrigger.vue.mjs +7 -0
  52. package/es/components/modal/VideoPreviewTrigger.vue2.mjs +96 -0
  53. package/es/components/modal/modal-global-keys.mjs +11 -0
  54. package/es/components/modal/modal-global-symbol.mjs +6 -0
  55. package/es/components/modal/modal-shelf-core.mjs +53 -4
  56. package/es/components/table/TableEmpty.vue.mjs +36 -0
  57. package/es/components/table/TableEmpty.vue2.mjs +4 -0
  58. package/es/components/table/TableMain.vue.mjs +1 -1
  59. package/es/components/table/TableMain.vue2.mjs +21 -8
  60. package/es/components/view-layout/ViewLayout.vue.mjs +1 -1
  61. package/es/components/view-layout/ViewLayout.vue2.mjs +1 -1
  62. package/es/hooks/menus-dispatch.mjs +8 -3
  63. package/es/index.mjs +127 -91
  64. package/es/style.css +412 -33
  65. package/package.json +2 -2
  66. package/src/components/app-layout/docs/README-AppLayout.md +48 -0
  67. package/src/components/app-layout/docs/README-AppPage.md +40 -2
  68. package/src/components/display/README.md +9 -3
  69. package/src/components/display/docs/README-ShadowClone.md +75 -0
  70. package/src/components/form/README.md +15 -2
  71. package/src/components/form/docs/README-FormActiveFilter.md +57 -0
  72. package/src/components/form/docs/README-FormInput.md +66 -0
  73. package/src/components/form/docs/README-FormSelect.md +77 -0
  74. package/src/components/form/docs/README-FormShadowCloneDispatch.md +65 -0
  75. package/src/components/form/docs/README-FormSortSwitchGroup.md +131 -0
  76. package/src/components/form/docs/README-FormUpload.md +108 -0
  77. package/src/components/form/docs/README-FormUploadAudio.md +80 -0
  78. package/src/components/form/docs/README-FormUploadImage.md +83 -0
  79. package/src/components/form/docs/README-FormUploadVideo.md +82 -0
  80. package/src/components/list-layout/README.md +6 -2
  81. package/src/components/list-layout/docs/README-ListLayout.md +1 -0
  82. package/src/components/modal/README.md +7 -2
  83. package/src/components/modal/docs/README-ImagePreviewTrigger.md +78 -0
  84. package/src/components/modal/docs/README-ModalImagePreview.md +78 -0
  85. package/src/components/modal/docs/README-ModalPorter.md +10 -0
  86. package/src/components/modal/docs/README-ModalShelf.md +11 -2
  87. package/src/components/modal/docs/README-ModalVideoPreview.md +89 -0
  88. package/src/components/modal/docs/README-VideoPreviewTrigger.md +91 -0
  89. package/src/components/table/docs/README-TableMain.md +3 -0
  90. package/types/components/app-layout/AppLayout.vue.d.ts +31 -1
  91. package/types/components/app-layout/AppPage.vue.d.ts +7 -2
  92. package/types/components/app-layout/types.d.ts +25 -0
  93. package/types/components/display/ShadowClone.vue.d.ts +20 -0
  94. package/types/components/display/TabsTile.vue.d.ts +2 -2
  95. package/types/components/display/index.d.ts +8 -1
  96. package/types/components/display/types.d.ts +7 -0
  97. package/types/components/display/use-shadow-target.d.ts +9 -0
  98. package/types/components/form/FormActiveFilter.vue.d.ts +9 -0
  99. package/types/components/form/FormInput.vue.d.ts +3 -0
  100. package/types/components/form/FormInputShadowClone.vue.d.ts +7 -0
  101. package/types/components/form/FormSearch.vue.d.ts +1 -1
  102. package/types/components/form/FormSelectShadowClone.vue.d.ts +39 -0
  103. package/types/components/form/FormShadowCloneDispatch.vue.d.ts +44 -0
  104. package/types/components/form/FormSortSwitch.vue.d.ts +17 -0
  105. package/types/components/form/FormSortSwitchGroup.vue.d.ts +15 -0
  106. package/types/components/form/FormUpload.vue.d.ts +57 -0
  107. package/types/components/form/FormUploadAudio.vue.d.ts +30 -0
  108. package/types/components/form/FormUploadCard.vue.d.ts +24 -0
  109. package/types/components/form/FormUploadFileInfo.vue.d.ts +10 -0
  110. package/types/components/form/FormUploadImage.vue.d.ts +34 -0
  111. package/types/components/form/FormUploadTrigger.vue.d.ts +11 -0
  112. package/types/components/form/FormUploadVideo.vue.d.ts +34 -0
  113. package/types/components/form/index.d.ts +12 -1
  114. package/types/components/form/types.d.ts +158 -0
  115. package/types/components/form/use-password-autofill.d.ts +11 -0
  116. package/types/components/form/use-upload-state.d.ts +29 -0
  117. package/types/components/list-layout/ListLayout.vue.d.ts +3 -0
  118. package/types/components/list-layout/types.d.ts +16 -0
  119. package/types/components/list-layout/use-active-filter.d.ts +27 -0
  120. package/types/components/modal/ImagePreviewTrigger.vue.d.ts +41 -0
  121. package/types/components/modal/ModalConfirm.vue.d.ts +1 -1
  122. package/types/components/modal/ModalImagePreview.vue.d.ts +31 -0
  123. package/types/components/modal/ModalPorter.vue.d.ts +7 -0
  124. package/types/components/modal/ModalShelf.vue.d.ts +12 -3
  125. package/types/components/modal/ModalVideoPreview.vue.d.ts +40 -0
  126. package/types/components/modal/VideoPreviewTrigger.vue.d.ts +43 -0
  127. package/types/components/modal/index.d.ts +6 -1
  128. package/types/components/modal/modal-global-keys.d.ts +25 -0
  129. package/types/components/modal/modal-global-symbol.d.ts +8 -0
  130. package/types/components/modal/modal-shelf-core.d.ts +11 -3
  131. package/types/components/modal/modal-shelf-types.d.ts +50 -0
  132. package/types/components/table/TableEmpty.vue.d.ts +11 -0
  133. package/types/components/table/types.d.ts +11 -0
  134. package/types/components/view-layout/types.d.ts +1 -1
  135. package/types/injectInfo.json.d.ts +1 -1
  136. package/types/store/app.d.ts +1 -1
@@ -0,0 +1,77 @@
1
+ import { defineComponent, openBlock, createBlock, mergeProps, withCtx, renderSlot, createVNode, unref, createElementBlock } from "vue";
2
+ import FormUpload from "./FormUpload.vue.mjs";
3
+ import FormUploadCard from "./FormUploadCard.vue.mjs";
4
+ import FormUploadTrigger from "./FormUploadTrigger.vue.mjs";
5
+ import _sfc_main$1 from "../modal/ImagePreviewTrigger.vue.mjs";
6
+ const _hoisted_1 = {
7
+ key: 1,
8
+ class: "dc-form-upload-image__thumb dc-form-upload-image__thumb_empty"
9
+ };
10
+ const _sfc_main = /* @__PURE__ */ defineComponent({
11
+ ...{ inheritAttrs: false },
12
+ __name: "FormUploadImage",
13
+ props: {
14
+ uploadFn: {},
15
+ loadingKey: {},
16
+ maxCount: { default: 1 },
17
+ maxSize: {},
18
+ accept: { default: "image/*" },
19
+ drag: { type: Boolean, default: false },
20
+ disabled: { type: Boolean, default: false },
21
+ showProgress: { type: Boolean, default: true },
22
+ placeholder: {},
23
+ listType: { default: "picture-card" }
24
+ },
25
+ setup(__props) {
26
+ return (_ctx, _cache) => {
27
+ return openBlock(), createBlock(FormUpload, mergeProps({ class: "dc-form-upload-image" }, _ctx.$attrs, {
28
+ "upload-fn": __props.uploadFn,
29
+ "loading-key": __props.loadingKey,
30
+ "max-count": __props.maxCount,
31
+ "max-size": __props.maxSize,
32
+ accept: __props.accept,
33
+ drag: __props.drag,
34
+ disabled: __props.disabled,
35
+ "show-progress": __props.showProgress,
36
+ placeholder: __props.placeholder,
37
+ "list-type": __props.listType
38
+ }), {
39
+ tip: withCtx(() => [
40
+ renderSlot(_ctx.$slots, "tip", {}, void 0, true)
41
+ ]),
42
+ file: withCtx(({ file, index, remove }) => [
43
+ renderSlot(_ctx.$slots, "file", {
44
+ file,
45
+ index,
46
+ remove
47
+ }, () => [
48
+ createVNode(FormUploadCard, {
49
+ file,
50
+ remove
51
+ }, {
52
+ default: withCtx(() => [
53
+ file.url ? (openBlock(), createBlock(unref(_sfc_main$1), {
54
+ key: 0,
55
+ class: "dc-form-upload-image__thumb",
56
+ src: file.url,
57
+ fit: "cover",
58
+ lazy: ""
59
+ }, null, 8, ["src"])) : (openBlock(), createElementBlock("div", _hoisted_1))
60
+ ]),
61
+ _: 2
62
+ }, 1032, ["file", "remove"])
63
+ ], true)
64
+ ]),
65
+ default: withCtx(() => [
66
+ renderSlot(_ctx.$slots, "default", {}, () => [
67
+ createVNode(FormUploadTrigger, { card: "" })
68
+ ], true)
69
+ ]),
70
+ _: 3
71
+ }, 16, ["upload-fn", "loading-key", "max-count", "max-size", "accept", "drag", "disabled", "show-progress", "placeholder", "list-type"]);
72
+ };
73
+ }
74
+ });
75
+ export {
76
+ _sfc_main as default
77
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./FormUploadTrigger.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const FormUploadTrigger = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-9fb0fb2a"]]);
5
+ export {
6
+ FormUploadTrigger as default
7
+ };
@@ -0,0 +1,34 @@
1
+ import { defineComponent, openBlock, createElementBlock, normalizeClass, createVNode, unref, withCtx, createBlock, toDisplayString, createCommentVNode } from "vue";
2
+ import { ElIcon } from "element-plus";
3
+ import { Plus, UploadFilled } from "@element-plus/icons-vue";
4
+ const _hoisted_1 = {
5
+ key: 0,
6
+ class: "dc-form-upload-trigger__text"
7
+ };
8
+ const _sfc_main = /* @__PURE__ */ defineComponent({
9
+ __name: "FormUploadTrigger",
10
+ props: {
11
+ text: { default: "点击上传" },
12
+ card: { type: Boolean, default: false }
13
+ },
14
+ setup(__props) {
15
+ return (_ctx, _cache) => {
16
+ return openBlock(), createElementBlock("div", {
17
+ class: normalizeClass(["dc-form-upload-trigger", { "dc-form-upload-trigger_card": __props.card }])
18
+ }, [
19
+ createVNode(unref(ElIcon), {
20
+ size: __props.card ? 28 : 16
21
+ }, {
22
+ default: withCtx(() => [
23
+ __props.card ? (openBlock(), createBlock(unref(Plus), { key: 0 })) : (openBlock(), createBlock(unref(UploadFilled), { key: 1 }))
24
+ ]),
25
+ _: 1
26
+ }, 8, ["size"]),
27
+ !__props.card ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(__props.text), 1)) : createCommentVNode("", true)
28
+ ], 2);
29
+ };
30
+ }
31
+ });
32
+ export {
33
+ _sfc_main as default
34
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./FormUploadVideo.vue2.mjs";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
+ const FormUploadVideo = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5eac98bc"]]);
5
+ export {
6
+ FormUploadVideo as default
7
+ };
@@ -0,0 +1,74 @@
1
+ import { defineComponent, openBlock, createBlock, mergeProps, withCtx, renderSlot, createVNode, unref, createElementBlock } from "vue";
2
+ import FormUpload from "./FormUpload.vue.mjs";
3
+ import FormUploadCard from "./FormUploadCard.vue.mjs";
4
+ import FormUploadTrigger from "./FormUploadTrigger.vue.mjs";
5
+ import VideoPreviewTrigger from "../modal/VideoPreviewTrigger.vue.mjs";
6
+ const _hoisted_1 = {
7
+ key: 1,
8
+ class: "dc-form-upload-video__thumb dc-form-upload-video__thumb_empty"
9
+ };
10
+ const _sfc_main = /* @__PURE__ */ defineComponent({
11
+ ...{ inheritAttrs: false },
12
+ __name: "FormUploadVideo",
13
+ props: {
14
+ uploadFn: {},
15
+ loadingKey: {},
16
+ maxCount: { default: 1 },
17
+ maxSize: {},
18
+ accept: { default: "video/*" },
19
+ drag: { type: Boolean, default: false },
20
+ disabled: { type: Boolean, default: false },
21
+ showProgress: { type: Boolean, default: true },
22
+ placeholder: {},
23
+ listType: { default: "picture-card" }
24
+ },
25
+ setup(__props) {
26
+ return (_ctx, _cache) => {
27
+ return openBlock(), createBlock(FormUpload, mergeProps({ class: "dc-form-upload-video" }, _ctx.$attrs, {
28
+ "upload-fn": __props.uploadFn,
29
+ "loading-key": __props.loadingKey,
30
+ "max-count": __props.maxCount,
31
+ "max-size": __props.maxSize,
32
+ accept: __props.accept,
33
+ drag: __props.drag,
34
+ disabled: __props.disabled,
35
+ "show-progress": __props.showProgress,
36
+ placeholder: __props.placeholder,
37
+ "list-type": __props.listType
38
+ }), {
39
+ tip: withCtx(() => [
40
+ renderSlot(_ctx.$slots, "tip", {}, void 0, true)
41
+ ]),
42
+ file: withCtx(({ file, index, remove }) => [
43
+ renderSlot(_ctx.$slots, "file", {
44
+ file,
45
+ index,
46
+ remove
47
+ }, () => [
48
+ createVNode(FormUploadCard, {
49
+ file,
50
+ remove
51
+ }, {
52
+ default: withCtx(() => [
53
+ file.url ? (openBlock(), createBlock(unref(VideoPreviewTrigger), {
54
+ key: 0,
55
+ url: file.url
56
+ }, null, 8, ["url"])) : (openBlock(), createElementBlock("div", _hoisted_1))
57
+ ]),
58
+ _: 2
59
+ }, 1032, ["file", "remove"])
60
+ ], true)
61
+ ]),
62
+ default: withCtx(() => [
63
+ renderSlot(_ctx.$slots, "default", {}, () => [
64
+ createVNode(FormUploadTrigger, { card: "" })
65
+ ], true)
66
+ ]),
67
+ _: 3
68
+ }, 16, ["upload-fn", "loading-key", "max-count", "max-size", "accept", "drag", "disabled", "show-progress", "placeholder", "list-type"]);
69
+ };
70
+ }
71
+ });
72
+ export {
73
+ _sfc_main as default
74
+ };
@@ -0,0 +1,34 @@
1
+ import { computed, ref, onMounted, onUnmounted } from "vue";
2
+ function usePasswordAutofill(props) {
3
+ const isPasswordForm = computed(
4
+ () => props.type === "password" || props.showPassword === true
5
+ );
6
+ const autocompleteOut = computed(
7
+ () => isPasswordForm.value && typeof props.passwordAutoComplete === "string" ? props.passwordAutoComplete : void 0
8
+ );
9
+ const delayedType = ref(
10
+ (props.type === "password" || props.showPassword === true) && typeof props.passwordAutoComplete === "number" ? "text" : void 0
11
+ );
12
+ const showPasswordOut = computed(
13
+ () => delayedType.value === "text" ? false : props.showPassword === true ? true : void 0
14
+ );
15
+ let timer;
16
+ onMounted(() => {
17
+ if (delayedType.value !== "text" || typeof props.passwordAutoComplete !== "number") {
18
+ return;
19
+ }
20
+ timer = window.setTimeout(() => {
21
+ delayedType.value = "password";
22
+ }, props.passwordAutoComplete);
23
+ });
24
+ onUnmounted(() => {
25
+ if (timer !== void 0) {
26
+ window.clearTimeout(timer);
27
+ }
28
+ });
29
+ const inputType = computed(() => delayedType.value ?? props.type);
30
+ return { inputType, autocompleteOut, showPasswordOut };
31
+ }
32
+ export {
33
+ usePasswordAutofill
34
+ };
@@ -0,0 +1,98 @@
1
+ import { inject, ref, watch } from "vue";
2
+ import { FORM_ITEM_CHANGE_LOADING } from "./utils.mjs";
3
+ let uploadUidSeed = 0;
4
+ const uploadFileFromUrl = (url) => {
5
+ const segment = url.split("?")[0].split("/").pop() || "";
6
+ let name = segment;
7
+ try {
8
+ name = decodeURIComponent(segment);
9
+ } catch {
10
+ }
11
+ return { uid: ++uploadUidSeed, name: name || url, url, status: "success" };
12
+ };
13
+ function useUploadState(modelValue, options) {
14
+ const {
15
+ maxCount,
16
+ maxSize,
17
+ uploadFn,
18
+ loadingKey,
19
+ onUploadSuccess,
20
+ onUploadError
21
+ } = options;
22
+ const changeLoading = inject(
23
+ FORM_ITEM_CHANGE_LOADING,
24
+ void 0
25
+ );
26
+ const fileList = ref([]);
27
+ const uploadingCount = ref(0);
28
+ const urlsOf = (value) => Array.isArray(value) ? value : [];
29
+ const applyLoading = (message) => {
30
+ const key = loadingKey();
31
+ if (!key || !changeLoading) return;
32
+ changeLoading({ key, message });
33
+ };
34
+ const beginUpload = () => {
35
+ if (uploadingCount.value === 0) applyLoading("上传中");
36
+ uploadingCount.value += 1;
37
+ };
38
+ const endUpload = () => {
39
+ uploadingCount.value -= 1;
40
+ if (uploadingCount.value === 0) applyLoading();
41
+ };
42
+ watch(
43
+ modelValue,
44
+ (value) => {
45
+ const urls = urlsOf(value);
46
+ if (urls.length === 0) {
47
+ fileList.value = [];
48
+ } else if (fileList.value.length === 0) {
49
+ fileList.value = urls.map(uploadFileFromUrl);
50
+ }
51
+ },
52
+ { immediate: true }
53
+ );
54
+ const handleUpload = async (options2) => {
55
+ beginUpload();
56
+ try {
57
+ const sizeLimitMb = maxSize();
58
+ if (sizeLimitMb !== void 0 && options2.file.size > sizeLimitMb * 1024 * 1024) {
59
+ throw new Error(`文件超过大小上限 ${sizeLimitMb}MB`);
60
+ }
61
+ const url = await uploadFn()(
62
+ options2.file,
63
+ (percent) => {
64
+ var _a;
65
+ return (_a = options2.onProgress) == null ? void 0 : _a.call(options2, {
66
+ percent
67
+ });
68
+ }
69
+ );
70
+ const uploadFile = fileList.value.find((f) => f.raw === options2.file);
71
+ if (uploadFile) uploadFile.url = url;
72
+ if (maxCount() > 1) {
73
+ modelValue.value = [...urlsOf(modelValue.value), url];
74
+ } else {
75
+ modelValue.value = [url];
76
+ }
77
+ onUploadSuccess(url, options2.file);
78
+ return url;
79
+ } catch (error) {
80
+ onUploadError(error, options2.file);
81
+ throw error;
82
+ } finally {
83
+ endUpload();
84
+ }
85
+ };
86
+ const handleRemove = (file) => {
87
+ const url = file.response ?? file.url;
88
+ if (url) {
89
+ modelValue.value = urlsOf(modelValue.value).filter(
90
+ (item) => item !== url
91
+ );
92
+ }
93
+ };
94
+ return { fileList, uploadingCount, handleUpload, handleRemove };
95
+ }
96
+ export {
97
+ useUploadState
98
+ };
@@ -1,7 +1,7 @@
1
1
  import _sfc_main from "./ListLayout.vue2.mjs";
2
2
  /* empty css */
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
4
- const ListLayout = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5301293b"]]);
4
+ const ListLayout = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8527d1df"]]);
5
5
  export {
6
6
  ListLayout as default
7
7
  };
@@ -1,8 +1,10 @@
1
1
  import { defineComponent, useCssVars, unref, useSlots, computed, useModel, ref, shallowRef, watch, withDirectives, openBlock, createBlock, normalizeClass, withCtx, createVNode, mergeProps, createSlots, renderSlot, normalizeProps, guardReactiveProps, renderList, createCommentVNode, mergeModels } from "vue";
2
2
  import { vLoading } from "element-plus";
3
+ import FormActiveFilter from "../form/FormActiveFilter.vue.mjs";
3
4
  import FormSearch from "../form/FormSearch.vue.mjs";
4
5
  import { generateFormData, stringifyFormData } from "../form/utils.mjs";
5
6
  import { useListLayoutSticky } from "./use-list-layout-sticky.mjs";
7
+ import { useActiveFilter } from "./use-active-filter.mjs";
6
8
  import _sfc_main$1 from "../display/WatchSize.vue.mjs";
7
9
  import TableMain from "../table/TableMain.vue.mjs";
8
10
  import SlotLayoutFlowAside from "../slot-layout/SlotLayoutFlowAside.vue.mjs";
@@ -29,10 +31,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
29
31
  injectInfo: {},
30
32
  beforeSearch: {},
31
33
  clearTableFilterOnReset: { type: Boolean },
34
+ initialSearch: { type: Boolean, default: true },
32
35
  separateSearch: { type: Boolean, default: false },
33
36
  separateSearchConfig: {},
34
37
  searchSticky: { type: Boolean, default: false },
35
38
  toolbarSticky: { type: Boolean, default: false },
39
+ formActiveFilter: { type: Boolean, default: false },
40
+ allowClear: { type: Boolean, default: false },
36
41
  pagerSticky: { type: Boolean, default: false },
37
42
  headerObserveResize: { type: Boolean, default: false },
38
43
  operationObserveResize: { type: Boolean, default: false }
@@ -47,10 +52,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
47
52
  emits: /* @__PURE__ */ mergeModels(["dataChange", "pageInfoChange"], ["update:isAutoRefresh", "update:refreshInterval", "update:customView"]),
48
53
  setup(__props, { expose: __expose, emit: __emit }) {
49
54
  useCssVars((_ctx) => ({
50
- "ee852864": minHeight.value,
51
- "v6179ebd9": unref(searchStickyTop),
52
- "v0e6603c8": unref(toolbarStickyTop),
53
- "v6d62e58c": unref(pagerStickyBottom)
55
+ "v3483351c": minHeight.value,
56
+ "v5ccbcb06": unref(searchStickyTop),
57
+ "e69ab810": unref(toolbarStickyTop),
58
+ "v5631fb30": unref(pagerStickyBottom)
54
59
  }));
55
60
  const props = __props;
56
61
  const listLayoutEmits = __emit;
@@ -102,6 +107,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
102
107
  searchHeight: () => searchHeight.value,
103
108
  showSearch: () => showSearch.value
104
109
  });
110
+ const activeFilterEnabled = computed(() => props.formActiveFilter);
111
+ const activeFilterApi = useActiveFilter({
112
+ enabled: () => activeFilterEnabled.value,
113
+ query,
114
+ list: props.list,
115
+ formData: data,
116
+ reload: () => {
117
+ var _a;
118
+ return (_a = tableMain.value) == null ? void 0 : _a.reload();
119
+ }
120
+ });
121
+ const activeFilters = activeFilterApi.activeFilters;
105
122
  const operationHeightAdjust = computed(() => {
106
123
  if (!hasOperation.value) {
107
124
  return 0;
@@ -261,7 +278,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
261
278
  (n) => {
262
279
  const fData = generateFormData(n);
263
280
  data.value = fData;
264
- onSearch(stringifyFormData(fData, n));
281
+ if (props.initialSearch) {
282
+ onSearch(stringifyFormData(fData, n));
283
+ }
265
284
  },
266
285
  {
267
286
  immediate: true
@@ -315,14 +334,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
315
334
  };
316
335
  })
317
336
  ]), 1040, ["list", "data", "compact"]),
318
- hasOperation.value ? (openBlock(), createBlock(unref(_sfc_main$1), {
337
+ hasOperation.value || __props.formActiveFilter ? (openBlock(), createBlock(unref(_sfc_main$1), {
319
338
  key: 1,
320
339
  class: "list-layout-operation",
321
340
  "observe-resize": __props.operationObserveResize,
322
341
  onHeightChange: onOperateHeightChange
323
342
  }, {
324
343
  default: withCtx(() => [
325
- renderSlot(_ctx.$slots, "operation", {}, void 0, true)
344
+ __props.formActiveFilter ? (openBlock(), createBlock(unref(FormActiveFilter), {
345
+ key: 0,
346
+ filters: unref(activeFilters),
347
+ "allow-clear": __props.allowClear,
348
+ onRemove: unref(activeFilterApi).remove,
349
+ onClear: unref(activeFilterApi).clearAll
350
+ }, null, 8, ["filters", "allow-clear", "onRemove", "onClear"])) : createCommentVNode("", true),
351
+ hasOperation.value ? renderSlot(_ctx.$slots, "operation", { key: 1 }, void 0, true) : createCommentVNode("", true)
326
352
  ]),
327
353
  _: 3
328
354
  }, 8, ["observe-resize"])) : createCommentVNode("", true)
@@ -343,7 +369,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
343
369
  maxHeight: tableMaxHeight.value,
344
370
  rowKey: assertRowKey.value,
345
371
  toolbar: __props.toolbar,
346
- showSwitchView: __props.showSwitchView
372
+ showSwitchView: __props.showSwitchView,
373
+ "initial-search": __props.initialSearch
347
374
  }, __props.tableMainProps, {
348
375
  refine: false,
349
376
  injectInfo: injectInfoAdjust.value,
@@ -378,7 +405,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
378
405
  })
379
406
  };
380
407
  })
381
- ]), 1040, ["is-auto-refresh", "refresh-interval", "custom-view", "api", "columns", "query", "maxHeight", "rowKey", "toolbar", "showSwitchView", "injectInfo"])
408
+ ]), 1040, ["is-auto-refresh", "refresh-interval", "custom-view", "api", "columns", "query", "maxHeight", "rowKey", "toolbar", "showSwitchView", "initial-search", "injectInfo"])
382
409
  ]),
383
410
  _: 3
384
411
  }, 8, ["class", "separate", "type", "gap", "aside-width", "aside-max-height"])), [
@@ -0,0 +1,133 @@
1
+ import { computed } from "vue";
2
+ function isEmptyValue(value) {
3
+ return value === "" || value === null || value === void 0 || Array.isArray(value) && value.length === 0;
4
+ }
5
+ function findConfig(list, field) {
6
+ return list.find((c) => c.key === field);
7
+ }
8
+ function resolveOptions(config) {
9
+ const props = typeof config.props === "function" ? config.props() : config.props;
10
+ const opts = props == null ? void 0 : props.options;
11
+ return Array.isArray(opts) ? opts : void 0;
12
+ }
13
+ function isSortOptions(opts) {
14
+ return Array.isArray(opts) && opts.length > 0 && typeof opts[0].field === "string" && !("value" in opts[0]);
15
+ }
16
+ function resolveSortLabel(config, value) {
17
+ const opts = resolveOptions(config);
18
+ if (!isSortOptions(opts)) {
19
+ return "";
20
+ }
21
+ const parts = String(value).split(",").filter(Boolean).map((rule) => {
22
+ const [field, dir] = rule.split(":");
23
+ const opt = opts.find((o) => o.field === field);
24
+ const dirText = dir === "asc" ? "升序" : dir === "desc" ? "降序" : "";
25
+ return `${(opt == null ? void 0 : opt.label) ?? field}${dirText ? `:${dirText}` : ""}`;
26
+ });
27
+ return parts.length ? parts.join("、") : "";
28
+ }
29
+ function matchLabel(config, value) {
30
+ const opts = resolveOptions(config);
31
+ if (isSortOptions(opts)) {
32
+ return resolveSortLabel(config, value) || void 0;
33
+ }
34
+ const hit = opts == null ? void 0 : opts.find((o) => o.value === value);
35
+ return hit ? String(hit.label) : void 0;
36
+ }
37
+ function resolveInit(config) {
38
+ return typeof config.init === "function" ? config.init() : config.init;
39
+ }
40
+ function buildSplitIndex(list) {
41
+ const index = /* @__PURE__ */ new Map();
42
+ for (const config of list) {
43
+ if (Array.isArray(config.splitKeys)) {
44
+ for (const key of config.splitKeys) {
45
+ index.set(key, config);
46
+ }
47
+ }
48
+ }
49
+ return index;
50
+ }
51
+ function useActiveFilter(options) {
52
+ const { enabled, query, list, formData, reload } = options;
53
+ const splitIndex = buildSplitIndex(list);
54
+ function composeSplitValue(config, fields) {
55
+ return (config.splitKeys ?? []).filter((key) => fields.includes(key)).map((key) => String(query.value[key])).join(" ~ ");
56
+ }
57
+ const activeFilters = computed(() => {
58
+ if (!enabled()) {
59
+ return [];
60
+ }
61
+ const entries = [];
62
+ const splitEntries = /* @__PURE__ */ new Map();
63
+ for (const [field, value] of Object.entries(query.value)) {
64
+ if (isEmptyValue(value)) {
65
+ continue;
66
+ }
67
+ const config = findConfig(list, field);
68
+ const splitConfig = splitIndex.get(field);
69
+ if (splitConfig && !config) {
70
+ let entry = splitEntries.get(splitConfig.key);
71
+ if (!entry) {
72
+ entry = {
73
+ field: splitConfig.key,
74
+ fields: [],
75
+ label: splitConfig.label ?? splitConfig.key,
76
+ displayValue: "",
77
+ configKey: splitConfig.key
78
+ };
79
+ splitEntries.set(splitConfig.key, entry);
80
+ entries.push(entry);
81
+ }
82
+ entry.fields.push(field);
83
+ } else {
84
+ entries.push({
85
+ field,
86
+ label: (config == null ? void 0 : config.label) ?? field,
87
+ displayValue: config ? matchLabel(config, value) ?? String(value) : String(value),
88
+ configKey: config == null ? void 0 : config.key
89
+ });
90
+ }
91
+ }
92
+ for (const entry of splitEntries.values()) {
93
+ const config = findConfig(list, entry.configKey);
94
+ if (config) {
95
+ entry.displayValue = composeSplitValue(config, entry.fields);
96
+ }
97
+ }
98
+ return entries;
99
+ });
100
+ function removeEntry(entry) {
101
+ var _a;
102
+ const fields = ((_a = entry.fields) == null ? void 0 : _a.length) ? entry.fields : [entry.field];
103
+ for (const field of fields) {
104
+ delete query.value[field];
105
+ }
106
+ if (entry.configKey) {
107
+ const config = findConfig(list, entry.configKey);
108
+ if (config) {
109
+ formData.value[config.key] = resolveInit(config);
110
+ }
111
+ }
112
+ }
113
+ function remove(entry) {
114
+ if (!enabled()) {
115
+ return;
116
+ }
117
+ removeEntry(entry);
118
+ reload();
119
+ }
120
+ function clearAll() {
121
+ if (!enabled()) {
122
+ return;
123
+ }
124
+ for (const entry of activeFilters.value) {
125
+ removeEntry(entry);
126
+ }
127
+ reload();
128
+ }
129
+ return { activeFilters, remove, clearAll };
130
+ }
131
+ export {
132
+ useActiveFilter
133
+ };
@@ -0,0 +1,34 @@
1
+ import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, renderSlot } from "vue";
2
+ import { ElImage } from "element-plus";
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ ...{ inheritAttrs: false },
5
+ __name: "ImagePreviewTrigger",
6
+ props: {
7
+ src: {},
8
+ previewSrc: {},
9
+ lazy: { type: Boolean, default: true },
10
+ preview: { type: Boolean, default: true }
11
+ },
12
+ setup(__props) {
13
+ return (_ctx, _cache) => {
14
+ return openBlock(), createBlock(unref(ElImage), mergeProps({
15
+ class: "dc-image-preview-trigger image-preview-trigger",
16
+ src: __props.src,
17
+ lazy: __props.lazy,
18
+ "preview-src-list": __props.preview ? [__props.previewSrc ?? __props.src] : void 0,
19
+ "preview-teleported": __props.preview
20
+ }, _ctx.$attrs), {
21
+ placeholder: withCtx(() => [
22
+ renderSlot(_ctx.$slots, "placeholder")
23
+ ]),
24
+ error: withCtx(() => [
25
+ renderSlot(_ctx.$slots, "error")
26
+ ]),
27
+ _: 3
28
+ }, 16, ["src", "lazy", "preview-src-list", "preview-teleported"]);
29
+ };
30
+ }
31
+ });
32
+ export {
33
+ _sfc_main as default
34
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./ImagePreviewTrigger.vue.mjs";
2
+ export {
3
+ _sfc_main as default
4
+ };