@tmagic/form 1.0.0-rc.8 → 1.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.
@@ -114,7 +114,8 @@ const filterFunction = (mForm, config, props) => {
114
114
  model: props.model,
115
115
  parent: mForm?.parentValues || {},
116
116
  formValue: mForm?.values || props.model,
117
- prop: props.prop
117
+ prop: props.prop,
118
+ config: props.config
118
119
  });
119
120
  };
120
121
  const display = function(mForm, config, props) {
@@ -145,7 +146,8 @@ const getRules = function(mForm, rules = [], props) {
145
146
  model: props.model,
146
147
  parent: mForm?.parentValues || {},
147
148
  formValue: mForm?.values || props.model,
148
- prop: props.prop
149
+ prop: props.prop,
150
+ config: props.config
149
151
  }, mForm);
150
152
  }
151
153
  return item;
@@ -256,7 +258,8 @@ const _sfc_main$t = defineComponent({
256
258
  model: props.model,
257
259
  values: mForm?.initValues,
258
260
  formValue: mForm?.values,
259
- prop: itemProp.value
261
+ prop: itemProp.value,
262
+ config: props.config
260
263
  });
261
264
  }
262
265
  if (filter === "number") {
@@ -270,7 +273,8 @@ const _sfc_main$t = defineComponent({
270
273
  model: props.model,
271
274
  values: mForm?.initValues,
272
275
  formValue: mForm?.values,
273
- prop: itemProp.value
276
+ prop: itemProp.value,
277
+ config: props.config
274
278
  });
275
279
  }
276
280
  };
@@ -316,7 +320,7 @@ const _sfc_main$t = defineComponent({
316
320
  };
317
321
  }
318
322
  });
319
- const _hoisted_1$f = ["innerHTML"];
323
+ const _hoisted_1$e = ["innerHTML"];
320
324
  const _hoisted_2$7 = ["innerHTML"];
321
325
  const _hoisted_3$7 = ["innerHTML"];
322
326
  const _hoisted_4$6 = ["innerHTML"];
@@ -366,7 +370,7 @@ function _sfc_render$q(_ctx, _cache, $props, $setup, $data, $options) {
366
370
  label: withCtx(() => [
367
371
  createElementVNode("span", {
368
372
  innerHTML: _ctx.type === "checkbox" ? "" : _ctx.config.text
369
- }, null, 8, _hoisted_1$f)
373
+ }, null, 8, _hoisted_1$e)
370
374
  ]),
371
375
  default: withCtx(() => [
372
376
  _ctx.tooltip ? (openBlock(), createBlock(_component_el_tooltip, { key: 0 }, {
@@ -505,7 +509,7 @@ const _sfc_main$s = defineComponent({
505
509
  };
506
510
  }
507
511
  });
508
- const _hoisted_1$e = ["innerHTML"];
512
+ const _hoisted_1$d = ["innerHTML"];
509
513
  const _hoisted_2$6 = ["innerHTML"];
510
514
  const _hoisted_3$6 = { key: 1 };
511
515
  const _hoisted_4$5 = ["innerHTML"];
@@ -539,7 +543,7 @@ function _sfc_render$p(_ctx, _cache, $props, $setup, $data, $options) {
539
543
  default: withCtx(() => [
540
544
  createElementVNode("span", {
541
545
  innerHTML: _ctx.config.legend
542
- }, null, 8, _hoisted_1$e),
546
+ }, null, 8, _hoisted_1$d),
543
547
  _ctx.config.extra ? (openBlock(), createElementBlock("span", {
544
548
  key: 0,
545
549
  innerHTML: _ctx.config.extra,
@@ -697,7 +701,7 @@ const _sfc_main$r = defineComponent({
697
701
  };
698
702
  }
699
703
  });
700
- const _hoisted_1$d = { class: "m-fields-group-list-item" };
704
+ const _hoisted_1$c = { class: "m-fields-group-list-item" };
701
705
  const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4E0A\u79FB");
702
706
  const _hoisted_3$5 = /* @__PURE__ */ createTextVNode("\u4E0B\u79FB");
703
707
  const _hoisted_4$4 = ["innerHTML"];
@@ -709,7 +713,7 @@ function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) {
709
713
  const _component_CaretRight = resolveComponent("CaretRight");
710
714
  const _component_CaretBottom = resolveComponent("CaretBottom");
711
715
  const _component_m_form_container = resolveComponent("m-form-container");
712
- return openBlock(), createElementBlock("div", _hoisted_1$d, [
716
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
713
717
  createElementVNode("div", null, [
714
718
  createVNode(_component_el_icon, {
715
719
  style: { "margin-right": "7px" },
@@ -826,7 +830,9 @@ const _sfc_main$q = defineComponent({
826
830
  if (typeof props.config.addable === "function") {
827
831
  return props.config.addable(mForm, {
828
832
  model: props.model[props.name],
829
- formValue: mForm?.values
833
+ formValue: mForm?.values,
834
+ prop: props.prop,
835
+ config: props.config
830
836
  });
831
837
  }
832
838
  return typeof props.config.addable === "undefined" ? true : props.config.addable;
@@ -843,7 +849,9 @@ const _sfc_main$q = defineComponent({
843
849
  if (typeof props.config.defaultAdd === "function") {
844
850
  initValues = await props.config.defaultAdd(mForm, {
845
851
  model: props.model[props.name],
846
- formValue: mForm?.values
852
+ formValue: mForm?.values,
853
+ prop: props.prop,
854
+ config: props.config
847
855
  });
848
856
  } else if (props.config.defaultAdd) {
849
857
  initValues = props.config.defaultAdd;
@@ -886,7 +894,7 @@ const _sfc_main$q = defineComponent({
886
894
  };
887
895
  }
888
896
  });
889
- const _hoisted_1$c = { class: "m-fields-group-list" };
897
+ const _hoisted_1$b = { class: "m-fields-group-list" };
890
898
  const _hoisted_2$4 = ["innerHTML"];
891
899
  const _hoisted_3$4 = {
892
900
  key: 1,
@@ -901,7 +909,7 @@ const _hoisted_7$1 = /* @__PURE__ */ createTextVNode("\u5207\u6362\u4E3A\u8868\u
901
909
  function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) {
902
910
  const _component_m_fields_group_list_item = resolveComponent("m-fields-group-list-item");
903
911
  const _component_el_button = resolveComponent("el-button");
904
- return openBlock(), createElementBlock("div", _hoisted_1$c, [
912
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
905
913
  _ctx.config.extra ? (openBlock(), createElementBlock("div", {
906
914
  key: 0,
907
915
  innerHTML: _ctx.config.extra,
@@ -980,7 +988,7 @@ const _sfc_main$p = defineComponent({
980
988
  };
981
989
  }
982
990
  });
983
- const _hoisted_1$b = { class: "clearfix" };
991
+ const _hoisted_1$a = { class: "clearfix" };
984
992
  const _hoisted_2$3 = ["innerHTML"];
985
993
  const _hoisted_3$3 = {
986
994
  key: 0,
@@ -1000,7 +1008,7 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
1000
1008
  "body-style": { display: _ctx.expand ? "block" : "none" }
1001
1009
  }, {
1002
1010
  header: withCtx(() => [
1003
- createElementVNode("div", _hoisted_1$b, [
1011
+ createElementVNode("div", _hoisted_1$a, [
1004
1012
  createElementVNode("a", {
1005
1013
  href: "javascript:",
1006
1014
  style: { "width": "100%", "display": "block" },
@@ -1486,7 +1494,7 @@ const _sfc_main$l = defineComponent({
1486
1494
  }
1487
1495
  emit("select", selection, row);
1488
1496
  if (typeof props.config.onSelect === "function") {
1489
- props.config.onSelect(mForm, { selection, row });
1497
+ props.config.onSelect(mForm, { selection, row, config: props.config });
1490
1498
  }
1491
1499
  },
1492
1500
  toggleRowSelection(row, selected) {
@@ -1612,7 +1620,7 @@ const _sfc_main$l = defineComponent({
1612
1620
  };
1613
1621
  }
1614
1622
  });
1615
- const _hoisted_1$a = ["innerHTML"];
1623
+ const _hoisted_1$9 = ["innerHTML"];
1616
1624
  const _hoisted_2$2 = { class: "el-form-item__content" };
1617
1625
  const _hoisted_3$2 = ["innerHTML"];
1618
1626
  const _hoisted_4$1 = /* @__PURE__ */ createTextVNode("\u6DFB\u52A0");
@@ -1641,7 +1649,7 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1641
1649
  key: 0,
1642
1650
  style: { "color": "rgba(0, 0, 0, 0.45)" },
1643
1651
  innerHTML: _ctx.config.extra
1644
- }, null, 8, _hoisted_1$a)) : createCommentVNode("", true),
1652
+ }, null, 8, _hoisted_1$9)) : createCommentVNode("", true),
1645
1653
  createElementVNode("div", _hoisted_2$2, [
1646
1654
  createVNode(_component_el_tooltip, {
1647
1655
  content: "\u62D6\u62FD\u53EF\u6392\u5E8F",
@@ -1891,11 +1899,11 @@ const tabClickHandler = (mForm, tab, props) => {
1891
1899
  const { config, model, prop } = props;
1892
1900
  tab.name = tab.paneName;
1893
1901
  if (typeof config.onTabClick === "function") {
1894
- config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
1902
+ config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
1895
1903
  }
1896
1904
  const tabConfig = config.items.find((item) => tab.name === item.status);
1897
1905
  if (tabConfig && typeof tabConfig.onTabClick === "function") {
1898
- tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
1906
+ tabConfig.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop, config });
1899
1907
  }
1900
1908
  };
1901
1909
  const Tab = defineComponent({
@@ -1950,7 +1958,11 @@ const Tab = defineComponent({
1950
1958
  if (!props.config.name)
1951
1959
  throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
1952
1960
  if (typeof props.config.onTabAdd === "function") {
1953
- props.config.onTabAdd(mForm, { model: props.model });
1961
+ props.config.onTabAdd(mForm, {
1962
+ model: props.model,
1963
+ prop: props.prop,
1964
+ config: props.config
1965
+ });
1954
1966
  } else if (tabs.value.length > 0) {
1955
1967
  const newObj = cloneDeep(tabs.value[0]);
1956
1968
  newObj.title = `\u6807\u7B7E${tabs.value.length + 1}`;
@@ -1963,7 +1975,11 @@ const Tab = defineComponent({
1963
1975
  if (!props.config.name)
1964
1976
  throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
1965
1977
  if (typeof props.config.onTabRemove === "function") {
1966
- props.config.onTabRemove(mForm, tabName, { model: props.model });
1978
+ props.config.onTabRemove(mForm, tabName, {
1979
+ model: props.model,
1980
+ prop: props.prop,
1981
+ config: props.config
1982
+ });
1967
1983
  } else {
1968
1984
  props.model[props.config.name].splice(+tabName, 1);
1969
1985
  if (tabName < activeTabName.value || activeTabName.value >= props.model[props.config.name].length) {
@@ -1978,7 +1994,7 @@ const Tab = defineComponent({
1978
1994
  changeHandler: () => {
1979
1995
  emit("change", props.model);
1980
1996
  if (typeof props.config.onChange === "function") {
1981
- props.config.onChange(mForm, { model: props.model });
1997
+ props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
1982
1998
  }
1983
1999
  }
1984
2000
  };
@@ -2167,13 +2183,13 @@ const _sfc_main$j = defineComponent({
2167
2183
  };
2168
2184
  }
2169
2185
  });
2170
- const _hoisted_1$9 = {
2186
+ const _hoisted_1$8 = {
2171
2187
  class: "m-cascader",
2172
2188
  style: { "width": "100%" }
2173
2189
  };
2174
2190
  function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2175
2191
  const _component_el_cascader = resolveComponent("el-cascader");
2176
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
2192
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
2177
2193
  createVNode(_component_el_cascader, {
2178
2194
  modelValue: _ctx.model[_ctx.name],
2179
2195
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
@@ -2296,7 +2312,7 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2296
2312
  }
2297
2313
  var CheckboxGroup = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$e]]);
2298
2314
 
2299
- const _hoisted_1$8 = { key: 0 };
2315
+ const _hoisted_1$7 = { key: 0 };
2300
2316
  const __default__$2 = defineComponent({
2301
2317
  name: "m-fields-color-picker"
2302
2318
  });
@@ -2316,7 +2332,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2316
2332
  const changeHandler = (value) => emit("change", value);
2317
2333
  return (_ctx, _cache) => {
2318
2334
  const _component_el_color_picker = resolveComponent("el-color-picker");
2319
- return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
2335
+ return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
2320
2336
  createVNode(_component_el_color_picker, {
2321
2337
  modelValue: _ctx.model[_ctx.name],
2322
2338
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
@@ -2352,10 +2368,10 @@ const _sfc_main$f = defineComponent({
2352
2368
  };
2353
2369
  }
2354
2370
  });
2355
- const _hoisted_1$7 = { key: 0 };
2371
+ const _hoisted_1$6 = { key: 0 };
2356
2372
  function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2357
2373
  const _component_el_date_picker = resolveComponent("el-date-picker");
2358
- return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
2374
+ return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
2359
2375
  createVNode(_component_el_date_picker, {
2360
2376
  modelValue: _ctx.model[_ctx.modelName],
2361
2377
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.modelName] = $event),
@@ -2422,20 +2438,19 @@ const _sfc_main$e = defineComponent({
2422
2438
  });
2423
2439
  function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2424
2440
  const _component_el_date_picker = resolveComponent("el-date-picker");
2425
- return openBlock(), createElementBlock("div", null, [
2426
- createVNode(_component_el_date_picker, {
2427
- modelValue: _ctx.value,
2428
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
2429
- type: "datetimerange",
2430
- "range-separator": "-",
2431
- "start-placeholder": "\u5F00\u59CB\u65E5\u671F",
2432
- "end-placeholder": "\u7ED3\u675F\u65E5\u671F",
2433
- size: _ctx.size,
2434
- "unlink-panels": true,
2435
- disabled: _ctx.disabled,
2436
- onChange: _ctx.changeHandler
2437
- }, null, 8, ["modelValue", "size", "disabled", "onChange"])
2438
- ]);
2441
+ return openBlock(), createBlock(_component_el_date_picker, {
2442
+ modelValue: _ctx.value,
2443
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
2444
+ type: "datetimerange",
2445
+ "range-separator": "-",
2446
+ "start-placeholder": "\u5F00\u59CB\u65E5\u671F",
2447
+ "end-placeholder": "\u7ED3\u675F\u65E5\u671F",
2448
+ size: _ctx.size,
2449
+ "unlink-panels": true,
2450
+ disabled: _ctx.disabled,
2451
+ "default-time": _ctx.config.defaultTime || [new Date(2e3, 1, 1, 23, 59, 59)],
2452
+ onChange: _ctx.changeHandler
2453
+ }, null, 8, ["modelValue", "size", "disabled", "default-time", "onChange"]);
2439
2454
  }
2440
2455
  var Daterange = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$c]]);
2441
2456
 
@@ -2467,23 +2482,21 @@ const _sfc_main$d = defineComponent({
2467
2482
  };
2468
2483
  }
2469
2484
  });
2470
- const _hoisted_1$6 = { key: 0 };
2471
2485
  function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2472
2486
  const _component_el_date_picker = resolveComponent("el-date-picker");
2473
- return _ctx.model ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
2474
- createVNode(_component_el_date_picker, {
2475
- modelValue: _ctx.model[_ctx.name],
2476
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
2477
- "popper-class": "magic-datetime-picker-popper",
2478
- type: "datetime",
2479
- size: _ctx.size,
2480
- placeholder: _ctx.config.placeholder,
2481
- disabled: _ctx.disabled,
2482
- format: _ctx.config.format || "YYYY-MM-DD HH:mm:ss",
2483
- "value-format": _ctx.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
2484
- onChange: _ctx.changeHandler
2485
- }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "onChange"])
2486
- ])) : createCommentVNode("", true);
2487
+ return openBlock(), createBlock(_component_el_date_picker, {
2488
+ modelValue: _ctx.model[_ctx.name],
2489
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
2490
+ "popper-class": "magic-datetime-picker-popper",
2491
+ type: "datetime",
2492
+ size: _ctx.size,
2493
+ placeholder: _ctx.config.placeholder,
2494
+ disabled: _ctx.disabled,
2495
+ format: _ctx.config.format || "YYYY-MM-DD HH:mm:ss",
2496
+ "value-format": _ctx.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
2497
+ "default-time": _ctx.config.defaultTime || [new Date(2e3, 1, 1, 23, 59, 59)],
2498
+ onChange: _ctx.changeHandler
2499
+ }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "default-time", "onChange"]);
2487
2500
  }
2488
2501
  var DateTime = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$b]]);
2489
2502
 
@@ -2905,7 +2918,8 @@ const _sfc_main$6 = defineComponent({
2905
2918
  body = body(mForm, {
2906
2919
  model: props.model,
2907
2920
  formValue: mForm?.values,
2908
- formValues: mForm?.values
2921
+ formValues: mForm?.values,
2922
+ config: props.config
2909
2923
  });
2910
2924
  }
2911
2925
  body.query = query.value;
@@ -2928,7 +2942,8 @@ const _sfc_main$6 = defineComponent({
2928
2942
  res = option.afterRequest(mForm, res, {
2929
2943
  model: props.model,
2930
2944
  formValue: mForm?.values,
2931
- formValues: mForm?.values
2945
+ formValues: mForm?.values,
2946
+ config: props.config
2932
2947
  });
2933
2948
  }
2934
2949
  const optionsData = res[option.root];
@@ -3020,7 +3035,8 @@ const _sfc_main$6 = defineComponent({
3020
3035
  model: props.model,
3021
3036
  prop: props.prop,
3022
3037
  formValues: mForm?.values,
3023
- formValue: mForm?.values
3038
+ formValue: mForm?.values,
3039
+ config: props.config
3024
3040
  })).then((data) => {
3025
3041
  options.value = data;
3026
3042
  });