@tmagic/form 1.7.8-beta.2 → 1.7.8-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,13 +57,13 @@ var FormDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
57
57
  const stepActive = ref(1);
58
58
  const bodyHeight = ref(`${document.body.clientHeight - 194}px`);
59
59
  const stepCount = computed(() => {
60
- const { length } = props.config;
61
- for (let index = 0; index < length; index++) if (props.config[index].type === "step") return props.config[index].items.length;
60
+ if (!Array.isArray(props.config)) return 0;
61
+ for (const item of props.config) if ("type" in item && item.type === "step") return item.items.length;
62
62
  return 0;
63
63
  });
64
64
  const hasStep = computed(() => {
65
- const { length } = props.config;
66
- for (let index = 0; index < length; index++) if (props.config[index].type === "step") return true;
65
+ if (!Array.isArray(props.config)) return false;
66
+ for (const item of props.config) if ("type" in item && item.type === "step") return true;
67
67
  return false;
68
68
  });
69
69
  const closeHandler = () => {
@@ -52,7 +52,7 @@ var Col_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
52
52
  "disabled"
53
53
  ])]),
54
54
  _: 1
55
- }, 8, ["span"])), [[vShow, display$1.value && __props.config.type !== "hidden"]]);
55
+ }, 8, ["span"])), [[vShow, display$1.value && "type" in __props.config && __props.config.type !== "hidden"]]);
56
56
  };
57
57
  }
58
58
  });
@@ -60,7 +60,7 @@ var Container_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
60
60
  return `${n}`;
61
61
  });
62
62
  const type = computed(() => {
63
- let { type } = props.config;
63
+ let type = "type" in props.config ? props.config.type : "";
64
64
  type = type && filterFunction(mForm, type, props);
65
65
  if (type === "form") return "";
66
66
  if (type === "container") return "";
@@ -42,7 +42,8 @@ var setValue = (mForm, value, initValue, item) => {
42
42
  var initValueItem = function(mForm, item, initValue, value) {
43
43
  const { items } = item;
44
44
  const { names } = item;
45
- const { type, name } = item;
45
+ const type = "type" in item ? item.type : "";
46
+ const { name } = item;
46
47
  if (isTableSelect(type) && name) {
47
48
  value[name] = initValue[name] ?? "";
48
49
  return value;
@@ -2655,7 +2655,8 @@
2655
2655
  var initValueItem = function(mForm, item, initValue, value) {
2656
2656
  const { items } = item;
2657
2657
  const { names } = item;
2658
- const { type, name } = item;
2658
+ const type = "type" in item ? item.type : "";
2659
+ const { name } = item;
2659
2660
  if (isTableSelect(type) && name) {
2660
2661
  value[name] = initValue[name] ?? "";
2661
2662
  return value;
@@ -2934,7 +2935,7 @@
2934
2935
  return `${n}`;
2935
2936
  });
2936
2937
  const type = (0, vue.computed)(() => {
2937
- let { type } = props.config;
2938
+ let type = "type" in props.config ? props.config.type : "";
2938
2939
  type = type && filterFunction(mForm, type, props);
2939
2940
  if (type === "form") return "";
2940
2941
  if (type === "container") return "";
@@ -3593,13 +3594,13 @@
3593
3594
  const stepActive = (0, vue.ref)(1);
3594
3595
  const bodyHeight = (0, vue.ref)(`${document.body.clientHeight - 194}px`);
3595
3596
  const stepCount = (0, vue.computed)(() => {
3596
- const { length } = props.config;
3597
- for (let index = 0; index < length; index++) if (props.config[index].type === "step") return props.config[index].items.length;
3597
+ if (!Array.isArray(props.config)) return 0;
3598
+ for (const item of props.config) if ("type" in item && item.type === "step") return item.items.length;
3598
3599
  return 0;
3599
3600
  });
3600
3601
  const hasStep = (0, vue.computed)(() => {
3601
- const { length } = props.config;
3602
- for (let index = 0; index < length; index++) if (props.config[index].type === "step") return true;
3602
+ if (!Array.isArray(props.config)) return false;
3603
+ for (const item of props.config) if ("type" in item && item.type === "step") return true;
3603
3604
  return false;
3604
3605
  });
3605
3606
  const closeHandler = () => {
@@ -4432,7 +4433,7 @@
4432
4433
  "disabled"
4433
4434
  ])]),
4434
4435
  _: 1
4435
- }, 8, ["span"])), [[vue.vShow, display$2.value && __props.config.type !== "hidden"]]);
4436
+ }, 8, ["span"])), [[vue.vShow, display$2.value && "type" in __props.config && __props.config.type !== "hidden"]]);
4436
4437
  };
4437
4438
  }
4438
4439
  });
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.8-beta.2",
2
+ "version": "1.7.8-beta.4",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -52,9 +52,9 @@
52
52
  "peerDependencies": {
53
53
  "vue": "^3.5.24",
54
54
  "typescript": "^5.9.3",
55
- "@tmagic/design": "1.7.8-beta.2",
56
- "@tmagic/utils": "1.7.8-beta.2",
57
- "@tmagic/form-schema": "1.7.8-beta.2"
55
+ "@tmagic/utils": "1.7.8-beta.4",
56
+ "@tmagic/design": "1.7.8-beta.4",
57
+ "@tmagic/form-schema": "1.7.8-beta.4"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "typescript": {
@@ -117,19 +117,25 @@ const stepActive = ref(1);
117
117
  const bodyHeight = ref(`${document.body.clientHeight - 194}px`);
118
118
 
119
119
  const stepCount = computed(() => {
120
- const { length } = props.config;
121
- for (let index = 0; index < length; index++) {
122
- if (props.config[index].type === 'step') {
123
- return (props.config[index] as StepConfig).items.length;
120
+ if (!Array.isArray(props.config)) {
121
+ return 0;
122
+ }
123
+
124
+ for (const item of props.config) {
125
+ if ('type' in item && item.type === 'step') {
126
+ return (item as StepConfig).items.length;
124
127
  }
125
128
  }
126
129
  return 0;
127
130
  });
128
131
 
129
132
  const hasStep = computed(() => {
130
- const { length } = props.config;
131
- for (let index = 0; index < length; index++) {
132
- if (props.config[index].type === 'step') {
133
+ if (!Array.isArray(props.config)) {
134
+ return false;
135
+ }
136
+
137
+ for (const item of props.config) {
138
+ if ('type' in item && item.type === 'step') {
133
139
  return true;
134
140
  }
135
141
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <TMagicCol v-show="display && config.type !== 'hidden'" :span="span">
2
+ <TMagicCol v-show="display && 'type' in config && config.type !== 'hidden'" :span="span">
3
3
  <Container
4
4
  :model="model"
5
5
  :lastValues="lastValues"
@@ -21,7 +21,7 @@ import { computed, inject } from 'vue';
21
21
 
22
22
  import { TMagicCol } from '@tmagic/design';
23
23
 
24
- import type { ChildConfig, ContainerChangeEventData, FormState } from '../schema';
24
+ import type { ContainerChangeEventData, FormItemConfig, FormState } from '../schema';
25
25
  import { display as displayFunction } from '../utils/form';
26
26
 
27
27
  import Container from './Container.vue';
@@ -34,8 +34,8 @@ const props = defineProps<{
34
34
  model: any;
35
35
  lastValues?: any;
36
36
  isCompare?: boolean;
37
- config: ChildConfig;
38
- labelWidth?: string;
37
+ config: FormItemConfig;
38
+ labelWidth?: string | number;
39
39
  expandMore?: boolean;
40
40
  span?: number;
41
41
  size?: string;
@@ -175,10 +175,10 @@ import { getValueByKeyPath } from '@tmagic/utils';
175
175
  import MHidden from '../fields/Hidden.vue';
176
176
  import type {
177
177
  CheckboxConfig,
178
- ChildConfig,
179
178
  ComponentConfig,
180
179
  ContainerChangeEventData,
181
180
  ContainerCommonConfig,
181
+ FormItemConfig,
182
182
  FormState,
183
183
  FormValue,
184
184
  ToolTipConfigType,
@@ -198,10 +198,10 @@ const props = withDefaults(
198
198
  model: FormValue;
199
199
  /** 需对比的值(开启对比模式时传入) */
200
200
  lastValues?: FormValue;
201
- config: ChildConfig;
201
+ config: FormItemConfig;
202
202
  prop?: string;
203
203
  disabled?: boolean;
204
- labelWidth?: string;
204
+ labelWidth?: string | number;
205
205
  expandMore?: boolean;
206
206
  stepActive?: string | number;
207
207
  size?: string;
@@ -253,7 +253,7 @@ const itemProp = computed(() => {
253
253
  });
254
254
 
255
255
  const type = computed((): string => {
256
- let { type } = props.config;
256
+ let type = 'type' in props.config ? props.config.type : '';
257
257
  type = type && filterFunction<string>(mForm, type, props);
258
258
  if (type === 'form') return '';
259
259
  if (type === 'container') return '';
@@ -1,7 +1,7 @@
1
1
  import { computed, inject } from 'vue';
2
2
 
3
3
  import { tMagicMessage } from '@tmagic/design';
4
- import type { FormState } from '@tmagic/form-schema';
4
+ import type { FormConfig, FormState } from '@tmagic/form-schema';
5
5
 
6
6
  import { initValue } from '../utils/form';
7
7
 
@@ -86,7 +86,7 @@ export const useAdd = (
86
86
  }
87
87
 
88
88
  inputs = await initValue(mForm, {
89
- config: columns,
89
+ config: columns as FormConfig,
90
90
  initValues: inputs,
91
91
  });
92
92
  }
@@ -3,7 +3,7 @@ import { WarningFilled } from '@element-plus/icons-vue';
3
3
  import { cloneDeep } from 'lodash-es';
4
4
 
5
5
  import { type TableColumnOptions, TMagicIcon, TMagicTooltip } from '@tmagic/design';
6
- import type { FormState, TableColumnConfig } from '@tmagic/form-schema';
6
+ import type { FormItemConfig, FormState, TableColumnConfig } from '@tmagic/form-schema';
7
7
 
8
8
  import Container from '../containers/Container.vue';
9
9
  import type { ContainerChangeEventData } from '../schema';
@@ -68,7 +68,7 @@ export const useTableColumns = (
68
68
  return `${props.prop}${props.prop ? '.' : ''}${index + 1 + currentPage.value * pageSize.value - 1}`;
69
69
  };
70
70
 
71
- const makeConfig = (config: TableColumnConfig, row: any) => {
71
+ const makeConfig = (config: TableColumnConfig, row: any): TableColumnConfig => {
72
72
  const newConfig = cloneDeep(config);
73
73
  if (typeof config.itemsFunction === 'function') {
74
74
  newConfig.items = config.itemsFunction(row);
@@ -199,7 +199,7 @@ export const useTableColumns = (
199
199
  disabled: props.disabled,
200
200
  prop: getProp($index),
201
201
  rules: column.rules,
202
- config: makeConfig(column, row),
202
+ config: makeConfig(column, row) as FormItemConfig,
203
203
  model: row,
204
204
  lastValues: lastData.value[$index],
205
205
  isCompare: props.isCompare,
package/src/utils/form.ts CHANGED
@@ -23,13 +23,12 @@ import { cloneDeep } from 'lodash-es';
23
23
 
24
24
  import { getValueByKeyPath } from '@tmagic/utils';
25
25
 
26
- import {
26
+ import type {
27
27
  ChildConfig,
28
28
  ContainerCommonConfig,
29
29
  DaterangeConfig,
30
30
  FilterFunction,
31
31
  FormConfig,
32
- FormItem,
33
32
  FormState,
34
33
  FormValue,
35
34
  HtmlField,
@@ -120,7 +119,8 @@ const initValueItem = function (
120
119
  ) {
121
120
  const { items } = item as ContainerCommonConfig;
122
121
  const { names } = item as DaterangeConfig;
123
- const { type, name } = item as FormItem;
122
+ const type = 'type' in item ? item.type : '';
123
+ const { name } = item;
124
124
 
125
125
  if (isTableSelect(type) && name) {
126
126
  value[name] = initValue[name] ?? '';
@@ -172,8 +172,8 @@ export const createValues = function (
172
172
  value: FormValue = {},
173
173
  ) {
174
174
  if (Array.isArray(config)) {
175
- config.forEach((item: ChildConfig | TabPaneConfig) => {
176
- initValueItem(mForm, item, initValue, value);
175
+ config.forEach((item) => {
176
+ initValueItem(mForm, item as ChildConfig | TabPaneConfig, initValue, value);
177
177
  });
178
178
  }
179
179
 
package/types/index.d.ts CHANGED
@@ -95,13 +95,13 @@ declare const __VLS_export$31: _vue_runtime_core0.DefineComponent<__VLS_Props$30
95
95
  inline: boolean;
96
96
  labelPosition: string;
97
97
  config: schema_d_exports.FormConfig;
98
+ height: string;
98
99
  initValues: Record<string, any>;
99
100
  lastValues: Record<string, any>;
100
101
  isCompare: boolean;
101
102
  keyProp: string;
102
103
  parentValues: Record<string, any>;
103
104
  stepActive: string | number;
104
- height: string;
105
105
  }, {}, {}, {}, string, _vue_runtime_core0.ComponentProvideOptions, false, {}, any>;
106
106
  declare const _default$12: typeof __VLS_export$31;
107
107
  //#endregion
@@ -181,13 +181,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
181
181
  inline: boolean;
182
182
  labelPosition: string;
183
183
  config: schema_d_exports.FormConfig;
184
+ height: string;
184
185
  initValues: Record<string, any>;
185
186
  lastValues: Record<string, any>;
186
187
  isCompare: boolean;
187
188
  keyProp: string;
188
189
  parentValues: Record<string, any>;
189
190
  stepActive: string | number;
190
- height: string;
191
191
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
192
192
  P: {};
193
193
  B: {};
@@ -234,13 +234,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
234
234
  inline: boolean;
235
235
  labelPosition: string;
236
236
  config: schema_d_exports.FormConfig;
237
+ height: string;
237
238
  initValues: Record<string, any>;
238
239
  lastValues: Record<string, any>;
239
240
  isCompare: boolean;
240
241
  keyProp: string;
241
242
  parentValues: Record<string, any>;
242
243
  stepActive: string | number;
243
- height: string;
244
244
  }> | undefined, _vue_runtime_core0.CreateComponentPublicInstanceWithMixins<Readonly<{
245
245
  config: schema_d_exports.FormConfig;
246
246
  initValues: Record<string, any>;
@@ -286,13 +286,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
286
286
  inline: boolean;
287
287
  labelPosition: string;
288
288
  config: schema_d_exports.FormConfig;
289
+ height: string;
289
290
  initValues: Record<string, any>;
290
291
  lastValues: Record<string, any>;
291
292
  isCompare: boolean;
292
293
  keyProp: string;
293
294
  parentValues: Record<string, any>;
294
295
  stepActive: string | number;
295
- height: string;
296
296
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
297
297
  P: {};
298
298
  B: {};
@@ -339,13 +339,13 @@ declare const __VLS_base$4: _vue_runtime_core0.DefineComponent<__VLS_Props$29, {
339
339
  inline: boolean;
340
340
  labelPosition: string;
341
341
  config: schema_d_exports.FormConfig;
342
+ height: string;
342
343
  initValues: Record<string, any>;
343
344
  lastValues: Record<string, any>;
344
345
  isCompare: boolean;
345
346
  keyProp: string;
346
347
  parentValues: Record<string, any>;
347
348
  stepActive: string | number;
348
- height: string;
349
349
  }> | undefined>;
350
350
  saveFetch: _vue_reactivity0.Ref<boolean, boolean>;
351
351
  dialogVisible: _vue_reactivity0.Ref<boolean, boolean>;
@@ -453,13 +453,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
453
453
  inline: boolean;
454
454
  labelPosition: string;
455
455
  config: schema_d_exports.FormConfig;
456
+ height: string;
456
457
  initValues: Record<string, any>;
457
458
  lastValues: Record<string, any>;
458
459
  isCompare: boolean;
459
460
  keyProp: string;
460
461
  parentValues: Record<string, any>;
461
462
  stepActive: string | number;
462
- height: string;
463
463
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
464
464
  P: {};
465
465
  B: {};
@@ -506,13 +506,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
506
506
  inline: boolean;
507
507
  labelPosition: string;
508
508
  config: schema_d_exports.FormConfig;
509
+ height: string;
509
510
  initValues: Record<string, any>;
510
511
  lastValues: Record<string, any>;
511
512
  isCompare: boolean;
512
513
  keyProp: string;
513
514
  parentValues: Record<string, any>;
514
515
  stepActive: string | number;
515
- height: string;
516
516
  }> | undefined, _vue_runtime_core0.CreateComponentPublicInstanceWithMixins<Readonly<{
517
517
  config: schema_d_exports.FormConfig;
518
518
  initValues: Record<string, any>;
@@ -558,13 +558,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
558
558
  inline: boolean;
559
559
  labelPosition: string;
560
560
  config: schema_d_exports.FormConfig;
561
+ height: string;
561
562
  initValues: Record<string, any>;
562
563
  lastValues: Record<string, any>;
563
564
  isCompare: boolean;
564
565
  keyProp: string;
565
566
  parentValues: Record<string, any>;
566
567
  stepActive: string | number;
567
- height: string;
568
568
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
569
569
  P: {};
570
570
  B: {};
@@ -611,13 +611,13 @@ declare const __VLS_base$3: _vue_runtime_core0.DefineComponent<__VLS_Props$28, {
611
611
  inline: boolean;
612
612
  labelPosition: string;
613
613
  config: schema_d_exports.FormConfig;
614
+ height: string;
614
615
  initValues: Record<string, any>;
615
616
  lastValues: Record<string, any>;
616
617
  isCompare: boolean;
617
618
  keyProp: string;
618
619
  parentValues: Record<string, any>;
619
620
  stepActive: string | number;
620
- height: string;
621
621
  }> | undefined>;
622
622
  saveFetch: _vue_reactivity0.Ref<boolean, boolean>;
623
623
  bodyHeight: _vue_reactivity0.Ref<number, number>;
@@ -723,13 +723,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
723
723
  inline: boolean;
724
724
  labelPosition: string;
725
725
  config: schema_d_exports.FormConfig;
726
+ height: string;
726
727
  initValues: Record<string, any>;
727
728
  lastValues: Record<string, any>;
728
729
  isCompare: boolean;
729
730
  keyProp: string;
730
731
  parentValues: Record<string, any>;
731
732
  stepActive: string | number;
732
- height: string;
733
733
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
734
734
  P: {};
735
735
  B: {};
@@ -776,13 +776,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
776
776
  inline: boolean;
777
777
  labelPosition: string;
778
778
  config: schema_d_exports.FormConfig;
779
+ height: string;
779
780
  initValues: Record<string, any>;
780
781
  lastValues: Record<string, any>;
781
782
  isCompare: boolean;
782
783
  keyProp: string;
783
784
  parentValues: Record<string, any>;
784
785
  stepActive: string | number;
785
- height: string;
786
786
  }> | undefined, _vue_runtime_core0.CreateComponentPublicInstanceWithMixins<Readonly<{
787
787
  config: schema_d_exports.FormConfig;
788
788
  initValues: Record<string, any>;
@@ -828,13 +828,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
828
828
  inline: boolean;
829
829
  labelPosition: string;
830
830
  config: schema_d_exports.FormConfig;
831
+ height: string;
831
832
  initValues: Record<string, any>;
832
833
  lastValues: Record<string, any>;
833
834
  isCompare: boolean;
834
835
  keyProp: string;
835
836
  parentValues: Record<string, any>;
836
837
  stepActive: string | number;
837
- height: string;
838
838
  }, false, {}, {}, _vue_runtime_core0.GlobalComponents, _vue_runtime_core0.GlobalDirectives, string, {}, any, _vue_runtime_core0.ComponentProvideOptions, {
839
839
  P: {};
840
840
  B: {};
@@ -881,13 +881,13 @@ declare const __VLS_base$2: _vue_runtime_core0.DefineComponent<__VLS_Props$27, {
881
881
  inline: boolean;
882
882
  labelPosition: string;
883
883
  config: schema_d_exports.FormConfig;
884
+ height: string;
884
885
  initValues: Record<string, any>;
885
886
  lastValues: Record<string, any>;
886
887
  isCompare: boolean;
887
888
  keyProp: string;
888
889
  parentValues: Record<string, any>;
889
890
  stepActive: string | number;
890
- height: string;
891
891
  }> | undefined>;
892
892
  saveFetch: _vue_reactivity0.Ref<boolean, boolean>;
893
893
  show: () => void;
@@ -917,10 +917,10 @@ type __VLS_WithSlots$2<T, S> = T & {
917
917
  type __VLS_Props$26 = {
918
918
  /** 表单值 */model: schema_d_exports.FormValue; /** 需对比的值(开启对比模式时传入) */
919
919
  lastValues?: schema_d_exports.FormValue;
920
- config: schema_d_exports.ChildConfig;
920
+ config: schema_d_exports.FormItemConfig;
921
921
  prop?: string;
922
922
  disabled?: boolean;
923
- labelWidth?: string;
923
+ labelWidth?: string | number;
924
924
  expandMore?: boolean;
925
925
  stepActive?: string | number;
926
926
  size?: string; /** 是否开启对比模式 */