@jzg223/design-runtime 0.0.0-stage → 0.0.1

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 (229) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/README.md +275 -2
  3. package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
  4. package/dist/api.js +149 -0
  5. package/dist/comb/design-comb.vue.js +7 -0
  6. package/dist/comb/design-comb2.vue.js +591 -0
  7. package/dist/compat.js +74 -0
  8. package/dist/components/ApiSwitch.vue.js +7 -0
  9. package/dist/components/ApiSwitch2.vue.js +98 -0
  10. package/dist/components/design-debug/dev-mode-toggle.vue.js +7 -0
  11. package/dist/components/design-debug/dev-mode-toggle2.vue.js +41 -0
  12. package/dist/components/design-debug/dev-mode.js +45 -0
  13. package/dist/components/design-debug/dev-state-button.vue.js +7 -0
  14. package/dist/components/design-debug/dev-state-button2.vue.js +447 -0
  15. package/dist/components/design-debug/expr-eval.js +81 -0
  16. package/dist/components/design-shared/host-api.js +47 -0
  17. package/dist/components/design-shared/popup-host.js +11 -0
  18. package/dist/components/design-table/design-table-inner.vue.js +7 -0
  19. package/dist/components/design-table/design-table-inner2.vue.js +39 -0
  20. package/dist/components/design-table/design-table.vue.js +7 -0
  21. package/dist/components/design-table/design-table2.vue.js +937 -0
  22. package/dist/components/design-table/row-actions/delete-action.vue.js +4 -0
  23. package/dist/components/design-table/row-actions/delete-action2.vue.js +42 -0
  24. package/dist/components/design-table/row-actions/edit-action.vue.js +4 -0
  25. package/dist/components/design-table/row-actions/edit-action2.vue.js +145 -0
  26. package/dist/components/design-table/row-actions/index.js +36 -0
  27. package/dist/components/design-table/row-actions/modal-comb-action.vue.js +4 -0
  28. package/dist/components/design-table/row-actions/modal-comb-action2.vue.js +66 -0
  29. package/dist/components/design-table/row-actions/modal-custom-action.vue.js +7 -0
  30. package/dist/components/design-table/row-actions/modal-custom-action2.vue.js +105 -0
  31. package/dist/components/design-table/row-actions/modal-form-action.vue.js +4 -0
  32. package/dist/components/design-table/row-actions/modal-form-action2.vue.js +82 -0
  33. package/dist/components/design-table/row-actions/modal-table-action.vue.js +4 -0
  34. package/dist/components/design-table/row-actions/modal-table-action2.vue.js +67 -0
  35. package/dist/components/design-table/row-actions/modal-tree-action.vue.js +4 -0
  36. package/dist/components/design-table/row-actions/modal-tree-action2.vue.js +70 -0
  37. package/dist/components/design-table/row-actions/navigate-comb-action.vue.js +4 -0
  38. package/dist/components/design-table/row-actions/navigate-comb-action2.vue.js +47 -0
  39. package/dist/components/design-table/row-actions/navigate-form-action.vue.js +4 -0
  40. package/dist/components/design-table/row-actions/navigate-form-action2.vue.js +47 -0
  41. package/dist/components/design-table/row-actions/navigate-table-action.vue.js +4 -0
  42. package/dist/components/design-table/row-actions/navigate-table-action2.vue.js +47 -0
  43. package/dist/components/design-table/row-actions/navigate-tree-action.vue.js +4 -0
  44. package/dist/components/design-table/row-actions/navigate-tree-action2.vue.js +47 -0
  45. package/dist/components/design-table/row-actions/other-action.vue.js +4 -0
  46. package/dist/components/design-table/row-actions/other-action2.vue.js +44 -0
  47. package/dist/components/design-tools/add-tool.vue.js +4 -0
  48. package/dist/components/design-tools/add-tool2.vue.js +136 -0
  49. package/dist/components/design-tools/command-executor.js +135 -0
  50. package/dist/components/design-tools/export-tool.vue.js +4 -0
  51. package/dist/components/design-tools/export-tool2.vue.js +46 -0
  52. package/dist/components/design-tools/import-tool.vue.js +4 -0
  53. package/dist/components/design-tools/import-tool2.vue.js +101 -0
  54. package/dist/components/design-tools/index.js +36 -0
  55. package/dist/components/design-tools/modal-comb-tool.vue.js +4 -0
  56. package/dist/components/design-tools/modal-comb-tool2.vue.js +56 -0
  57. package/dist/components/design-tools/modal-form-tool.vue.js +4 -0
  58. package/dist/components/design-tools/modal-form-tool2.vue.js +66 -0
  59. package/dist/components/design-tools/modal-hcm-tool.vue.js +7 -0
  60. package/dist/components/design-tools/modal-hcm-tool2.vue.js +85 -0
  61. package/dist/components/design-tools/modal-table-tool.vue.js +4 -0
  62. package/dist/components/design-tools/modal-table-tool2.vue.js +54 -0
  63. package/dist/components/design-tools/modal-tree-tool.vue.js +4 -0
  64. package/dist/components/design-tools/modal-tree-tool2.vue.js +57 -0
  65. package/dist/components/design-tools/navigate-comb-tool.vue.js +4 -0
  66. package/dist/components/design-tools/navigate-comb-tool2.vue.js +34 -0
  67. package/dist/components/design-tools/navigate-form-tool.vue.js +4 -0
  68. package/dist/components/design-tools/navigate-form-tool2.vue.js +34 -0
  69. package/dist/components/design-tools/navigate-table-tool.vue.js +4 -0
  70. package/dist/components/design-tools/navigate-table-tool2.vue.js +33 -0
  71. package/dist/components/design-tools/other-tool.vue.js +4 -0
  72. package/dist/components/design-tools/other-tool2.vue.js +34 -0
  73. package/dist/components/flow-status-cell/flow-status-cell.vue.js +7 -0
  74. package/dist/components/flow-status-cell/flow-status-cell2.vue.js +124 -0
  75. package/dist/flow.js +22 -0
  76. package/dist/form/cell-condition.js +122 -0
  77. package/dist/form/derived-express.js +34 -0
  78. package/dist/form/design-form-inner.vue.js +7 -0
  79. package/dist/form/design-form-inner2.vue.js +449 -0
  80. package/dist/form/design-form.vue.js +7 -0
  81. package/dist/form/design-form2.vue.js +681 -0
  82. package/dist/form/fields/checkbox-field.vue.js +88 -0
  83. package/dist/form/fields/checkbox-field2.vue.js +4 -0
  84. package/dist/form/fields/custom-field.vue.js +36 -0
  85. package/dist/form/fields/custom-field2.vue.js +4 -0
  86. package/dist/form/fields/date-field.vue.js +64 -0
  87. package/dist/form/fields/date-field2.vue.js +4 -0
  88. package/dist/form/fields/embedded-list-field.vue.js +7 -0
  89. package/dist/form/fields/embedded-list-field2.vue.js +437 -0
  90. package/dist/form/fields/file-field.vue.js +88 -0
  91. package/dist/form/fields/file-field2.vue.js +4 -0
  92. package/dist/form/fields/image-field.vue.js +90 -0
  93. package/dist/form/fields/image-field2.vue.js +4 -0
  94. package/dist/form/fields/index.js +106 -0
  95. package/dist/form/fields/month-field.vue.js +51 -0
  96. package/dist/form/fields/month-field2.vue.js +4 -0
  97. package/dist/form/fields/org-select-field.vue.js +7 -0
  98. package/dist/form/fields/org-select-field2.vue.js +187 -0
  99. package/dist/form/fields/orgs-select-field.vue.js +182 -0
  100. package/dist/form/fields/orgs-select-field2.vue.js +4 -0
  101. package/dist/form/fields/radio-field.vue.js +91 -0
  102. package/dist/form/fields/radio-field2.vue.js +4 -0
  103. package/dist/form/fields/select-field.vue.js +7 -0
  104. package/dist/form/fields/select-field2.vue.js +317 -0
  105. package/dist/form/fields/splitline-field.vue.js +7 -0
  106. package/dist/form/fields/splitline-field2.vue.js +50 -0
  107. package/dist/form/fields/switch-field.vue.js +32 -0
  108. package/dist/form/fields/switch-field2.vue.js +4 -0
  109. package/dist/form/fields/text-field.vue.js +78 -0
  110. package/dist/form/fields/text-field2.vue.js +4 -0
  111. package/dist/form/fields/time-field.vue.js +50 -0
  112. package/dist/form/fields/time-field2.vue.js +4 -0
  113. package/dist/form/fields/tree-field.vue.js +157 -0
  114. package/dist/form/fields/tree-field2.vue.js +4 -0
  115. package/dist/form/number-precision.js +18 -0
  116. package/dist/form/transformer.js +162 -0
  117. package/dist/host.js +76 -0
  118. package/dist/http.js +19 -0
  119. package/dist/index.js +166 -0
  120. package/dist/mapping.js +44 -0
  121. package/dist/org/dept-api.js +30 -0
  122. package/dist/org/dept-tree-source.js +53 -0
  123. package/dist/org/dept-tree.js +122 -0
  124. package/dist/registry.js +77 -0
  125. package/dist/search/design-search.vue.js +7 -0
  126. package/dist/search/design-search2.vue.js +232 -0
  127. package/dist/search/transformer.js +115 -0
  128. package/dist/style.css +1220 -0
  129. package/dist/table/data.js +18 -0
  130. package/dist/table/load-gate.js +19 -0
  131. package/dist/table/query-body.js +59 -0
  132. package/dist/table/query-dedupe.js +54 -0
  133. package/dist/table/query-search.js +9 -0
  134. package/dist/table/row-action-mapping.js +34 -0
  135. package/dist/table/transformer.js +328 -0
  136. package/dist/tree/design-tree.vue.js +7 -0
  137. package/dist/tree/design-tree2.vue.js +783 -0
  138. package/dist/types/api.d.ts +83 -0
  139. package/dist/types/comb/design-comb.vue.d.ts +38 -0
  140. package/dist/types/compat.d.ts +46 -0
  141. package/dist/types/components/ApiSwitch.vue.d.ts +31 -0
  142. package/dist/types/components/design-debug/dev-mode-toggle.vue.d.ts +2 -0
  143. package/dist/types/components/design-debug/dev-mode.d.ts +8 -0
  144. package/dist/types/components/design-debug/dev-state-button.vue.d.ts +55 -0
  145. package/dist/types/components/design-debug/expr-eval.d.ts +55 -0
  146. package/dist/types/components/design-shared/host-api.d.ts +60 -0
  147. package/dist/types/components/design-shared/popup-host.d.ts +13 -0
  148. package/dist/types/components/design-table/design-table-inner.vue.d.ts +19 -0
  149. package/dist/types/components/design-table/design-table.vue.d.ts +70 -0
  150. package/dist/types/components/design-table/row-actions/delete-action.vue.d.ts +12 -0
  151. package/dist/types/components/design-table/row-actions/edit-action.vue.d.ts +14 -0
  152. package/dist/types/components/design-table/row-actions/index.d.ts +25 -0
  153. package/dist/types/components/design-table/row-actions/modal-comb-action.vue.d.ts +10 -0
  154. package/dist/types/components/design-table/row-actions/modal-custom-action.vue.d.ts +15 -0
  155. package/dist/types/components/design-table/row-actions/modal-form-action.vue.d.ts +10 -0
  156. package/dist/types/components/design-table/row-actions/modal-table-action.vue.d.ts +10 -0
  157. package/dist/types/components/design-table/row-actions/modal-tree-action.vue.d.ts +10 -0
  158. package/dist/types/components/design-table/row-actions/navigate-comb-action.vue.d.ts +10 -0
  159. package/dist/types/components/design-table/row-actions/navigate-form-action.vue.d.ts +10 -0
  160. package/dist/types/components/design-table/row-actions/navigate-table-action.vue.d.ts +10 -0
  161. package/dist/types/components/design-table/row-actions/navigate-tree-action.vue.d.ts +10 -0
  162. package/dist/types/components/design-table/row-actions/other-action.vue.d.ts +14 -0
  163. package/dist/types/components/design-tools/add-tool.vue.d.ts +23 -0
  164. package/dist/types/components/design-tools/command-executor.d.ts +80 -0
  165. package/dist/types/components/design-tools/export-tool.vue.d.ts +9 -0
  166. package/dist/types/components/design-tools/import-tool.vue.d.ts +14 -0
  167. package/dist/types/components/design-tools/index.d.ts +23 -0
  168. package/dist/types/components/design-tools/modal-comb-tool.vue.d.ts +12 -0
  169. package/dist/types/components/design-tools/modal-form-tool.vue.d.ts +12 -0
  170. package/dist/types/components/design-tools/modal-hcm-tool.vue.d.ts +23 -0
  171. package/dist/types/components/design-tools/modal-table-tool.vue.d.ts +12 -0
  172. package/dist/types/components/design-tools/modal-tree-tool.vue.d.ts +12 -0
  173. package/dist/types/components/design-tools/navigate-comb-tool.vue.d.ts +12 -0
  174. package/dist/types/components/design-tools/navigate-form-tool.vue.d.ts +11 -0
  175. package/dist/types/components/design-tools/navigate-table-tool.vue.d.ts +12 -0
  176. package/dist/types/components/design-tools/other-tool.vue.d.ts +16 -0
  177. package/dist/types/components/flow-status-cell/flow-status-cell.vue.d.ts +14 -0
  178. package/dist/types/components/index.d.ts +33 -0
  179. package/dist/types/flow.d.ts +50 -0
  180. package/dist/types/form/cell-condition.d.ts +35 -0
  181. package/dist/types/form/derived-express.d.ts +28 -0
  182. package/dist/types/form/design-form-inner.vue.d.ts +55 -0
  183. package/dist/types/form/design-form.vue.d.ts +96 -0
  184. package/dist/types/form/fields/checkbox-field.vue.d.ts +14 -0
  185. package/dist/types/form/fields/custom-field.vue.d.ts +22 -0
  186. package/dist/types/form/fields/date-field.vue.d.ts +12 -0
  187. package/dist/types/form/fields/embedded-list-field.vue.d.ts +26 -0
  188. package/dist/types/form/fields/file-field.vue.d.ts +12 -0
  189. package/dist/types/form/fields/image-field.vue.d.ts +12 -0
  190. package/dist/types/form/fields/index.d.ts +34 -0
  191. package/dist/types/form/fields/month-field.vue.d.ts +12 -0
  192. package/dist/types/form/fields/org-select-field.vue.d.ts +14 -0
  193. package/dist/types/form/fields/orgs-select-field.vue.d.ts +12 -0
  194. package/dist/types/form/fields/radio-field.vue.d.ts +14 -0
  195. package/dist/types/form/fields/select-field.vue.d.ts +14 -0
  196. package/dist/types/form/fields/splitline-field.vue.d.ts +7 -0
  197. package/dist/types/form/fields/switch-field.vue.d.ts +12 -0
  198. package/dist/types/form/fields/text-field.vue.d.ts +12 -0
  199. package/dist/types/form/fields/time-field.vue.d.ts +12 -0
  200. package/dist/types/form/fields/tree-field.vue.d.ts +12 -0
  201. package/dist/types/form/number-precision.d.ts +15 -0
  202. package/dist/types/form/transformer.d.ts +27 -0
  203. package/dist/types/host.d.ts +182 -0
  204. package/dist/types/http.d.ts +59 -0
  205. package/dist/types/index.d.ts +41 -0
  206. package/dist/types/mapping.d.ts +39 -0
  207. package/dist/types/org/dept-api.d.ts +12 -0
  208. package/dist/types/org/dept-tree-source.d.ts +15 -0
  209. package/dist/types/org/dept-tree.d.ts +62 -0
  210. package/dist/types/registry.d.ts +79 -0
  211. package/dist/types/search/design-search.vue.d.ts +46 -0
  212. package/dist/types/search/transformer.d.ts +36 -0
  213. package/dist/types/table/data.d.ts +30 -0
  214. package/dist/types/table/index.d.ts +20 -0
  215. package/dist/types/table/load-gate.d.ts +24 -0
  216. package/dist/types/table/query-body.d.ts +46 -0
  217. package/dist/types/table/query-dedupe.d.ts +42 -0
  218. package/dist/types/table/query-search.d.ts +21 -0
  219. package/dist/types/table/row-action-mapping.d.ts +36 -0
  220. package/dist/types/table/transformer.d.ts +59 -0
  221. package/dist/types/tree/design-tree.vue.d.ts +33 -0
  222. package/dist/types/types.d.ts +525 -0
  223. package/dist/types/utils/default-value.d.ts +16 -0
  224. package/dist/types/utils/download.d.ts +9 -0
  225. package/dist/types/utils/popup-width.d.ts +21 -0
  226. package/dist/utils/default-value.js +38 -0
  227. package/dist/utils/download.js +19 -0
  228. package/dist/utils/popup-width.js +19 -0
  229. package/package.json +73 -4
@@ -0,0 +1,98 @@
1
+ import { defineComponent, computed, useModel, ref, openBlock, createBlock, unref, mergeProps, mergeModels } from "vue";
2
+ import { Switch } from "antdv-next";
3
+ import { hostT, getDesignHost } from "../host.js";
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "ApiSwitch",
6
+ props: /* @__PURE__ */ mergeModels({
7
+ checkedText: { default: void 0 },
8
+ unCheckedText: { default: void 0 },
9
+ disabled: { type: Boolean },
10
+ api: {},
11
+ confirm: { type: Boolean, default: false },
12
+ confirmText: { type: Function, default: void 0 }
13
+ }, {
14
+ "value": { type: [Boolean, String, Number, Object], ...{
15
+ default: false
16
+ } },
17
+ "valueModifiers": {}
18
+ }),
19
+ emits: /* @__PURE__ */ mergeModels(["reload"], ["update:value"]),
20
+ setup(__props, { emit: __emit }) {
21
+ const props = __props;
22
+ const emit = __emit;
23
+ const checkedTextComputed = computed(
24
+ () => props.checkedText ?? hostT("pages.common.enable", "启用")
25
+ );
26
+ const unCheckedTextComputed = computed(
27
+ () => props.unCheckedText ?? hostT("pages.common.disable", "禁用")
28
+ );
29
+ const currentChecked = useModel(__props, "value");
30
+ const loading = ref(false);
31
+ async function runUpdate(checked) {
32
+ const { api } = props;
33
+ if (typeof api !== "function") return;
34
+ await api(checked);
35
+ emit("reload");
36
+ }
37
+ function confirmUpdate(checked, lastStatus) {
38
+ const content = typeof props.confirmText === "function" ? props.confirmText(checked) : "确认要更新状态吗?";
39
+ const modal = getDesignHost().modal;
40
+ if (!modal) {
41
+ console.warn(
42
+ "[design-platform] 未注入 host.modal,confirm=true 已降级为直接执行;请在 installDesignPlatform({ modal }) 里提供 antd 的 modal 实例"
43
+ );
44
+ void runUpdate(checked);
45
+ return;
46
+ }
47
+ modal.confirm({
48
+ title: "提示",
49
+ content,
50
+ centered: true,
51
+ onOk: async () => {
52
+ try {
53
+ loading.value = true;
54
+ await runUpdate(checked);
55
+ } catch {
56
+ currentChecked.value = lastStatus;
57
+ } finally {
58
+ loading.value = false;
59
+ }
60
+ },
61
+ onCancel: () => {
62
+ currentChecked.value = lastStatus;
63
+ }
64
+ });
65
+ }
66
+ async function handleChange(checked, e) {
67
+ e.stopPropagation();
68
+ const lastStatus = !checked;
69
+ currentChecked.value = checked;
70
+ try {
71
+ loading.value = true;
72
+ if (props.confirm) {
73
+ confirmUpdate(checked, lastStatus);
74
+ return;
75
+ }
76
+ await runUpdate(checked);
77
+ } catch {
78
+ currentChecked.value = lastStatus;
79
+ } finally {
80
+ loading.value = false;
81
+ }
82
+ }
83
+ return (_ctx, _cache) => {
84
+ return openBlock(), createBlock(unref(Switch), mergeProps(_ctx.$attrs, {
85
+ class: "dr-api-switch",
86
+ loading: loading.value,
87
+ disabled: __props.disabled,
88
+ checked: currentChecked.value,
89
+ "checked-children": checkedTextComputed.value,
90
+ "un-checked-children": unCheckedTextComputed.value,
91
+ onChange: handleChange
92
+ }), null, 16, ["loading", "disabled", "checked", "checked-children", "un-checked-children"]);
93
+ };
94
+ }
95
+ });
96
+ export {
97
+ _sfc_main as default
98
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./dev-mode-toggle2.vue.js";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const devModeToggle = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f3f51604"]]);
5
+ export {
6
+ devModeToggle as default
7
+ };
@@ -0,0 +1,41 @@
1
+ import { defineComponent, openBlock, createBlock, unref, withCtx, createElementVNode, normalizeClass, createElementBlock } from "vue";
2
+ import { Tooltip } from "antdv-next";
3
+ import { useDevMode, setDevMode } from "./dev-mode.js";
4
+ const _hoisted_1 = {
5
+ key: 0,
6
+ class: "dev-mode-toggle__label"
7
+ };
8
+ const _hoisted_2 = {
9
+ key: 1,
10
+ class: "dev-mode-toggle__dot"
11
+ };
12
+ const _sfc_main = /* @__PURE__ */ defineComponent({
13
+ ...{ name: "DesignDevModeToggle" },
14
+ __name: "dev-mode-toggle",
15
+ setup(__props) {
16
+ const devMode = useDevMode();
17
+ function toggle() {
18
+ setDevMode(!devMode.value);
19
+ }
20
+ return (_ctx, _cache) => {
21
+ return openBlock(), createBlock(unref(Tooltip), {
22
+ title: unref(devMode) ? "开发模式已开启,点击关闭" : "点击开启开发模式(显示各组件的 🐞 状态按钮与编辑/设计入口)",
23
+ placement: "left"
24
+ }, {
25
+ default: withCtx(() => [
26
+ createElementVNode("button", {
27
+ class: normalizeClass(["dev-mode-toggle", { "dev-mode-toggle--on": unref(devMode) }]),
28
+ type: "button",
29
+ onClick: toggle
30
+ }, [
31
+ unref(devMode) ? (openBlock(), createElementBlock("span", _hoisted_1, "开发")) : (openBlock(), createElementBlock("span", _hoisted_2))
32
+ ], 2)
33
+ ]),
34
+ _: 1
35
+ }, 8, ["title"]);
36
+ };
37
+ }
38
+ });
39
+ export {
40
+ _sfc_main as default
41
+ };
@@ -0,0 +1,45 @@
1
+ import { ref } from "vue";
2
+ const STORAGE_KEY = "design-dev-mode";
3
+ function readUrlDevMode() {
4
+ if (typeof window === "undefined") return null;
5
+ const value = new URLSearchParams(window.location.search).get("dev");
6
+ if (value === "1") return true;
7
+ if (value === "0") return false;
8
+ return null;
9
+ }
10
+ function readStoredDevMode() {
11
+ if (typeof window === "undefined") return false;
12
+ try {
13
+ return window.localStorage.getItem(STORAGE_KEY) === "1";
14
+ } catch {
15
+ return false;
16
+ }
17
+ }
18
+ const devMode = ref(readUrlDevMode() ?? readStoredDevMode());
19
+ function stripUrlDevMode() {
20
+ if (typeof window === "undefined") return;
21
+ const url = new URL(window.location.href);
22
+ if (url.searchParams.has("dev")) {
23
+ url.searchParams.delete("dev");
24
+ window.history.replaceState(null, "", url.toString());
25
+ }
26
+ }
27
+ function setDevMode(on) {
28
+ devMode.value = on;
29
+ try {
30
+ if (on) {
31
+ window.localStorage.setItem(STORAGE_KEY, "1");
32
+ } else {
33
+ window.localStorage.removeItem(STORAGE_KEY);
34
+ stripUrlDevMode();
35
+ }
36
+ } catch {
37
+ }
38
+ }
39
+ function useDevMode() {
40
+ return devMode;
41
+ }
42
+ export {
43
+ setDevMode,
44
+ useDevMode
45
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./dev-state-button2.vue.js";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const DesignDevStateButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d72f4e96"]]);
5
+ export {
6
+ DesignDevStateButton as default
7
+ };
@@ -0,0 +1,447 @@
1
+ import { defineComponent, ref, computed, unref, openBlock, createElementBlock, normalizeStyle, createVNode, withCtx, createTextVNode, createElementVNode, toDisplayString, createCommentVNode, Fragment, renderList, createBlock } from "vue";
2
+ import { Button, Modal, Space, TextArea } from "antdv-next";
3
+ import { fetchDesignUiConfig } from "../../api.js";
4
+ import { buildExprScope, listScopeKeys, evalExpression, scopeKeyTip, appendScopeKey } from "./expr-eval.js";
5
+ import { useDevMode, setDevMode } from "./dev-mode.js";
6
+ import { platformMessage } from "../design-shared/host-api.js";
7
+ const _hoisted_1 = {
8
+ key: 0,
9
+ class: "dev-state-button__designer"
10
+ };
11
+ const _hoisted_2 = { class: "dev-state-button__designer-label" };
12
+ const _hoisted_3 = { class: "dev-state-button__toolbar" };
13
+ const _hoisted_4 = { class: "dev-state-button__tabs" };
14
+ const _hoisted_5 = {
15
+ key: 1,
16
+ class: "dev-state-button__expr"
17
+ };
18
+ const _hoisted_6 = { class: "dev-state-button__expr-input" };
19
+ const _hoisted_7 = {
20
+ key: 0,
21
+ class: "dev-state-button__scope-switch"
22
+ };
23
+ const _hoisted_8 = { class: "dev-state-button__expr-hint" };
24
+ const _hoisted_9 = { class: "dev-state-button__scope" };
25
+ const _hoisted_10 = { class: "dev-state-button__scope-label" };
26
+ const _hoisted_11 = {
27
+ key: 0,
28
+ class: "dev-state-button__scope-empty"
29
+ };
30
+ const _hoisted_12 = {
31
+ key: 1,
32
+ class: "dev-state-button__expr-empty"
33
+ };
34
+ const _hoisted_13 = {
35
+ key: 2,
36
+ class: "dev-state-button__expr-error"
37
+ };
38
+ const _hoisted_14 = { class: "dev-state-button__pre" };
39
+ const _hoisted_15 = {
40
+ key: 3,
41
+ class: "dev-state-button__content"
42
+ };
43
+ const _hoisted_16 = { class: "dev-state-button__head" };
44
+ const _hoisted_17 = { class: "dev-state-button__label" };
45
+ const _hoisted_18 = { class: "dev-state-button__type" };
46
+ const _hoisted_19 = {
47
+ key: 0,
48
+ class: "dev-state-button__warn"
49
+ };
50
+ const _hoisted_20 = { class: "dev-state-button__pre" };
51
+ const _hoisted_21 = {
52
+ key: 0,
53
+ class: "dev-state-button__content"
54
+ };
55
+ const _hoisted_22 = { class: "dev-state-button__head" };
56
+ const _hoisted_23 = { class: "dev-state-button__label" };
57
+ const _hoisted_24 = { class: "dev-state-button__pre" };
58
+ const _hoisted_25 = {
59
+ key: 1,
60
+ class: "dev-state-button__empty"
61
+ };
62
+ const EXPR_TAB_KEY = "__expr__";
63
+ const _sfc_main = /* @__PURE__ */ defineComponent({
64
+ ...{ name: "DesignDevStateButton" },
65
+ __name: "dev-state-button",
66
+ props: {
67
+ title: {},
68
+ state: {},
69
+ designerType: {},
70
+ designerCategory: {},
71
+ designerName: {},
72
+ exprScope: {},
73
+ exprScopeExtra: {},
74
+ exprScopeLabels: {},
75
+ top: { default: 10 }
76
+ },
77
+ setup(__props) {
78
+ const props = __props;
79
+ const devMode = useDevMode();
80
+ const open = ref(false);
81
+ const showDesignerActions = computed(
82
+ () => devMode.value && !!props.designerType && !!props.designerCategory && !!props.designerName
83
+ );
84
+ async function resolveDesignUiBaseUrl() {
85
+ var _a;
86
+ try {
87
+ const res = await fetchDesignUiConfig();
88
+ const url = (_a = res == null ? void 0 : res.uiUrl) == null ? void 0 : _a.trim();
89
+ if (url) return url;
90
+ } catch (err) {
91
+ console.warn(
92
+ "[design-debug] 获取构建端地址失败,回退环境变量/默认值:",
93
+ (err == null ? void 0 : err.message) ?? err
94
+ );
95
+ }
96
+ return "http://localhost:4000";
97
+ }
98
+ async function openDesigner(action) {
99
+ if (!props.designerType || !props.designerCategory || !props.designerName) return;
100
+ const params = new URLSearchParams({
101
+ type: props.designerType,
102
+ name: `${props.designerCategory}/${props.designerName}`,
103
+ action
104
+ });
105
+ const base = (await resolveDesignUiBaseUrl()).replace(/\/+$/, "");
106
+ window.open(`${base}/index.html?${params.toString()}`, "_blank");
107
+ }
108
+ const activeKey = ref(EXPR_TAB_KEY);
109
+ const isExprTab = computed(() => activeKey.value === EXPR_TAB_KEY);
110
+ const activeSection = computed(
111
+ () => sections.value.find((s) => s.key === activeKey.value) ?? sections.value[0] ?? null
112
+ );
113
+ const sections = computed(
114
+ () => Object.entries(props.state ?? {}).map(([key, value]) => {
115
+ let json;
116
+ try {
117
+ const raw = JSON.stringify(value, null, 2);
118
+ json = raw === void 0 ? String(value) : raw;
119
+ } catch (err) {
120
+ json = `[序列化失败] ${(err == null ? void 0 : err.message) ?? err}`;
121
+ }
122
+ return { key, label: key, json };
123
+ })
124
+ );
125
+ async function copyText(text, tip) {
126
+ try {
127
+ await navigator.clipboard.writeText(text);
128
+ platformMessage().success(tip);
129
+ } catch {
130
+ platformMessage().error("复制失败(浏览器可能未授权剪贴板)");
131
+ }
132
+ }
133
+ function copySection(section) {
134
+ return copyText(section.json, `已复制 ${section.label}`);
135
+ }
136
+ function copyAll() {
137
+ const all = sections.value.map((s) => `### ${s.label}
138
+ ${s.json}`).join("\n\n");
139
+ return copyText(all, "已复制全部状态");
140
+ }
141
+ function handleCloseDevMode() {
142
+ setDevMode(false);
143
+ open.value = false;
144
+ }
145
+ const expression = ref("");
146
+ const exprScope = computed(
147
+ () => buildExprScope(props.state, props.exprScope)
148
+ );
149
+ const exprScopeSource = ref("mapping");
150
+ const hasExtraScope = computed(() => !!props.exprScopeExtra);
151
+ const activeScope = computed(
152
+ () => exprScopeSource.value === "extra" && props.exprScopeExtra ? props.exprScopeExtra.scope : exprScope.value
153
+ );
154
+ const activeScopeLabels = computed(
155
+ () => exprScopeSource.value === "extra" ? null : props.exprScopeLabels
156
+ );
157
+ const activeScopeLabelText = computed(
158
+ () => exprScopeSource.value === "extra" && props.exprScopeExtra ? `可用作用域(${props.exprScopeExtra.label}):` : "可用作用域:"
159
+ );
160
+ const activeScopeHint = computed(
161
+ () => {
162
+ var _a;
163
+ return exprScopeSource.value === "extra" ? ((_a = props.exprScopeExtra) == null ? void 0 : _a.hint) ?? "" : "";
164
+ }
165
+ );
166
+ const scopeKeys = computed(() => listScopeKeys(activeScope.value));
167
+ const exprResult = computed(
168
+ () => open.value ? evalExpression(expression.value, activeScope.value) : null
169
+ );
170
+ function insertScopeKey(key) {
171
+ expression.value = appendScopeKey(expression.value, key);
172
+ }
173
+ function clearExpression() {
174
+ expression.value = "";
175
+ }
176
+ function copyExprResult() {
177
+ const result = exprResult.value;
178
+ if (result == null ? void 0 : result.ok) return copyText(result.text, "已复制计算结果");
179
+ }
180
+ return (_ctx, _cache) => {
181
+ return unref(devMode) ? (openBlock(), createElementBlock("div", {
182
+ key: 0,
183
+ class: "dev-state-button",
184
+ style: normalizeStyle({ top: `${__props.top}px` })
185
+ }, [
186
+ createVNode(unref(Button), {
187
+ class: "dev-state-button__fab",
188
+ type: "primary",
189
+ shape: "circle",
190
+ size: "small",
191
+ title: `${__props.title} · 查看组件状态(开发模式)`,
192
+ onClick: _cache[0] || (_cache[0] = ($event) => open.value = true)
193
+ }, {
194
+ default: withCtx(() => [..._cache[9] || (_cache[9] = [
195
+ createTextVNode(" 🐞 ", -1)
196
+ ])]),
197
+ _: 1
198
+ }, 8, ["title"]),
199
+ createVNode(unref(Modal), {
200
+ open: open.value,
201
+ title: `${__props.title} · 组件状态`,
202
+ width: 1e3,
203
+ footer: null,
204
+ onCancel: _cache[8] || (_cache[8] = ($event) => open.value = false)
205
+ }, {
206
+ default: withCtx(() => {
207
+ var _a;
208
+ return [
209
+ showDesignerActions.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
210
+ createElementVNode("span", _hoisted_2, [
211
+ _cache[10] || (_cache[10] = createTextVNode(" 设计器快捷入口:", -1)),
212
+ createElementVNode("code", null, toDisplayString(__props.designerCategory) + "/" + toDisplayString(__props.designerName), 1),
213
+ createTextVNode("(" + toDisplayString(__props.designerType) + ") ", 1)
214
+ ]),
215
+ createVNode(unref(Space), null, {
216
+ default: withCtx(() => [
217
+ createVNode(unref(Button), {
218
+ size: "small",
219
+ title: `在 design-ui 中编辑 ${__props.designerType} 配置`,
220
+ onClick: _cache[1] || (_cache[1] = ($event) => openDesigner("edit"))
221
+ }, {
222
+ default: withCtx(() => [..._cache[11] || (_cache[11] = [
223
+ createTextVNode(" 编辑 ", -1)
224
+ ])]),
225
+ _: 1
226
+ }, 8, ["title"]),
227
+ createVNode(unref(Button), {
228
+ size: "small",
229
+ type: "primary",
230
+ title: `在 design-ui 中设计 ${__props.designerType} 配置`,
231
+ onClick: _cache[2] || (_cache[2] = ($event) => openDesigner("design"))
232
+ }, {
233
+ default: withCtx(() => [..._cache[12] || (_cache[12] = [
234
+ createTextVNode(" 设计 ", -1)
235
+ ])]),
236
+ _: 1
237
+ }, 8, ["title"])
238
+ ]),
239
+ _: 1
240
+ })
241
+ ])) : createCommentVNode("", true),
242
+ createElementVNode("div", _hoisted_3, [
243
+ _cache[15] || (_cache[15] = createElementVNode("span", { class: "dev-state-button__tip" }, "开发模式 · 实时状态(打开弹窗期间数据持续刷新)", -1)),
244
+ createVNode(unref(Space), null, {
245
+ default: withCtx(() => [
246
+ createVNode(unref(Button), {
247
+ size: "small",
248
+ onClick: copyAll
249
+ }, {
250
+ default: withCtx(() => [..._cache[13] || (_cache[13] = [
251
+ createTextVNode("复制全部", -1)
252
+ ])]),
253
+ _: 1
254
+ }),
255
+ createVNode(unref(Button), {
256
+ size: "small",
257
+ danger: "",
258
+ type: "text",
259
+ onClick: handleCloseDevMode
260
+ }, {
261
+ default: withCtx(() => [..._cache[14] || (_cache[14] = [
262
+ createTextVNode(" 关闭开发模式 ", -1)
263
+ ])]),
264
+ _: 1
265
+ })
266
+ ]),
267
+ _: 1
268
+ })
269
+ ]),
270
+ createElementVNode("div", _hoisted_4, [
271
+ createVNode(unref(Button), {
272
+ size: "small",
273
+ type: isExprTab.value ? "primary" : "default",
274
+ title: "输入表达式实时求值(与构建端字段映射表达式同语义)",
275
+ onClick: _cache[3] || (_cache[3] = ($event) => activeKey.value = EXPR_TAB_KEY)
276
+ }, {
277
+ default: withCtx(() => [..._cache[16] || (_cache[16] = [
278
+ createTextVNode(" 🧮 表达式计算 ", -1)
279
+ ])]),
280
+ _: 1
281
+ }, 8, ["type"]),
282
+ (openBlock(true), createElementBlock(Fragment, null, renderList(sections.value, (s) => {
283
+ var _a2;
284
+ return openBlock(), createBlock(unref(Button), {
285
+ key: s.key,
286
+ size: "small",
287
+ type: ((_a2 = activeSection.value) == null ? void 0 : _a2.key) === s.key && !isExprTab.value ? "primary" : "default",
288
+ onClick: ($event) => activeKey.value = s.key
289
+ }, {
290
+ default: withCtx(() => [
291
+ createTextVNode(toDisplayString(s.label), 1)
292
+ ]),
293
+ _: 2
294
+ }, 1032, ["type", "onClick"]);
295
+ }), 128))
296
+ ]),
297
+ isExprTab.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
298
+ createElementVNode("div", _hoisted_6, [
299
+ createVNode(unref(TextArea), {
300
+ value: expression.value,
301
+ "onUpdate:value": _cache[4] || (_cache[4] = ($event) => expression.value = $event),
302
+ rows: 2,
303
+ spellcheck: false,
304
+ placeholder: "输入表达式,实时求值。例如:params.pid",
305
+ class: "dev-state-button__expr-textarea"
306
+ }, null, 8, ["value"]),
307
+ createVNode(unref(Space), null, {
308
+ default: withCtx(() => {
309
+ var _a2;
310
+ return [
311
+ createVNode(unref(Button), {
312
+ size: "small",
313
+ disabled: !expression.value,
314
+ onClick: clearExpression
315
+ }, {
316
+ default: withCtx(() => [..._cache[17] || (_cache[17] = [
317
+ createTextVNode(" 清空 ", -1)
318
+ ])]),
319
+ _: 1
320
+ }, 8, ["disabled"]),
321
+ createVNode(unref(Button), {
322
+ size: "small",
323
+ disabled: !((_a2 = exprResult.value) == null ? void 0 : _a2.ok),
324
+ onClick: copyExprResult
325
+ }, {
326
+ default: withCtx(() => [..._cache[18] || (_cache[18] = [
327
+ createTextVNode(" 复制结果 ", -1)
328
+ ])]),
329
+ _: 1
330
+ }, 8, ["disabled"])
331
+ ];
332
+ }),
333
+ _: 1
334
+ })
335
+ ]),
336
+ hasExtraScope.value ? (openBlock(), createElementBlock("div", _hoisted_7, [
337
+ _cache[20] || (_cache[20] = createElementVNode("span", { class: "dev-state-button__scope-switch-label" }, "求值作用域:", -1)),
338
+ createVNode(unref(Button), {
339
+ size: "small",
340
+ type: exprScopeSource.value === "mapping" ? "primary" : "default",
341
+ title: "本组件「字段映射」表达式的真实作用域",
342
+ onClick: _cache[5] || (_cache[5] = ($event) => exprScopeSource.value = "mapping")
343
+ }, {
344
+ default: withCtx(() => [..._cache[19] || (_cache[19] = [
345
+ createTextVNode(" 映射作用域 ", -1)
346
+ ])]),
347
+ _: 1
348
+ }, 8, ["type"]),
349
+ createVNode(unref(Button), {
350
+ size: "small",
351
+ type: exprScopeSource.value === "extra" ? "primary" : "default",
352
+ title: (_a = __props.exprScopeExtra) == null ? void 0 : _a.hint,
353
+ onClick: _cache[6] || (_cache[6] = ($event) => exprScopeSource.value = "extra")
354
+ }, {
355
+ default: withCtx(() => {
356
+ var _a2;
357
+ return [
358
+ createTextVNode(toDisplayString((_a2 = __props.exprScopeExtra) == null ? void 0 : _a2.label), 1)
359
+ ];
360
+ }),
361
+ _: 1
362
+ }, 8, ["type", "title"])
363
+ ])) : createCommentVNode("", true),
364
+ createElementVNode("div", _hoisted_8, [
365
+ exprScopeSource.value === "extra" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
366
+ createTextVNode(toDisplayString(activeScopeHint.value || "当前作用域=该组件「非映射」表达式的真实可用变量,与字段映射作用域不同,不要混用。"), 1)
367
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
368
+ _cache[21] || (_cache[21] = createTextVNode(" 作用域 = ", -1)),
369
+ _cache[22] || (_cache[22] = createElementVNode("strong", null, "本组件", -1)),
370
+ _cache[23] || (_cache[23] = createTextVNode("「字段映射」表达式的真实可用变量(各组件不同,见下方 可用作用域),求值与映射", -1)),
371
+ _cache[24] || (_cache[24] = createElementVNode("strong", null, "同源", -1)),
372
+ _cache[25] || (_cache[25] = createTextVNode("。结果随状态实时刷新。 ", -1))
373
+ ], 64))
374
+ ]),
375
+ createElementVNode("div", _hoisted_9, [
376
+ createElementVNode("span", _hoisted_10, toDisplayString(activeScopeLabelText.value), 1),
377
+ (openBlock(true), createElementBlock(Fragment, null, renderList(scopeKeys.value, (key) => {
378
+ return openBlock(), createBlock(unref(Button), {
379
+ key,
380
+ size: "small",
381
+ type: "link",
382
+ class: "dev-state-button__scope-chip",
383
+ title: unref(scopeKeyTip)(key, activeScope.value[key], activeScopeLabels.value),
384
+ onClick: ($event) => insertScopeKey(key)
385
+ }, {
386
+ default: withCtx(() => [
387
+ createTextVNode(toDisplayString(key), 1)
388
+ ]),
389
+ _: 2
390
+ }, 1032, ["title", "onClick"]);
391
+ }), 128)),
392
+ scopeKeys.value.length === 0 ? (openBlock(), createElementBlock("span", _hoisted_11, " (该组件未接线表达式作用域) ")) : createCommentVNode("", true)
393
+ ]),
394
+ !expression.value.trim() ? (openBlock(), createElementBlock("div", _hoisted_12, " 输入表达式后这里显示计算结果 ")) : exprResult.value && !exprResult.value.ok ? (openBlock(), createElementBlock("div", _hoisted_13, [
395
+ _cache[26] || (_cache[26] = createElementVNode("div", { class: "dev-state-button__head" }, [
396
+ createElementVNode("span", null, "求值失败")
397
+ ], -1)),
398
+ createElementVNode("pre", _hoisted_14, toDisplayString(exprResult.value.error), 1)
399
+ ])) : exprResult.value ? (openBlock(), createElementBlock("div", _hoisted_15, [
400
+ createElementVNode("div", _hoisted_16, [
401
+ createElementVNode("code", _hoisted_17, [
402
+ _cache[27] || (_cache[27] = createTextVNode(" 结果 ", -1)),
403
+ createElementVNode("span", _hoisted_18, toDisplayString(exprResult.value.type), 1),
404
+ exprResult.value.empty ? (openBlock(), createElementBlock("span", _hoisted_19, " 未取到值(undefined / null) ")) : createCommentVNode("", true)
405
+ ]),
406
+ createVNode(unref(Button), {
407
+ size: "small",
408
+ type: "link",
409
+ onClick: copyExprResult
410
+ }, {
411
+ default: withCtx(() => [..._cache[28] || (_cache[28] = [
412
+ createTextVNode("复制", -1)
413
+ ])]),
414
+ _: 1
415
+ })
416
+ ]),
417
+ createElementVNode("pre", _hoisted_20, toDisplayString(exprResult.value.text), 1)
418
+ ])) : createCommentVNode("", true)
419
+ ])) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [
420
+ activeSection.value ? (openBlock(), createElementBlock("div", _hoisted_21, [
421
+ createElementVNode("div", _hoisted_22, [
422
+ createElementVNode("code", _hoisted_23, toDisplayString(activeSection.value.label), 1),
423
+ createVNode(unref(Button), {
424
+ size: "small",
425
+ type: "link",
426
+ onClick: _cache[7] || (_cache[7] = ($event) => copySection(activeSection.value))
427
+ }, {
428
+ default: withCtx(() => [..._cache[29] || (_cache[29] = [
429
+ createTextVNode("复制", -1)
430
+ ])]),
431
+ _: 1
432
+ })
433
+ ]),
434
+ createElementVNode("pre", _hoisted_24, toDisplayString(activeSection.value.json), 1)
435
+ ])) : (openBlock(), createElementBlock("div", _hoisted_25, "暂无状态数据"))
436
+ ], 64))
437
+ ];
438
+ }),
439
+ _: 1
440
+ }, 8, ["open", "title"])
441
+ ], 4)) : createCommentVNode("", true);
442
+ };
443
+ }
444
+ });
445
+ export {
446
+ _sfc_main as default
447
+ };