@tmagic/form 1.1.0-beta.6 → 1.1.0-beta.7

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.
@@ -320,7 +320,7 @@ const _hoisted_5$4 = {
320
320
  key: 4,
321
321
  style: { "text-align": "center" }
322
322
  };
323
- function _sfc_render$p(_ctx, _cache, $props, $setup, $data, $options) {
323
+ function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) {
324
324
  const _component_m_fields_hidden = resolveComponent("m-fields-hidden");
325
325
  const _component_el_tooltip = resolveComponent("el-tooltip");
326
326
  const _component_el_form_item = resolveComponent("el-form-item");
@@ -447,7 +447,7 @@ function _sfc_render$p(_ctx, _cache, $props, $setup, $data, $options) {
447
447
  ])) : createCommentVNode("", true)
448
448
  ], 6)) : createCommentVNode("", true);
449
449
  }
450
- const Container = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["render", _sfc_render$p]]);
450
+ const Container = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["render", _sfc_render$o]]);
451
451
 
452
452
  const _hoisted_1$b = ["innerHTML"];
453
453
  const _hoisted_2$6 = ["innerHTML"];
@@ -662,7 +662,7 @@ const _hoisted_1$a = { class: "m-fields-group-list-item" };
662
662
  const _hoisted_2$5 = /* @__PURE__ */ createTextVNode("\u4E0A\u79FB");
663
663
  const _hoisted_3$5 = /* @__PURE__ */ createTextVNode("\u4E0B\u79FB");
664
664
  const _hoisted_4$4 = ["innerHTML"];
665
- function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) {
665
+ function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) {
666
666
  const _component_CaretBottom = resolveComponent("CaretBottom");
667
667
  const _component_CaretRight = resolveComponent("CaretRight");
668
668
  const _component_el_icon = resolveComponent("el-icon");
@@ -752,7 +752,7 @@ function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) {
752
752
  }, null, 8, ["config", "model", "labelWidth", "prop", "size", "onChange"])) : createCommentVNode("", true)
753
753
  ]);
754
754
  }
755
- const MFieldsGroupListItem = /* @__PURE__ */ _export_sfc(_sfc_main$s, [["render", _sfc_render$o]]);
755
+ const MFieldsGroupListItem = /* @__PURE__ */ _export_sfc(_sfc_main$s, [["render", _sfc_render$n]]);
756
756
 
757
757
  const _sfc_main$r = defineComponent({
758
758
  name: "m-form-group-list",
@@ -863,7 +863,7 @@ const _hoisted_5$2 = [
863
863
  ];
864
864
  const _hoisted_6$1 = /* @__PURE__ */ createTextVNode("\u6DFB\u52A0\u7EC4");
865
865
  const _hoisted_7$1 = /* @__PURE__ */ createTextVNode("\u5207\u6362\u4E3A\u8868\u683C");
866
- function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) {
866
+ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
867
867
  const _component_m_fields_group_list_item = resolveComponent("m-fields-group-list-item");
868
868
  const _component_el_button = resolveComponent("el-button");
869
869
  return openBlock(), createElementBlock("div", _hoisted_1$9, [
@@ -910,7 +910,7 @@ function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) {
910
910
  }, 8, ["onClick"])) : createCommentVNode("", true)
911
911
  ]);
912
912
  }
913
- const GroupList = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["render", _sfc_render$n]]);
913
+ const GroupList = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["render", _sfc_render$m]]);
914
914
 
915
915
  const _sfc_main$q = defineComponent({
916
916
  name: "m-form-panel",
@@ -954,7 +954,7 @@ const _hoisted_3$3 = {
954
954
  };
955
955
  const _hoisted_4$2 = { style: { "flex": "1" } };
956
956
  const _hoisted_5$1 = ["src"];
957
- function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
957
+ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
958
958
  const _component_caret_bottom = resolveComponent("caret-bottom");
959
959
  const _component_caret_right = resolveComponent("caret-right");
960
960
  const _component_el_icon = resolveComponent("el-icon");
@@ -1024,7 +1024,7 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
1024
1024
  _: 3
1025
1025
  }, 8, ["body-style"])) : createCommentVNode("", true);
1026
1026
  }
1027
- const Panel = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["render", _sfc_render$m]]);
1027
+ const Panel = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["render", _sfc_render$l]]);
1028
1028
 
1029
1029
  const _sfc_main$p = defineComponent({
1030
1030
  props: {
@@ -1054,7 +1054,7 @@ const _sfc_main$p = defineComponent({
1054
1054
  }
1055
1055
  });
1056
1056
 
1057
- function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
1057
+ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
1058
1058
  const _component_m_form_container = resolveComponent("m-form-container");
1059
1059
  const _component_el_col = resolveComponent("el-col");
1060
1060
  return withDirectives((openBlock(), createBlock(_component_el_col, { span: _ctx.span }, {
@@ -1074,7 +1074,7 @@ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
1074
1074
  [vShow, _ctx.display && _ctx.config.type !== "hidden"]
1075
1075
  ]);
1076
1076
  }
1077
- const Col = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["render", _sfc_render$l]]);
1077
+ const Col = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["render", _sfc_render$k]]);
1078
1078
 
1079
1079
  const _sfc_main$o = defineComponent({
1080
1080
  name: "m-form-row",
@@ -1105,7 +1105,7 @@ const _sfc_main$o = defineComponent({
1105
1105
  }
1106
1106
  });
1107
1107
 
1108
- function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
1108
+ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
1109
1109
  const _component_Col = resolveComponent("Col");
1110
1110
  const _component_el_row = resolveComponent("el-row");
1111
1111
  return openBlock(), createBlock(_component_el_row, { gutter: 10 }, {
@@ -1127,7 +1127,7 @@ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
1127
1127
  _: 1
1128
1128
  });
1129
1129
  }
1130
- const Row = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$k]]);
1130
+ const Row = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$j]]);
1131
1131
 
1132
1132
  const _sfc_main$n = defineComponent({
1133
1133
  name: "m-form-step",
@@ -1165,7 +1165,7 @@ const _sfc_main$n = defineComponent({
1165
1165
  }
1166
1166
  });
1167
1167
 
1168
- function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
1168
+ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1169
1169
  const _component_el_step = resolveComponent("el-step");
1170
1170
  const _component_el_steps = resolveComponent("el-steps");
1171
1171
  const _component_m_form_container = resolveComponent("m-form-container");
@@ -1208,7 +1208,7 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
1208
1208
  }), 256))
1209
1209
  ]);
1210
1210
  }
1211
- const MStep = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$j]]);
1211
+ const MStep = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$i]]);
1212
1212
 
1213
1213
  let loadedAMapJS = false;
1214
1214
  let firstLoadingAMapJS = true;
@@ -1595,7 +1595,7 @@ const _hoisted_10 = {
1595
1595
  class: "bottom",
1596
1596
  style: { "text-align": "right" }
1597
1597
  };
1598
- function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1598
+ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1599
1599
  const _component_el_table_column = resolveComponent("el-table-column");
1600
1600
  const _component_el_button = resolveComponent("el-button");
1601
1601
  const _component_el_tooltip = resolveComponent("el-tooltip");
@@ -1844,7 +1844,7 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1844
1844
  ])
1845
1845
  ], 2);
1846
1846
  }
1847
- const Table = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$i]]);
1847
+ const Table = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$h]]);
1848
1848
 
1849
1849
  const getActive = (mForm, props, activeTabName) => {
1850
1850
  const { config, model, prop } = props;
@@ -1964,7 +1964,7 @@ const Tab = defineComponent({
1964
1964
  }
1965
1965
  });
1966
1966
 
1967
- function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1967
+ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1968
1968
  const _component_m_form_container = resolveComponent("m-form-container");
1969
1969
  const _component_el_tab_pane = resolveComponent("el-tab-pane");
1970
1970
  const _component_el_tabs = resolveComponent("el-tabs");
@@ -2010,7 +2010,7 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
2010
2010
  _: 1
2011
2011
  }, 8, ["modelValue", "class", "type", "editable", "tab-position", "onTabClick", "onTabAdd", "onTabRemove"]);
2012
2012
  }
2013
- const Tabs = /* @__PURE__ */ _export_sfc(Tab, [["render", _sfc_render$h]]);
2013
+ const Tabs = /* @__PURE__ */ _export_sfc(Tab, [["render", _sfc_render$g]]);
2014
2014
 
2015
2015
  let $MAGIC_FORM = {};
2016
2016
  const setConfig = (option) => {
@@ -2152,7 +2152,7 @@ const _hoisted_1$6 = {
2152
2152
  class: "m-cascader",
2153
2153
  style: { "width": "100%" }
2154
2154
  };
2155
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2155
+ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2156
2156
  const _component_el_cascader = resolveComponent("el-cascader");
2157
2157
  return openBlock(), createElementBlock("div", _hoisted_1$6, [
2158
2158
  createVNode(_component_el_cascader, {
@@ -2171,7 +2171,7 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2171
2171
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "props", "onChange"])
2172
2172
  ]);
2173
2173
  }
2174
- const Cascader = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$g]]);
2174
+ const Cascader = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$f]]);
2175
2175
 
2176
2176
  const _sfc_main$k = defineComponent({
2177
2177
  name: "m-fields-checkbox",
@@ -2213,7 +2213,7 @@ const _sfc_main$k = defineComponent({
2213
2213
  }
2214
2214
  });
2215
2215
 
2216
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2216
+ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2217
2217
  const _component_el_checkbox = resolveComponent("el-checkbox");
2218
2218
  return openBlock(), createBlock(_component_el_checkbox, {
2219
2219
  modelValue: _ctx.model[_ctx.name],
@@ -2226,7 +2226,7 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2226
2226
  onChange: _ctx.changeHandler
2227
2227
  }, null, 8, ["modelValue", "size", "trueLabel", "falseLabel", "disabled", "label", "onChange"]);
2228
2228
  }
2229
- const Checkbox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$f]]);
2229
+ const Checkbox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
2230
2230
 
2231
2231
  const _sfc_main$j = defineComponent({
2232
2232
  name: "m-fields-checkbox-group",
@@ -2251,7 +2251,7 @@ const _sfc_main$j = defineComponent({
2251
2251
  }
2252
2252
  });
2253
2253
 
2254
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2254
+ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2255
2255
  const _component_el_checkbox = resolveComponent("el-checkbox");
2256
2256
  const _component_el_checkbox_group = resolveComponent("el-checkbox-group");
2257
2257
  return openBlock(), createBlock(_component_el_checkbox_group, {
@@ -2277,7 +2277,7 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2277
2277
  _: 1
2278
2278
  }, 8, ["modelValue", "size", "disabled", "onChange"]);
2279
2279
  }
2280
- const CheckboxGroup = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$e]]);
2280
+ const CheckboxGroup = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
2281
2281
 
2282
2282
  const _sfc_main$i = /* @__PURE__ */ defineComponent({
2283
2283
  __name: "ColorPicker",
@@ -2331,7 +2331,7 @@ const _sfc_main$h = defineComponent({
2331
2331
  }
2332
2332
  });
2333
2333
 
2334
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2334
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2335
2335
  const _component_el_date_picker = resolveComponent("el-date-picker");
2336
2336
  return openBlock(), createBlock(_component_el_date_picker, {
2337
2337
  modelValue: _ctx.model[_ctx.name],
@@ -2345,76 +2345,96 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2345
2345
  onChange: _ctx.changeHandler
2346
2346
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "onChange"]);
2347
2347
  }
2348
- const Date$1 = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$d]]);
2348
+ const Date$1 = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$c]]);
2349
2349
 
2350
- const _sfc_main$g = defineComponent({
2351
- name: "m-fields-daterange",
2350
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2351
+ __name: "Daterange",
2352
2352
  props: {
2353
- ...fieldProps,
2354
- config: {
2355
- type: Object,
2356
- required: true
2357
- }
2353
+ config: null,
2354
+ model: null,
2355
+ initValues: null,
2356
+ values: null,
2357
+ name: null,
2358
+ prop: null,
2359
+ disabled: { type: Boolean },
2360
+ size: null
2358
2361
  },
2359
2362
  emits: ["change"],
2360
- setup(props, { emit }) {
2363
+ setup(__props, { emit }) {
2364
+ const props = __props;
2361
2365
  useAddField(props.prop);
2362
2366
  const { names } = props.config;
2363
2367
  const value = ref([]);
2364
2368
  if (props.model !== void 0) {
2365
2369
  if (names?.length) {
2366
- value.value = names.map((item) => datetimeFormatter(props.model?.[item], ""));
2367
- } else if (props.name && props.model[props.name]) {
2368
- value.value = props.model[props.name].map((item) => datetimeFormatter(item, ""));
2369
- }
2370
- }
2371
- const setValue = (v) => {
2372
- if (names?.length && v instanceof Array) {
2373
- names.forEach((item, index) => {
2374
- if (props.model) {
2375
- props.model[item] = datetimeFormatter(v[index].toString(), "");
2370
+ watch([() => props.model[names[0]], () => props.model[names[1]]], ([start, end], [preStart, preEnd]) => {
2371
+ if (!value.value) {
2372
+ value.value = [];
2376
2373
  }
2374
+ if (!start || !end)
2375
+ value.value = [];
2376
+ if (start !== preStart)
2377
+ value.value[0] = new Date(start);
2378
+ if (end !== preEnd)
2379
+ value.value[1] = new Date(end);
2380
+ }, {
2381
+ immediate: true
2377
2382
  });
2378
- } else if (props.model && props.name && v instanceof Date) {
2379
- props.model[props.name] = datetimeFormatter(v.toString(), "");
2380
- } else if (names?.length) {
2381
- names.forEach((item) => {
2382
- if (props.model) {
2383
- props.model[item] = void 0;
2384
- }
2383
+ } else if (props.name && props.model[props.name]) {
2384
+ watch(() => props.model[props.name], (start, preStart) => {
2385
+ if (start !== preStart)
2386
+ value.value = start.map((item) => item ? new Date(item) : void 0);
2387
+ }, {
2388
+ immediate: true
2385
2389
  });
2386
- } else if (props.name) {
2387
- props.model[props.name] = void 0;
2388
2390
  }
2391
+ }
2392
+ const setValue = (v) => {
2393
+ names?.forEach((item, index) => {
2394
+ if (!props.model) {
2395
+ return;
2396
+ }
2397
+ if (Array.isArray(v)) {
2398
+ props.model[item] = datetimeFormatter(v[index]?.toString(), "");
2399
+ } else {
2400
+ props.model[item] = void 0;
2401
+ }
2402
+ });
2389
2403
  };
2390
- return {
2391
- value,
2392
- changeHandler(v) {
2393
- setValue(v);
2394
- emit("change", v);
2404
+ const changeHandler = (v) => {
2405
+ const value2 = v || [];
2406
+ if (props.name) {
2407
+ emit("change", value2.map((item) => {
2408
+ if (item)
2409
+ return datetimeFormatter(item, "");
2410
+ return void 0;
2411
+ }));
2412
+ } else {
2413
+ if (names?.length) {
2414
+ setValue(value2);
2415
+ }
2416
+ emit("change", value2);
2395
2417
  }
2396
2418
  };
2419
+ return (_ctx, _cache) => {
2420
+ const _component_el_date_picker = resolveComponent("el-date-picker");
2421
+ return openBlock(), createBlock(_component_el_date_picker, {
2422
+ modelValue: value.value,
2423
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
2424
+ type: "datetimerange",
2425
+ "range-separator": "-",
2426
+ "start-placeholder": "\u5F00\u59CB\u65E5\u671F",
2427
+ "end-placeholder": "\u7ED3\u675F\u65E5\u671F",
2428
+ size: __props.size,
2429
+ "unlink-panels": true,
2430
+ disabled: __props.disabled,
2431
+ "default-time": __props.config.defaultTime,
2432
+ onChange: changeHandler
2433
+ }, null, 8, ["modelValue", "size", "disabled", "default-time"]);
2434
+ };
2397
2435
  }
2398
2436
  });
2399
2437
 
2400
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2401
- const _component_el_date_picker = resolveComponent("el-date-picker");
2402
- return openBlock(), createBlock(_component_el_date_picker, {
2403
- modelValue: _ctx.value,
2404
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
2405
- type: "datetimerange",
2406
- "range-separator": "-",
2407
- "start-placeholder": "\u5F00\u59CB\u65E5\u671F",
2408
- "end-placeholder": "\u7ED3\u675F\u65E5\u671F",
2409
- size: _ctx.size,
2410
- "unlink-panels": true,
2411
- disabled: _ctx.disabled,
2412
- "default-time": _ctx.config.defaultTime,
2413
- onChange: _ctx.changeHandler
2414
- }, null, 8, ["modelValue", "size", "disabled", "default-time", "onChange"]);
2415
- }
2416
- const Daterange = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$c]]);
2417
-
2418
2438
  const _sfc_main$f = defineComponent({
2419
2439
  name: "m-fields-datetime",
2420
2440
  props: {
@@ -3832,7 +3852,7 @@ const install = (app, opt) => {
3832
3852
  app.component(Time.name, Time);
3833
3853
  app.component(Checkbox.name, Checkbox);
3834
3854
  app.component(Switch.name, Switch);
3835
- app.component(Daterange.name, Daterange);
3855
+ app.component("m-fields-daterange", _sfc_main$g);
3836
3856
  app.component("m-fields-color-picker", _sfc_main$i);
3837
3857
  app.component(CheckboxGroup.name, CheckboxGroup);
3838
3858
  app.component(RadioGroup.name, RadioGroup);
@@ -3846,5 +3866,5 @@ const index = {
3846
3866
  install
3847
3867
  };
3848
3868
 
3849
- export { Cascader as MCascader, Checkbox as MCheckbox, CheckboxGroup as MCheckboxGroup, _sfc_main$i as MColorPicker, Container as MContainer, Date$1 as MDate, DateTime as MDateTime, Daterange as MDaterange, _sfc_main$e as MDisplay, DynamicField as MDynamicField, _sfc_main$t as MFieldset, Form as MForm, FormDialog as MFormDialog, GroupList as MGroupList, _sfc_main$c as MHidden, Link as MLink, Number$1 as MNumber, Panel as MPanel, RadioGroup as MRadioGroup, Row as MRow, Select as MSelect, Switch as MSwitch, Table as MTable, Tabs as MTabs, Text as MText, Textarea as MTextarea, Time as MTime, index as default, display, fieldProps, filterFunction, getRules, initValue, useAddField };
3869
+ export { Cascader as MCascader, Checkbox as MCheckbox, CheckboxGroup as MCheckboxGroup, _sfc_main$i as MColorPicker, Container as MContainer, Date$1 as MDate, DateTime as MDateTime, _sfc_main$g as MDaterange, _sfc_main$e as MDisplay, DynamicField as MDynamicField, _sfc_main$t as MFieldset, Form as MForm, FormDialog as MFormDialog, GroupList as MGroupList, _sfc_main$c as MHidden, Link as MLink, Number$1 as MNumber, Panel as MPanel, RadioGroup as MRadioGroup, Row as MRow, Select as MSelect, Switch as MSwitch, Table as MTable, Tabs as MTabs, Text as MText, Textarea as MTextarea, Time as MTime, index as default, display, fieldProps, filterFunction, getRules, initValue, useAddField };
3850
3870
  //# sourceMappingURL=tmagic-form.mjs.map