@tmagic/form 1.8.0-beta.1 → 1.8.0-beta.2

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.
@@ -1,7 +1,8 @@
1
+ import { FORM_DIFF_CONFIG_KEY } from "./schema.js";
1
2
  import { getConfig } from "./utils/config.js";
2
3
  import { initValue } from "./utils/form.js";
3
4
  import Container_default from "./containers/Container.js";
4
- import { Fragment, createBlock, createCommentVNode, createElementBlock, defineComponent, normalizeStyle, openBlock, provide, reactive, ref, renderList, shallowRef, toRaw, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
5
+ import { Fragment, createBlock, createCommentVNode, createElementBlock, createSlots, defineComponent, mergeProps, normalizeStyle, openBlock, provide, reactive, ref, renderList, renderSlot, shallowRef, toRaw, unref, useTemplateRef, watch, watchEffect, withCtx } from "vue";
5
6
  import { cloneDeep, isEqual } from "lodash-es";
6
7
  import { TMagicForm, tMagicMessage, tMagicMessageBox } from "@tmagic/design";
7
8
  import { setValueByKeyPath } from "@tmagic/utils";
@@ -34,7 +35,9 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
34
35
  keyProp: { default: "__key" },
35
36
  popperClass: {},
36
37
  preventSubmitDefault: { type: Boolean },
37
- extendState: {}
38
+ extendState: {},
39
+ showDiff: {},
40
+ selfDiffFieldTypes: {}
38
41
  },
39
42
  emits: [
40
43
  "change",
@@ -150,6 +153,14 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
150
153
  }
151
154
  });
152
155
  provide("mForm", formState);
156
+ provide(FORM_DIFF_CONFIG_KEY, {
157
+ get showDiff() {
158
+ return props.showDiff;
159
+ },
160
+ get selfDiffFieldTypes() {
161
+ return props.selfDiffFieldTypes;
162
+ }
163
+ });
153
164
  const changeRecords = shallowRef([]);
154
165
  watch([() => props.config, () => props.initValues], ([config], [preConfig]) => {
155
166
  changeRecords.value = [];
@@ -266,7 +277,11 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
266
277
  "step-active": __props.stepActive,
267
278
  size: __props.size,
268
279
  onChange: changeHandler
269
- }, null, 8, [
280
+ }, createSlots({ _: 2 }, [_ctx.$slots.label ? {
281
+ name: "label",
282
+ fn: withCtx((labelProps) => [renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, labelProps))]),
283
+ key: "0"
284
+ } : void 0]), 1032, [
270
285
  "disabled",
271
286
  "config",
272
287
  "model",
@@ -277,7 +292,7 @@ var Form_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
277
292
  "size"
278
293
  ]);
279
294
  }), 128)) : createCommentVNode("v-if", true)]),
280
- _: 1
295
+ _: 3
281
296
  }, 8, [
282
297
  "model",
283
298
  "label-width",
@@ -1,8 +1,9 @@
1
+ import { FORM_DIFF_CONFIG_KEY } from "../schema.js";
1
2
  import Hidden_default from "../fields/Hidden.js";
2
3
  import { getField } from "../utils/config.js";
3
4
  import { createObjectProp, display, filterFunction, getRules } from "../utils/form.js";
4
5
  import FormLabel_default from "./FormLabel.js";
5
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, readonly, ref, renderList, resolveComponent, resolveDynamicComponent, toDisplayString, toRaw, unref, watch, watchEffect, withCtx } from "vue";
6
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, normalizeStyle, openBlock, readonly, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, toRaw, unref, watch, watchEffect, withCtx } from "vue";
6
7
  import { isEqual } from "lodash-es";
7
8
  import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from "@tmagic/design";
8
9
  import { getValueByKeyPath } from "@tmagic/utils";
@@ -15,7 +16,8 @@ var _hoisted_4 = ["innerHTML"];
15
16
  var _hoisted_5 = ["innerHTML"];
16
17
  var _hoisted_6 = ["innerHTML"];
17
18
  var _hoisted_7 = ["innerHTML"];
18
- var _hoisted_8 = {
19
+ var _hoisted_8 = ["innerHTML"];
20
+ var _hoisted_9 = {
19
21
  key: 5,
20
22
  style: { "text-align": "center" }
21
23
  };
@@ -45,11 +47,20 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
45
47
  const props = __props;
46
48
  const emit = __emit;
47
49
  const mForm = inject("mForm");
50
+ const diffConfig = inject(FORM_DIFF_CONFIG_KEY, {});
48
51
  const expand = ref(false);
49
52
  const name = computed(() => props.config.name || "");
50
53
  const showDiff = computed(() => {
51
54
  if (!props.isCompare) return false;
52
- return !isEqual(name.value ? props.model[name.value] : props.model, name.value ? props.lastValues[name.value] : props.lastValues);
55
+ const curValue = name.value ? props.model[name.value] : props.model;
56
+ const lastValue = name.value ? props.lastValues[name.value] : props.lastValues;
57
+ const customShowDiff = diffConfig.showDiff;
58
+ if (typeof customShowDiff === "function") return Boolean(customShowDiff({
59
+ curValue,
60
+ lastValue,
61
+ config: props.config
62
+ }));
63
+ return !isEqual(curValue, lastValue);
53
64
  });
54
65
  const items = computed(() => props.config.items);
55
66
  const itemProp = computed(() => {
@@ -70,6 +81,35 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
70
81
  if (type.value === "component" && props.config.component) return props.config.component;
71
82
  return getField(type.value || "container") || `m-${items.value ? "form" : "fields"}-${type.value}`;
72
83
  });
84
+ /**
85
+ * 自接管对比的字段类型白名单。
86
+ *
87
+ * 这类字段在 `isCompare === true` 且存在差异时,不再由 Container 渲染前后两份独立组件来对比,
88
+ * 而是只渲染一次组件,将 `model` / `lastValues` / `isCompare` 一并传给字段组件,
89
+ * 由字段组件内部自行展示前后差异(典型场景:vs-code 字段使用 monaco 自带的 diff 编辑器)。
90
+ *
91
+ * 这样做的好处:
92
+ * 1. 避免重型字段(如 monaco 编辑器)在对比模式下被实例化两次,节省资源;
93
+ * 2. 提供更专业的对比视觉效果(如 monaco diff 的行级高亮、左右滚动同步等)。
94
+ *
95
+ * 注意:像 `event-select` / `code-select-col` 这类内部由列表 / 嵌套子表单组成的复合字段,若按默认逻辑
96
+ * 渲染前后两份独立组件,会出现两套下拉框 + 两份参数表单(或两套「添加事件」按钮、两份完整面板),
97
+ * 体验很差。这类字段在内部把 `is-compare`/`lastValues` 透传给子级容器,由子级逐项展示差异,
98
+ * 因此同样归类为自接管对比字段。
99
+ */
100
+ const DEFAULT_SELF_DIFF_FIELD_TYPES = [
101
+ "vs-code",
102
+ "event-select",
103
+ "code-select-col",
104
+ "code-select"
105
+ ];
106
+ const effectiveSelfDiffFieldTypes = computed(() => {
107
+ const custom = diffConfig.selfDiffFieldTypes;
108
+ if (typeof custom === "function") return new Set(custom([...DEFAULT_SELF_DIFF_FIELD_TYPES]));
109
+ if (Array.isArray(custom)) return new Set([...DEFAULT_SELF_DIFF_FIELD_TYPES, ...custom]);
110
+ return new Set(DEFAULT_SELF_DIFF_FIELD_TYPES);
111
+ });
112
+ const isSelfDiffField = computed(() => effectiveSelfDiffFieldTypes.value.has(type.value));
73
113
  const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
74
114
  const text = computed(() => filterFunction(mForm, props.config.text, props));
75
115
  const tooltip = computed(() => {
@@ -238,7 +278,13 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
238
278
  "label-width",
239
279
  "style"
240
280
  ])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, { class: { "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value } }), {
241
- label: withCtx(() => [createVNode(FormLabel_default, {
281
+ label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
282
+ config: __props.config,
283
+ type: type.value,
284
+ text: text.value,
285
+ prop: itemProp.value,
286
+ disabled: disabled.value
287
+ }, () => [createVNode(FormLabel_default, {
242
288
  tip: __props.config.tip,
243
289
  type: type.value,
244
290
  "use-label": __props.config.useLabel,
@@ -250,7 +296,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
250
296
  "use-label",
251
297
  "label-title",
252
298
  "text"
253
- ])]),
299
+ ])])]),
254
300
  default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
255
301
  key: 0,
256
302
  placement: tooltip.value.placement
@@ -279,7 +325,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
279
325
  "last-values",
280
326
  "is-compare"
281
327
  ]))]),
282
- _: 1
328
+ _: 3
283
329
  }, 16, ["class"]), __props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
284
330
  key: 0,
285
331
  placement: "top"
@@ -295,12 +341,18 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
295
341
  _: 1
296
342
  })) : createCommentVNode("v-if", true)], 64)) : type.value && display$1.value && showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
297
343
  createCommentVNode(" 对比 "),
298
- createCommentVNode(" 上次内容 "),
299
- createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, { class: {
344
+ createCommentVNode(" 自接管对比的字段类型(如 vs-code):只渲染一次组件,由字段内部用 diff 编辑器/视图自行展示前后差异 "),
345
+ isSelfDiffField.value ? (openBlock(), createBlock(unref(TMagicFormItem), mergeProps({ key: 0 }, formItemProps.value, { class: {
300
346
  "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value,
301
- "show-diff": true
347
+ "self-diff": true
302
348
  } }), {
303
- label: withCtx(() => [createVNode(FormLabel_default, {
349
+ label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
350
+ config: __props.config,
351
+ type: type.value,
352
+ text: text.value,
353
+ prop: itemProp.value,
354
+ disabled: disabled.value
355
+ }, () => [createVNode(FormLabel_default, {
304
356
  tip: __props.config.tip,
305
357
  type: type.value,
306
358
  "use-label": __props.config.useLabel,
@@ -312,88 +364,148 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
312
364
  "use-label",
313
365
  "label-title",
314
366
  "text"
315
- ])]),
367
+ ])])]),
316
368
  default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
317
369
  key: 0,
318
370
  placement: tooltip.value.placement
319
371
  }, {
320
372
  content: withCtx(() => [createElementVNode("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_4)]),
321
373
  default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
322
- model: __props.lastValues,
374
+ model: __props.model,
375
+ "last-values": __props.lastValues,
376
+ "is-compare": __props.isCompare,
323
377
  onChange: onChangeHandler
324
- }), null, 16, ["model"]))]),
378
+ }), null, 16, [
379
+ "model",
380
+ "last-values",
381
+ "is-compare"
382
+ ]))]),
325
383
  _: 1
326
384
  }, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
327
- model: __props.lastValues,
385
+ model: __props.model,
386
+ "last-values": __props.lastValues,
387
+ "is-compare": __props.isCompare,
328
388
  onChange: onChangeHandler
329
- }), null, 16, ["model"]))]),
330
- _: 1
331
- }, 16, ["class"]),
332
- __props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
333
- key: 0,
334
- placement: "top"
335
- }, {
336
- content: withCtx(() => [createElementVNode("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_5)]),
337
- default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
338
- "line-height": "40px",
339
- "margin-left": "5px"
340
- } }, {
341
- default: withCtx(() => [createVNode(unref(WarningFilled))]),
342
- _: 1
343
- })]),
344
- _: 1
345
- })) : createCommentVNode("v-if", true),
346
- createCommentVNode(" 当前内容 "),
347
- createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, {
348
- style: __props.config.tip ? "flex: 1" : "",
349
- class: {
389
+ }), null, 16, [
390
+ "model",
391
+ "last-values",
392
+ "is-compare"
393
+ ]))]),
394
+ _: 3
395
+ }, 16, ["class"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
396
+ createCommentVNode(" 普通字段:渲染前后两份独立的组件用于对比 "),
397
+ createCommentVNode(" 上次内容 "),
398
+ createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, { class: {
350
399
  "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value,
351
- "show-diff": true
352
- }
353
- }), {
354
- label: withCtx(() => [createVNode(FormLabel_default, {
355
- tip: __props.config.tip,
356
- type: type.value,
357
- "use-label": __props.config.useLabel,
358
- "label-title": __props.config.labelTitle,
359
- text: text.value
360
- }, null, 8, [
361
- "tip",
362
- "type",
363
- "use-label",
364
- "label-title",
365
- "text"
366
- ])]),
367
- default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
400
+ "show-before-diff": true
401
+ } }), {
402
+ label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
403
+ config: __props.config,
404
+ type: type.value,
405
+ text: text.value,
406
+ prop: itemProp.value,
407
+ disabled: disabled.value
408
+ }, () => [createVNode(FormLabel_default, {
409
+ tip: __props.config.tip,
410
+ type: type.value,
411
+ "use-label": __props.config.useLabel,
412
+ "label-title": __props.config.labelTitle,
413
+ text: text.value
414
+ }, null, 8, [
415
+ "tip",
416
+ "type",
417
+ "use-label",
418
+ "label-title",
419
+ "text"
420
+ ])])]),
421
+ default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
422
+ key: 0,
423
+ placement: tooltip.value.placement
424
+ }, {
425
+ content: withCtx(() => [createElementVNode("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_5)]),
426
+ default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
427
+ model: __props.lastValues,
428
+ onChange: onChangeHandler
429
+ }), null, 16, ["model"]))]),
430
+ _: 1
431
+ }, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
432
+ model: __props.lastValues,
433
+ onChange: onChangeHandler
434
+ }), null, 16, ["model"]))]),
435
+ _: 3
436
+ }, 16, ["class"]),
437
+ __props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
368
438
  key: 0,
369
- placement: tooltip.value.placement
439
+ placement: "top"
370
440
  }, {
371
- content: withCtx(() => [createElementVNode("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_6)]),
372
- default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
441
+ content: withCtx(() => [createElementVNode("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_6)]),
442
+ default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
443
+ "line-height": "40px",
444
+ "margin-left": "5px"
445
+ } }, {
446
+ default: withCtx(() => [createVNode(unref(WarningFilled))]),
447
+ _: 1
448
+ })]),
449
+ _: 1
450
+ })) : createCommentVNode("v-if", true),
451
+ createCommentVNode(" 当前内容 "),
452
+ createVNode(unref(TMagicFormItem), mergeProps(formItemProps.value, {
453
+ style: __props.config.tip ? "flex: 1" : "",
454
+ class: {
455
+ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value,
456
+ "show-after-diff": true
457
+ }
458
+ }), {
459
+ label: withCtx(() => [renderSlot(_ctx.$slots, "label", {
460
+ config: __props.config,
461
+ type: type.value,
462
+ text: text.value,
463
+ prop: itemProp.value,
464
+ disabled: disabled.value
465
+ }, () => [createVNode(FormLabel_default, {
466
+ tip: __props.config.tip,
467
+ type: type.value,
468
+ "use-label": __props.config.useLabel,
469
+ "label-title": __props.config.labelTitle,
470
+ text: text.value
471
+ }, null, 8, [
472
+ "tip",
473
+ "type",
474
+ "use-label",
475
+ "label-title",
476
+ "text"
477
+ ])])]),
478
+ default: withCtx(() => [tooltip.value.text ? (openBlock(), createBlock(unref(TMagicTooltip), {
479
+ key: 0,
480
+ placement: tooltip.value.placement
481
+ }, {
482
+ content: withCtx(() => [createElementVNode("div", { innerHTML: tooltip.value.text }, null, 8, _hoisted_7)]),
483
+ default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps(fieldsProps.value, {
484
+ model: __props.model,
485
+ onChange: onChangeHandler
486
+ }), null, 16, ["model"]))]),
487
+ _: 1
488
+ }, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
373
489
  model: __props.model,
374
490
  onChange: onChangeHandler
375
491
  }), null, 16, ["model"]))]),
492
+ _: 3
493
+ }, 16, ["style", "class"]),
494
+ __props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
495
+ key: 1,
496
+ placement: "top"
497
+ }, {
498
+ content: withCtx(() => [createElementVNode("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_8)]),
499
+ default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
500
+ "line-height": "40px",
501
+ "margin-left": "5px"
502
+ } }, {
503
+ default: withCtx(() => [createVNode(unref(WarningFilled))]),
504
+ _: 1
505
+ })]),
376
506
  _: 1
377
- }, 8, ["placement"])) : (openBlock(), createBlock(resolveDynamicComponent(tagName.value), mergeProps({ key: 1 }, fieldsProps.value, {
378
- model: __props.model,
379
- onChange: onChangeHandler
380
- }), null, 16, ["model"]))]),
381
- _: 1
382
- }, 16, ["style", "class"]),
383
- __props.config.tip && type.value === "checkbox" && !__props.config.useLabel ? (openBlock(), createBlock(unref(TMagicTooltip), {
384
- key: 1,
385
- placement: "top"
386
- }, {
387
- content: withCtx(() => [createElementVNode("div", { innerHTML: __props.config.tip }, null, 8, _hoisted_7)]),
388
- default: withCtx(() => [createVNode(unref(TMagicIcon), { style: {
389
- "line-height": "40px",
390
- "margin-left": "5px"
391
- } }, {
392
- default: withCtx(() => [createVNode(unref(WarningFilled))]),
393
- _: 1
394
- })]),
395
- _: 1
396
- })) : createCommentVNode("v-if", true)
507
+ })) : createCommentVNode("v-if", true)
508
+ ], 64))
397
509
  ], 64)) : items.value && display$1.value ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [(isValidName() ? __props.model[name.value] : __props.model) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(items.value, (item) => {
398
510
  return openBlock(), createBlock(_component_Container, {
399
511
  key: key(item),
@@ -409,7 +521,11 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
409
521
  prop: itemProp.value,
410
522
  onChange: onChangeHandler,
411
523
  onAddDiffCount
412
- }, null, 8, [
524
+ }, createSlots({ _: 2 }, [_ctx.$slots.label ? {
525
+ name: "label",
526
+ fn: withCtx((labelProps) => [renderSlot(_ctx.$slots, "label", mergeProps({ ref_for: true }, labelProps))]),
527
+ key: "0"
528
+ } : void 0]), 1032, [
413
529
  "model",
414
530
  "last-values",
415
531
  "is-compare",
@@ -421,7 +537,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
421
537
  "label-width",
422
538
  "prop"
423
539
  ]);
424
- }), 128)) : createCommentVNode("v-if", true)], 64)) : createCommentVNode("v-if", true), __props.config.expand && type.value !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_8, [createVNode(unref(TMagicButton), {
540
+ }), 128)) : createCommentVNode("v-if", true)], 64)) : createCommentVNode("v-if", true), __props.config.expand && type.value !== "fieldset" ? (openBlock(), createElementBlock("div", _hoisted_9, [createVNode(unref(TMagicButton), {
425
541
  type: "primary",
426
542
  size: "small",
427
543
  disabled: false,
@@ -8,7 +8,10 @@ var _hoisted_3 = {
8
8
  key: 1,
9
9
  class: "el-table__empty-block"
10
10
  };
11
- var _hoisted_4 = { class: "m-fields-group-list-footer" };
11
+ var _hoisted_4 = {
12
+ key: 3,
13
+ class: "m-fields-group-list-footer"
14
+ };
12
15
  var _hoisted_5 = { style: {
13
16
  "display": "flex",
14
17
  "justify-content": "flex-end",
@@ -91,7 +94,7 @@ var GroupList_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
91
94
  "group-model"
92
95
  ]);
93
96
  }), 128)),
94
- createElementVNode("div", _hoisted_4, [renderSlot(_ctx.$slots, "toggle-button"), createElementVNode("div", _hoisted_5, [renderSlot(_ctx.$slots, "add-button")])])
97
+ !__props.isCompare ? (openBlock(), createElementBlock("div", _hoisted_4, [renderSlot(_ctx.$slots, "toggle-button"), createElementVNode("div", _hoisted_5, [renderSlot(_ctx.$slots, "add-button")])])) : createCommentVNode("v-if", true)
95
98
  ]);
96
99
  };
97
100
  }
@@ -99,16 +99,17 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
99
99
  }), createElementVNode("span", { innerHTML: title.value }, null, 8, _hoisted_1)]),
100
100
  _: 1
101
101
  }, 8, ["disabled"]),
102
- withDirectives(createVNode(unref(TMagicButton), {
102
+ !__props.isCompare ? withDirectives((openBlock(), createBlock(unref(TMagicButton), {
103
+ key: 0,
103
104
  type: "danger",
104
105
  size: "small",
105
106
  link: "",
106
107
  icon: unref(Delete),
107
108
  disabled: __props.disabled,
108
109
  onClick: removeHandler
109
- }, null, 8, ["icon", "disabled"]), [[vShow, showDelete.value]]),
110
- copyable.value ? (openBlock(), createBlock(unref(TMagicButton), {
111
- key: 0,
110
+ }, null, 8, ["icon", "disabled"])), [[vShow, showDelete.value]]) : createCommentVNode("v-if", true),
111
+ copyable.value && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicButton), {
112
+ key: 1,
112
113
  link: "",
113
114
  size: "small",
114
115
  type: "primary",
@@ -119,7 +120,7 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
119
120
  default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("复制", -1)])]),
120
121
  _: 1
121
122
  }, 8, ["icon", "disabled"])) : createCommentVNode("v-if", true),
122
- movable.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [withDirectives(createVNode(unref(TMagicButton), {
123
+ movable.value && !__props.isCompare ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [withDirectives(createVNode(unref(TMagicButton), {
123
124
  link: "",
124
125
  size: "small",
125
126
  disabled: __props.disabled,
@@ -138,8 +139,8 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
138
139
  default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("下移", -1)])]),
139
140
  _: 1
140
141
  }, 8, ["disabled", "icon"]), [[vShow, __props.index !== length.value - 1]])], 64)) : createCommentVNode("v-if", true),
141
- __props.config.moveSpecifyLocation ? (openBlock(), createBlock(unref(TMagicPopover), {
142
- key: 2,
142
+ __props.config.moveSpecifyLocation && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicPopover), {
143
+ key: 3,
143
144
  trigger: "click",
144
145
  placement: "top",
145
146
  width: "200",
@@ -185,7 +186,7 @@ var GroupListItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
185
186
  _: 1
186
187
  }, 8, ["visible"])) : createCommentVNode("v-if", true),
187
188
  itemExtra.value ? (openBlock(), createElementBlock("span", {
188
- key: 3,
189
+ key: 4,
189
190
  innerHTML: itemExtra.value,
190
191
  class: "m-form-tip"
191
192
  }, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)
@@ -1,6 +1,6 @@
1
1
  import { display, filterFunction, initValue } from "../utils/form.js";
2
2
  import Container_default from "./Container.js";
3
- import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, unref, watchEffect, withCtx } from "vue";
3
+ import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, unref, watch, watchEffect, withCtx } from "vue";
4
4
  import { isEmpty } from "lodash-es";
5
5
  import { TMagicBadge, getDesignConfig } from "@tmagic/design";
6
6
  //#region packages/form/src/containers/Tabs.vue?vue&type=script&setup=true&lang.ts
@@ -74,6 +74,9 @@ var Tabs_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
74
74
  prop: props.prop
75
75
  });
76
76
  });
77
+ watch([() => props.model, () => props.lastValues], () => {
78
+ diffCount.value = {};
79
+ });
77
80
  const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
78
81
  const tabClickHandler = (tab) => {
79
82
  if (typeof tab === "object") tabClick(mForm, tab, props);
@@ -148,7 +151,7 @@ var Tabs_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
148
151
  default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(tabs.value, (tab, tabIndex) => {
149
152
  return openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"), mergeProps({ key: tab[unref(mForm)?.keyProp || "__key"] ?? tabIndex }, { ref_for: true }, unref(tabPaneComponent)?.props({
150
153
  name: filter(tab.status) || tabIndex.toString(),
151
- lazy: tab.lazy || false
154
+ lazy: __props.isCompare ? false : tab.lazy || false
152
155
  }) || {}), {
153
156
  label: withCtx(() => [createElementVNode("span", null, [createTextVNode(toDisplayString(filter(tab.title)), 1), createVNode(unref(TMagicBadge), {
154
157
  hidden: !diffCount.value[Number(tabIndex)],
@@ -122,7 +122,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
122
122
  default: withCtx(() => [createTextVNode(toDisplayString(unref(isFullscreen) ? "退出全屏" : "全屏编辑"), 1)]),
123
123
  _: 1
124
124
  }, 8, ["icon", "onClick"])) : createCommentVNode("v-if", true),
125
- unref(importable) ? (openBlock(), createBlock(unref(TMagicUpload), {
125
+ unref(importable) && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicUpload), {
126
126
  key: 2,
127
127
  style: { "display": "inline-block" },
128
128
  ref: "excelBtn",
@@ -142,7 +142,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
142
142
  }, 8, ["disabled"])]),
143
143
  _: 1
144
144
  }, 8, ["disabled", "on-change"])) : createCommentVNode("v-if", true),
145
- unref(importable) ? (openBlock(), createBlock(unref(TMagicButton), {
145
+ unref(importable) && !__props.isCompare ? (openBlock(), createBlock(unref(TMagicButton), {
146
146
  key: 3,
147
147
  size: "small",
148
148
  type: "warning",
@@ -153,7 +153,7 @@ var Table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
153
153
  default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("清空", -1)])]),
154
154
  _: 1
155
155
  }, 8, ["disabled", "onClick"])) : createCommentVNode("v-if", true)
156
- ]), renderSlot(_ctx.$slots, "add-button")]),
156
+ ]), !__props.isCompare ? renderSlot(_ctx.$slots, "add-button", { key: 0 }) : createCommentVNode("v-if", true)]),
157
157
  __props.config.pagination ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(unref(TMagicPagination), {
158
158
  layout: "total, sizes, prev, pager, next, jumper",
159
159
  "hide-on-single-page": __props.model[modelName.value].length < unref(pageSize),
package/dist/es/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import "./_virtual/_rolldown/runtime.js";
2
+ import { FORM_DIFF_CONFIG_KEY } from "./schema.js";
2
3
  import { useAddField } from "./utils/useAddField.js";
3
4
  import Hidden_default from "./fields/Hidden.js";
4
5
  import { deleteField, getField, registerField } from "./utils/config.js";
@@ -38,4 +39,4 @@ import plugin_default from "./plugin.js";
38
39
  export * from "@tmagic/form-schema";
39
40
  var createForm = (config) => config;
40
41
  //#endregion
41
- export { Cascader_default as MCascader, Checkbox_default as MCheckbox, CheckboxGroup_default as MCheckboxGroup, ColorPicker_default as MColorPicker, Container_default as MContainer, Date_default as MDate, DateTime_default as MDateTime, Daterange_default as MDaterange, Display_default as MDisplay, DynamicField_default as MDynamicField, Fieldset_default as MFieldset, FlexLayout_default as MFlexLayout, Form_default as MForm, FormBox_default as MFormBox, FormDialog_default as MFormDialog, FormDrawer_default as MFormDrawer, TableGroupList_default as MGroupList, Hidden_default as MHidden, Link_default as MLink, Number_default as MNumber, NumberRange_default as MNumberRange, Panel_default as MPanel, RadioGroup_default as MRadioGroup, Row_default as MRow, Select_default as MSelect, Switch_default as MSwitch, TableGroupList_default as MTable, TableGroupList_default as MTableGroupList, Tabs_default as MTabs, Text_default as MText, Textarea_default as MTextarea, Time_default as MTime, Timerange_default as MTimerange, createForm, createObjectProp, createValues, datetimeFormatter, plugin_default as default, deleteField as deleteFormField, display, filterFunction, getDataByPage, getField as getFormField, getRules, initValue, registerField as registerFormField, sortArray, sortChange, submitForm, useAddField };
42
+ export { FORM_DIFF_CONFIG_KEY, Cascader_default as MCascader, Checkbox_default as MCheckbox, CheckboxGroup_default as MCheckboxGroup, ColorPicker_default as MColorPicker, Container_default as MContainer, Date_default as MDate, DateTime_default as MDateTime, Daterange_default as MDaterange, Display_default as MDisplay, DynamicField_default as MDynamicField, Fieldset_default as MFieldset, FlexLayout_default as MFlexLayout, Form_default as MForm, FormBox_default as MFormBox, FormDialog_default as MFormDialog, FormDrawer_default as MFormDrawer, TableGroupList_default as MGroupList, Hidden_default as MHidden, Link_default as MLink, Number_default as MNumber, NumberRange_default as MNumberRange, Panel_default as MPanel, RadioGroup_default as MRadioGroup, Row_default as MRow, Select_default as MSelect, Switch_default as MSwitch, TableGroupList_default as MTable, TableGroupList_default as MTableGroupList, Tabs_default as MTabs, Text_default as MText, Textarea_default as MTextarea, Time_default as MTime, Timerange_default as MTimerange, createForm, createObjectProp, createValues, datetimeFormatter, plugin_default as default, deleteField as deleteFormField, display, filterFunction, getDataByPage, getField as getFormField, getRules, initValue, registerField as registerFormField, sortArray, sortChange, submitForm, useAddField };
package/dist/es/schema.js CHANGED
@@ -1,2 +1,6 @@
1
1
  import "./_virtual/_rolldown/runtime.js";
2
2
  export * from "@tmagic/form-schema";
3
+ //#region packages/form/src/schema.ts
4
+ var FORM_DIFF_CONFIG_KEY = Symbol("mFormDiffConfig");
5
+ //#endregion
6
+ export { FORM_DIFF_CONFIG_KEY };
package/dist/es/style.css CHANGED
@@ -10,7 +10,10 @@
10
10
  .m-form-container.has-tip .tmagic-design-form-item {
11
11
  flex: 1;
12
12
  }
13
- .m-form-container .tmagic-design-form-item.show-diff {
13
+ .m-form-container .tmagic-design-form-item.show-after-diff {
14
+ background: rgb(225, 243, 216);
15
+ }
16
+ .m-form-container .tmagic-design-form-item.show-before-diff {
14
17
  background: #f7dadd;
15
18
  }
16
19
 
package/dist/style.css CHANGED
@@ -10,7 +10,10 @@
10
10
  .m-form-container.has-tip .tmagic-design-form-item {
11
11
  flex: 1;
12
12
  }
13
- .m-form-container .tmagic-design-form-item.show-diff {
13
+ .m-form-container .tmagic-design-form-item.show-after-diff {
14
+ background: rgb(225, 243, 216);
15
+ }
16
+ .m-form-container .tmagic-design-form-item.show-before-diff {
14
17
  background: #f7dadd;
15
18
  }
16
19