@tmagic/form 1.0.0-beta.1 → 1.0.0-beta.10

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 (43) hide show
  1. package/LICENSE +5432 -0
  2. package/dist/style.css +0 -1
  3. package/dist/tmagic-form.es.js +62 -40
  4. package/dist/tmagic-form.es.js.map +1 -1
  5. package/dist/tmagic-form.umd.js +62 -40
  6. package/dist/tmagic-form.umd.js.map +1 -1
  7. package/dist/types/src/containers/Container.vue.d.ts +1 -1
  8. package/dist/types/src/containers/Fieldset.vue.d.ts +1 -1
  9. package/dist/types/src/containers/GroupList.vue.d.ts +1 -1
  10. package/dist/types/src/containers/GroupListItem.vue.d.ts +1 -1
  11. package/dist/types/src/containers/Panel.vue.d.ts +1 -1
  12. package/dist/types/src/containers/Row.vue.d.ts +1 -1
  13. package/dist/types/src/containers/Step.vue.d.ts +1 -1
  14. package/dist/types/src/containers/Tabs.vue.d.ts +2 -2
  15. package/dist/types/src/fields/Checkbox.vue.d.ts +2 -2
  16. package/dist/types/src/fields/CheckboxGroup.vue.d.ts +2 -2
  17. package/dist/types/src/fields/Date.vue.d.ts +2 -2
  18. package/dist/types/src/fields/DateTime.vue.d.ts +2 -2
  19. package/dist/types/src/fields/Daterange.vue.d.ts +2 -2
  20. package/dist/types/src/fields/DynamicField.vue.d.ts +2 -2
  21. package/dist/types/src/fields/Number.vue.d.ts +2 -2
  22. package/dist/types/src/fields/RadioGroup.vue.d.ts +2 -2
  23. package/dist/types/src/fields/Switch.vue.d.ts +2 -2
  24. package/dist/types/src/fields/Text.vue.d.ts +2 -2
  25. package/dist/types/src/fields/Textarea.vue.d.ts +2 -2
  26. package/dist/types/src/fields/Time.vue.d.ts +2 -2
  27. package/dist/types/src/schema.d.ts +2 -0
  28. package/package.json +10 -8
  29. package/src/Form.vue +38 -29
  30. package/src/FormDialog.vue +3 -0
  31. package/src/containers/Container.vue +20 -7
  32. package/src/containers/Table.vue +8 -6
  33. package/src/containers/Tabs.vue +4 -0
  34. package/src/fields/Select.vue +3 -0
  35. package/src/fields/Text.vue +1 -1
  36. package/src/schema.ts +2 -0
  37. package/src/theme/table.scss +0 -1
  38. package/dist/types/src/Form.vue.d.ts +0 -304
  39. package/dist/types/src/FormDialog.vue.d.ts +0 -641
  40. package/dist/types/src/containers/Table.vue.d.ts +0 -1401
  41. package/dist/types/src/fields/Cascader.vue.d.ts +0 -1748
  42. package/dist/types/src/fields/Link.vue.d.ts +0 -1365
  43. package/dist/types/src/fields/Select.vue.d.ts +0 -975
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('lodash-es'), require('@element-plus/icons'), require('element-plus'), require('sortablejs'), require('@tmagic/utils')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'lodash-es', '@element-plus/icons', 'element-plus', 'sortablejs', '@tmagic/utils'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.vue, global.lodashEs, global.icons, global.elementPlus, global.Sortable, global.utils));
5
- })(this, (function (exports, vue, lodashEs, icons, elementPlus, Sortable, utils) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons'), require('lodash-es'), require('element-plus'), require('sortablejs'), require('@tmagic/utils')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons', 'lodash-es', 'element-plus', 'sortablejs', '@tmagic/utils'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.vue, global.icons, global.lodashEs, global.elementPlus, global.Sortable, global.utils));
5
+ })(this, (function (exports, vue, icons, lodashEs, elementPlus, Sortable, utils) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -174,6 +174,7 @@
174
174
 
175
175
  const _sfc_main$s = vue.defineComponent({
176
176
  name: "m-form-container",
177
+ components: { WarningFilled: icons.WarningFilled },
177
178
  props: {
178
179
  labelWidth: String,
179
180
  expandMore: Boolean,
@@ -267,9 +268,14 @@
267
268
  };
268
269
  const onChangeHandler = async function(v, key2) {
269
270
  const { filter, onChange, trim, name: name2, dynamicKey } = props.config;
270
- let value = filterHandler(filter, v);
271
- value = await changeHandler(onChange, value) ?? value;
272
- value = trimHandler(trim, value) ?? value;
271
+ let value = v;
272
+ try {
273
+ value = filterHandler(filter, v);
274
+ value = await changeHandler(onChange, value) ?? value;
275
+ value = trimHandler(trim, value) ?? value;
276
+ } catch (e) {
277
+ console.error(e);
278
+ }
273
279
  if ((name2 || name2 === 0) && props.model !== value && (v !== value || props.model[name2] !== value)) {
274
280
  props.model[name2] = value;
275
281
  }
@@ -299,9 +305,8 @@
299
305
  const _hoisted_1$g = ["innerHTML"];
300
306
  const _hoisted_2$7 = ["innerHTML"];
301
307
  const _hoisted_3$7 = ["innerHTML"];
302
- const _hoisted_4$6 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-warning" }, null, -1);
303
- const _hoisted_5$4 = ["innerHTML"];
304
- const _hoisted_6$3 = {
308
+ const _hoisted_4$6 = ["innerHTML"];
309
+ const _hoisted_5$4 = {
305
310
  key: 4,
306
311
  style: { "text-align": "center" }
307
312
  };
@@ -309,11 +314,13 @@
309
314
  const _component_m_fields_hidden = vue.resolveComponent("m-fields-hidden");
310
315
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
311
316
  const _component_el_form_item = vue.resolveComponent("el-form-item");
317
+ const _component_warning_filled = vue.resolveComponent("warning-filled");
318
+ const _component_el_icon = vue.resolveComponent("el-icon");
312
319
  const _component_m_form_container = vue.resolveComponent("m-form-container");
313
320
  const _component_el_button = vue.resolveComponent("el-button");
314
321
  return _ctx.config ? (vue.openBlock(), vue.createElementBlock("div", {
315
322
  key: 0,
316
- style: vue.normalizeStyle(_ctx.config.tip ? "display: flex" : ""),
323
+ style: vue.normalizeStyle(_ctx.config.tip ? "display: flex;align-items: baseline;" : ""),
317
324
  class: vue.normalizeClass([_ctx.config.className, "m-form-container"])
318
325
  }, [
319
326
  _ctx.type === "hidden" ? (vue.openBlock(), vue.createBlock(_component_m_fields_hidden, {
@@ -384,16 +391,20 @@
384
391
  }, 8, ["style", "prop", "label-width", "rules"]),
385
392
  _ctx.config.tip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
386
393
  key: 0,
387
- placement: "top",
388
- style: { "line-height": "40px", "margin-left": "5px" }
394
+ placement: "top"
389
395
  }, {
390
396
  content: vue.withCtx(() => [
391
397
  vue.createElementVNode("div", {
392
398
  innerHTML: _ctx.config.tip
393
- }, null, 8, _hoisted_5$4)
399
+ }, null, 8, _hoisted_4$6)
394
400
  ]),
395
401
  default: vue.withCtx(() => [
396
- _hoisted_4$6
402
+ vue.createVNode(_component_el_icon, { style: { "line-height": "40px", "margin-left": "5px" } }, {
403
+ default: vue.withCtx(() => [
404
+ vue.createVNode(_component_warning_filled)
405
+ ]),
406
+ _: 1
407
+ })
397
408
  ]),
398
409
  _: 1
399
410
  })) : vue.createCommentVNode("", true)
@@ -412,7 +423,7 @@
412
423
  }, null, 8, ["model", "config", "size", "step-active", "expand-more", "label-width", "prop", "onChange"]);
413
424
  }), 128)) : vue.createCommentVNode("", true)
414
425
  ], 64)) : vue.createCommentVNode("", true),
415
- _ctx.config.expand && _ctx.type !== "fieldset" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$3, [
426
+ _ctx.config.expand && _ctx.type !== "fieldset" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$4, [
416
427
  vue.createVNode(_component_el_button, {
417
428
  type: "text",
418
429
  onClick: _ctx.expandHandler
@@ -1362,6 +1373,8 @@
1362
1373
  ArrowDown: icons.ArrowDown,
1363
1374
  ArrowUp: icons.ArrowUp,
1364
1375
  Delete: icons.Delete,
1376
+ FullScreen: icons.FullScreen,
1377
+ Grid: icons.Grid,
1365
1378
  data: vue.computed(() => props.model[modelName.value].filter((item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value)),
1366
1379
  addable: vue.computed(() => {
1367
1380
  if (!props.model[modelName.value].length) {
@@ -1610,7 +1623,7 @@
1610
1623
  })) : vue.createCommentVNode("", true),
1611
1624
  vue.createVNode(_component_el_table_column, {
1612
1625
  label: "\u64CD\u4F5C",
1613
- width: "50",
1626
+ width: "60",
1614
1627
  fixed: _ctx.config.fixed === false ? void 0 : "left"
1615
1628
  }, {
1616
1629
  default: vue.withCtx((scope) => [
@@ -1628,7 +1641,7 @@
1628
1641
  _ctx.sort && _ctx.model[_ctx.modelName] && _ctx.model[_ctx.modelName].length > 1 ? (vue.openBlock(), vue.createBlock(_component_el_table_column, {
1629
1642
  key: 1,
1630
1643
  label: "\u6392\u5E8F",
1631
- width: "70"
1644
+ width: "60"
1632
1645
  }, {
1633
1646
  default: vue.withCtx((scope) => [
1634
1647
  scope.$index + 1 + _ctx.pagecontext * _ctx.pagesize - 1 !== 0 ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
@@ -1676,7 +1689,7 @@
1676
1689
  width: "45"
1677
1690
  })) : vue.createCommentVNode("", true),
1678
1691
  vue.createVNode(_component_el_table_column, {
1679
- width: "50",
1692
+ width: "60",
1680
1693
  label: "\u5E8F\u53F7"
1681
1694
  }, {
1682
1695
  default: vue.withCtx((scope) => [
@@ -1733,7 +1746,7 @@
1733
1746
  _hoisted_5,
1734
1747
  _ctx.enableToggleMode && !_ctx.isFullscreen ? (vue.openBlock(), vue.createBlock(_component_el_button, {
1735
1748
  key: 1,
1736
- icon: "el-icon-s-grid",
1749
+ icon: _ctx.Grid,
1737
1750
  size: "small",
1738
1751
  onClick: _ctx.toggleMode
1739
1752
  }, {
@@ -1741,10 +1754,10 @@
1741
1754
  _hoisted_6
1742
1755
  ]),
1743
1756
  _: 1
1744
- }, 8, ["onClick"])) : vue.createCommentVNode("", true),
1757
+ }, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true),
1745
1758
  _ctx.config.enableFullscreen !== false ? (vue.openBlock(), vue.createBlock(_component_el_button, {
1746
1759
  key: 2,
1747
- icon: "el-icon-s-grid",
1760
+ icon: _ctx.FullScreen,
1748
1761
  size: "small",
1749
1762
  onClick: _ctx.toggleFullscreen
1750
1763
  }, {
@@ -1752,7 +1765,7 @@
1752
1765
  vue.createTextVNode(vue.toDisplayString(_ctx.isFullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F\u7F16\u8F91"), 1)
1753
1766
  ]),
1754
1767
  _: 1
1755
- }, 8, ["onClick"])) : vue.createCommentVNode("", true),
1768
+ }, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true),
1756
1769
  _ctx.importable ? (vue.openBlock(), vue.createBlock(_component_el_upload, {
1757
1770
  key: 3,
1758
1771
  ref: "excelBtn",
@@ -1818,6 +1831,7 @@
1818
1831
  };
1819
1832
  const tabClickHandler = (mForm, tab, props) => {
1820
1833
  const { config, model, prop } = props;
1834
+ tab.name = tab.paneName;
1821
1835
  if (typeof config.onTabClick === "function") {
1822
1836
  config.onTabClick(mForm, tab, { model, formValue: mForm?.values, prop });
1823
1837
  }
@@ -2937,6 +2951,7 @@
2937
2951
  vue.watch(() => mForm?.values, () => {
2938
2952
  typeof props.config.options === "function" && Promise.resolve(props.config.options(mForm, {
2939
2953
  model: props.model,
2954
+ prop: props.prop,
2940
2955
  formValues: mForm?.values,
2941
2956
  formValue: mForm?.values
2942
2957
  })).then((data) => {
@@ -2986,6 +3001,7 @@
2986
3001
  remote,
2987
3002
  options,
2988
3003
  moreLoadingVisible,
3004
+ popperClass: mForm?.popperClass,
2989
3005
  getRequestFuc() {
2990
3006
  return getConfig("request");
2991
3007
  },
@@ -3039,6 +3055,7 @@
3039
3055
  ref: "select",
3040
3056
  clearable: "",
3041
3057
  filterable: "",
3058
+ "popper-class": `m-select-popper ${_ctx.popperClass}`,
3042
3059
  size: _ctx.size,
3043
3060
  remote: _ctx.remote,
3044
3061
  placeholder: _ctx.config.placeholder,
@@ -3082,7 +3099,7 @@
3082
3099
  ]) : vue.createCommentVNode("", true)
3083
3100
  ]),
3084
3101
  _: 1
3085
- }, 8, ["modelValue", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method", "onChange", "onVisibleChange"])), [
3102
+ }, 8, ["modelValue", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method", "onChange", "onVisibleChange"])), [
3086
3103
  [_directive_loading, _ctx.loading]
3087
3104
  ]) : vue.createCommentVNode("", true);
3088
3105
  }
@@ -3253,7 +3270,7 @@
3253
3270
  typeof _ctx.config.append === "object" && _ctx.config.append.type === "button" ? (vue.openBlock(), vue.createBlock(_component_el_button, {
3254
3271
  key: 1,
3255
3272
  style: { "color": "#409eff" },
3256
- onClick: _ctx.buttonClickHandler
3273
+ onClick: vue.withModifiers(_ctx.buttonClickHandler, ["prevent"])
3257
3274
  }, {
3258
3275
  default: vue.withCtx(() => [
3259
3276
  vue.createTextVNode(vue.toDisplayString(_ctx.config.append.text), 1)
@@ -3358,7 +3375,6 @@
3358
3375
 
3359
3376
  const _sfc_main$1 = vue.defineComponent({
3360
3377
  name: "m-form",
3361
- components: { ElForm: elementPlus.ElForm, MContainer: Container },
3362
3378
  props: {
3363
3379
  initValues: {
3364
3380
  type: Object,
@@ -3391,8 +3407,7 @@
3391
3407
  default: () => 1
3392
3408
  },
3393
3409
  size: {
3394
- type: String,
3395
- default: "small"
3410
+ type: String
3396
3411
  },
3397
3412
  inline: {
3398
3413
  type: Boolean,
@@ -3405,6 +3420,9 @@
3405
3420
  keyProp: {
3406
3421
  type: String,
3407
3422
  default: "__key"
3423
+ },
3424
+ popperClass: {
3425
+ type: String
3408
3426
  }
3409
3427
  },
3410
3428
  emits: ["change", "field-input", "field-change"],
@@ -3416,6 +3434,7 @@
3416
3434
  const requestFuc = getConfig("request");
3417
3435
  const formState = vue.reactive({
3418
3436
  keyProp: props.keyProp,
3437
+ popperClass: props.popperClass,
3419
3438
  config: props.config,
3420
3439
  initValues: props.initValues,
3421
3440
  parentValues: props.parentValues,
@@ -3435,8 +3454,10 @@
3435
3454
  }
3436
3455
  });
3437
3456
  vue.provide("mForm", formState);
3438
- vue.watchEffect(() => {
3439
- initialized.value = false;
3457
+ vue.watch([() => props.config, () => props.initValues], ([config], [preConfig]) => {
3458
+ if (!lodashEs.isEqual(vue.toRaw(config), vue.toRaw(preConfig))) {
3459
+ initialized.value = false;
3460
+ }
3440
3461
  initValue(formState, {
3441
3462
  initValues: props.initValues,
3442
3463
  config: props.config
@@ -3444,7 +3465,7 @@
3444
3465
  values.value = value;
3445
3466
  initialized.value = true;
3446
3467
  });
3447
- });
3468
+ }, { immediate: true });
3448
3469
  return {
3449
3470
  initialized,
3450
3471
  values,
@@ -3477,10 +3498,9 @@
3477
3498
  }
3478
3499
  });
3479
3500
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3480
- const _component_MContainer = vue.resolveComponent("MContainer");
3481
- const _component_ElForm = vue.resolveComponent("ElForm");
3482
- return _ctx.initialized && Array.isArray(_ctx.config) ? (vue.openBlock(), vue.createBlock(_component_ElForm, {
3483
- key: 0,
3501
+ const _component_m_form_container = vue.resolveComponent("m-form-container");
3502
+ const _component_el_form = vue.resolveComponent("el-form");
3503
+ return vue.openBlock(), vue.createBlock(_component_el_form, {
3484
3504
  class: "m-form",
3485
3505
  ref: "elForm",
3486
3506
  model: _ctx.values,
@@ -3491,8 +3511,8 @@
3491
3511
  "label-position": _ctx.labelPosition
3492
3512
  }, {
3493
3513
  default: vue.withCtx(() => [
3494
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.config, (item, index) => {
3495
- return vue.openBlock(), vue.createBlock(_component_MContainer, {
3514
+ _ctx.initialized && Array.isArray(_ctx.config) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(_ctx.config, (item, index) => {
3515
+ return vue.openBlock(), vue.createBlock(_component_m_form_container, {
3496
3516
  key: item[_ctx.keyProp] ?? index,
3497
3517
  config: item,
3498
3518
  model: _ctx.values,
@@ -3501,10 +3521,10 @@
3501
3521
  size: _ctx.size,
3502
3522
  onChange: _ctx.changeHandler
3503
3523
  }, null, 8, ["config", "model", "label-width", "step-active", "size", "onChange"]);
3504
- }), 128))
3524
+ }), 128)) : vue.createCommentVNode("", true)
3505
3525
  ]),
3506
3526
  _: 1
3507
- }, 8, ["model", "label-width", "disabled", "style", "inline", "label-position"])) : vue.createCommentVNode("", true);
3527
+ }, 8, ["model", "label-width", "disabled", "style", "inline", "label-position"]);
3508
3528
  }
3509
3529
  var Form = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
3510
3530
 
@@ -3524,6 +3544,7 @@
3524
3544
  default: () => []
3525
3545
  },
3526
3546
  labelWidth: [Number, String],
3547
+ size: String,
3527
3548
  confirmText: {
3528
3549
  type: String,
3529
3550
  default: "\u786E\u5B9A"
@@ -3694,11 +3715,12 @@
3694
3715
  modelValue: _ctx.stepActive,
3695
3716
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.stepActive = $event),
3696
3717
  ref: "form",
3718
+ size: _ctx.size,
3697
3719
  config: _ctx.config,
3698
3720
  "init-values": _ctx.values,
3699
3721
  "label-width": _ctx.labelWidth,
3700
3722
  onChange: _ctx.changeHandler
3701
- }, null, 8, ["modelValue", "config", "init-values", "label-width", "onChange"]),
3723
+ }, null, 8, ["modelValue", "size", "config", "init-values", "label-width", "onChange"]),
3702
3724
  vue.renderSlot(_ctx.$slots, "default")
3703
3725
  ], 4)
3704
3726
  ]),