@tmagic/form 1.4.16 → 1.4.18

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.
package/dist/style.css CHANGED
@@ -46,10 +46,10 @@
46
46
  .m-form .el-tabs {
47
47
  margin-bottom: 10px;
48
48
  }
49
- .m-form .el-form-item.hidden > .el-form-item__label {
49
+ .m-form .el-form-item.tmagic-form-hidden > .el-form-item__label {
50
50
  display: none;
51
51
  }
52
- .m-form .t-form__item.hidden > .t-form__label {
52
+ .m-form .t-form__item.tmagic-form-hidden > .t-form__label {
53
53
  display: none;
54
54
  }
55
55
 
@@ -165,7 +165,7 @@ const initValue = async (mForm, { initValues, config }) => {
165
165
  return valuesTmp || {};
166
166
  };
167
167
 
168
- const _hoisted_1$d = ["id", "data-magic-id"];
168
+ const _hoisted_1$d = ["data-tmagic-id", "data-tmagic-form-item-prop"];
169
169
  const _hoisted_2$8 = ["innerHTML", "title"];
170
170
  const _hoisted_3$5 = ["innerHTML"];
171
171
  const _hoisted_4$4 = ["innerHTML"];
@@ -319,8 +319,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
319
319
  const _component_Container = resolveComponent("Container", true);
320
320
  return _ctx.config ? (openBlock(), createElementBlock("div", {
321
321
  key: 0,
322
- id: _ctx.config.id,
323
- "data-magic-id": _ctx.config.id,
322
+ "data-tmagic-id": _ctx.config.id,
323
+ "data-tmagic-form-item-prop": itemProp.value,
324
324
  style: normalizeStyle(_ctx.config.tip ? "display: flex;align-items: baseline;" : ""),
325
325
  class: normalizeClass(`m-form-container m-container-${type.value || ""} ${_ctx.config.className || ""}`)
326
326
  }, [
@@ -349,7 +349,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
349
349
  }, null, 40, ["size", "model", "last-values", "is-compare", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
350
350
  createVNode(unref(TMagicFormItem), {
351
351
  style: normalizeStyle(_ctx.config.tip ? "flex: 1" : ""),
352
- class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
352
+ class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
353
353
  prop: itemProp.value,
354
354
  "label-width": itemLabelWidth.value,
355
355
  rules: rule.value
@@ -422,7 +422,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
422
422
  ], 64)) : type.value && display$1.value && showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
423
423
  createVNode(unref(TMagicFormItem), {
424
424
  style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
425
- class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
425
+ class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
426
426
  prop: itemProp.value,
427
427
  "label-width": itemLabelWidth.value,
428
428
  rules: rule.value
@@ -490,7 +490,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
490
490
  })) : createCommentVNode("", true),
491
491
  createVNode(unref(TMagicFormItem), {
492
492
  style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
493
- class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
493
+ class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
494
494
  prop: itemProp.value,
495
495
  "label-width": itemLabelWidth.value,
496
496
  rules: rule.value
@@ -2455,7 +2455,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2455
2455
  const props = __props;
2456
2456
  const emit = __emit;
2457
2457
  useAddField(props.prop);
2458
- props.model[props.name] = datetimeFormatter(props.model[props.name], "");
2458
+ props.model[props.name] = datetimeFormatter(props.model[props.name], "", "YYYY/MM/DD");
2459
2459
  const changeHandler = (v) => {
2460
2460
  emit("change", v);
2461
2461
  };
@@ -2467,8 +2467,8 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
2467
2467
  size: _ctx.size,
2468
2468
  placeholder: _ctx.config.placeholder,
2469
2469
  disabled: _ctx.disabled,
2470
- format: _ctx.config.format,
2471
- "value-format": _ctx.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
2470
+ format: _ctx.config.format || "YYYY/MM/DD",
2471
+ "value-format": _ctx.config.valueFormat || "YYYY/MM/DD",
2472
2472
  onChange: changeHandler
2473
2473
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format"]);
2474
2474
  };
@@ -2532,7 +2532,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2532
2532
  return;
2533
2533
  }
2534
2534
  if (Array.isArray(v)) {
2535
- props.model[item] = datetimeFormatter(v[index]?.toString(), "");
2535
+ props.model[item] = datetimeFormatter(
2536
+ v[index]?.toString(),
2537
+ "",
2538
+ props.config.valueFormat || "YYYY/MM/DD HH:mm:ss"
2539
+ );
2536
2540
  } else {
2537
2541
  props.model[item] = void 0;
2538
2542
  }
@@ -2544,7 +2548,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2544
2548
  emit(
2545
2549
  "change",
2546
2550
  value2.map((item) => {
2547
- if (item) return datetimeFormatter(item, "");
2551
+ if (item) return datetimeFormatter(item, "", props.config.valueFormat || "YYYY/MM/DD HH:mm:ss");
2548
2552
  return void 0;
2549
2553
  })
2550
2554
  );
@@ -2567,8 +2571,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
2567
2571
  "unlink-panels": true,
2568
2572
  disabled: _ctx.disabled,
2569
2573
  "default-time": _ctx.config.defaultTime,
2574
+ "value-format": _ctx.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
2575
+ "date-format": _ctx.config.dateFormat || "YYYY/MM/DD",
2576
+ "time-format": _ctx.config.timeFormat || "HH:mm:ss",
2570
2577
  onChange: changeHandler
2571
- }, null, 8, ["modelValue", "size", "disabled", "default-time"]);
2578
+ }, null, 8, ["modelValue", "size", "disabled", "default-time", "value-format", "date-format", "time-format"]);
2572
2579
  };
2573
2580
  }
2574
2581
  });
@@ -2599,7 +2606,11 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2599
2606
  if (value === "Invalid Date") {
2600
2607
  props.model[props.name] = "";
2601
2608
  } else {
2602
- props.model[props.name] = datetimeFormatter(props.model[props.name], "", props.config.valueFormat);
2609
+ props.model[props.name] = datetimeFormatter(
2610
+ props.model[props.name],
2611
+ "",
2612
+ props.config.valueFormat || "YYYY/MM/DD HH:mm:ss"
2613
+ );
2603
2614
  }
2604
2615
  }
2605
2616
  const changeHandler = (v) => {
@@ -4164,7 +4175,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
4164
4175
  return;
4165
4176
  }
4166
4177
  if (Array.isArray(v)) {
4167
- props.model[item] = datetimeFormatter(v[index]?.toString(), "");
4178
+ props.model[item] = v[index];
4168
4179
  } else {
4169
4180
  props.model[item] = void 0;
4170
4181
  }
@@ -164,7 +164,7 @@
164
164
  return valuesTmp || {};
165
165
  };
166
166
 
167
- const _hoisted_1$d = ["id", "data-magic-id"];
167
+ const _hoisted_1$d = ["data-tmagic-id", "data-tmagic-form-item-prop"];
168
168
  const _hoisted_2$8 = ["innerHTML", "title"];
169
169
  const _hoisted_3$5 = ["innerHTML"];
170
170
  const _hoisted_4$4 = ["innerHTML"];
@@ -318,8 +318,8 @@
318
318
  const _component_Container = vue.resolveComponent("Container", true);
319
319
  return _ctx.config ? (vue.openBlock(), vue.createElementBlock("div", {
320
320
  key: 0,
321
- id: _ctx.config.id,
322
- "data-magic-id": _ctx.config.id,
321
+ "data-tmagic-id": _ctx.config.id,
322
+ "data-tmagic-form-item-prop": itemProp.value,
323
323
  style: vue.normalizeStyle(_ctx.config.tip ? "display: flex;align-items: baseline;" : ""),
324
324
  class: vue.normalizeClass(`m-form-container m-container-${type.value || ""} ${_ctx.config.className || ""}`)
325
325
  }, [
@@ -348,7 +348,7 @@
348
348
  }, null, 40, ["size", "model", "last-values", "is-compare", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : type.value && display$1.value && !showDiff.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
349
349
  vue.createVNode(vue.unref(design.TMagicFormItem), {
350
350
  style: vue.normalizeStyle(_ctx.config.tip ? "flex: 1" : ""),
351
- class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
351
+ class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
352
352
  prop: itemProp.value,
353
353
  "label-width": itemLabelWidth.value,
354
354
  rules: rule.value
@@ -421,7 +421,7 @@
421
421
  ], 64)) : type.value && display$1.value && showDiff.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
422
422
  vue.createVNode(vue.unref(design.TMagicFormItem), {
423
423
  style: vue.normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
424
- class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
424
+ class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
425
425
  prop: itemProp.value,
426
426
  "label-width": itemLabelWidth.value,
427
427
  rules: rule.value
@@ -489,7 +489,7 @@
489
489
  })) : vue.createCommentVNode("", true),
490
490
  vue.createVNode(vue.unref(design.TMagicFormItem), {
491
491
  style: vue.normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
492
- class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
492
+ class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
493
493
  prop: itemProp.value,
494
494
  "label-width": itemLabelWidth.value,
495
495
  rules: rule.value
@@ -2454,7 +2454,7 @@
2454
2454
  const props = __props;
2455
2455
  const emit = __emit;
2456
2456
  useAddField(props.prop);
2457
- props.model[props.name] = utils.datetimeFormatter(props.model[props.name], "");
2457
+ props.model[props.name] = utils.datetimeFormatter(props.model[props.name], "", "YYYY/MM/DD");
2458
2458
  const changeHandler = (v) => {
2459
2459
  emit("change", v);
2460
2460
  };
@@ -2466,8 +2466,8 @@
2466
2466
  size: _ctx.size,
2467
2467
  placeholder: _ctx.config.placeholder,
2468
2468
  disabled: _ctx.disabled,
2469
- format: _ctx.config.format,
2470
- "value-format": _ctx.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
2469
+ format: _ctx.config.format || "YYYY/MM/DD",
2470
+ "value-format": _ctx.config.valueFormat || "YYYY/MM/DD",
2471
2471
  onChange: changeHandler
2472
2472
  }, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format"]);
2473
2473
  };
@@ -2531,7 +2531,11 @@
2531
2531
  return;
2532
2532
  }
2533
2533
  if (Array.isArray(v)) {
2534
- props.model[item] = utils.datetimeFormatter(v[index]?.toString(), "");
2534
+ props.model[item] = utils.datetimeFormatter(
2535
+ v[index]?.toString(),
2536
+ "",
2537
+ props.config.valueFormat || "YYYY/MM/DD HH:mm:ss"
2538
+ );
2535
2539
  } else {
2536
2540
  props.model[item] = void 0;
2537
2541
  }
@@ -2543,7 +2547,7 @@
2543
2547
  emit(
2544
2548
  "change",
2545
2549
  value2.map((item) => {
2546
- if (item) return utils.datetimeFormatter(item, "");
2550
+ if (item) return utils.datetimeFormatter(item, "", props.config.valueFormat || "YYYY/MM/DD HH:mm:ss");
2547
2551
  return void 0;
2548
2552
  })
2549
2553
  );
@@ -2566,8 +2570,11 @@
2566
2570
  "unlink-panels": true,
2567
2571
  disabled: _ctx.disabled,
2568
2572
  "default-time": _ctx.config.defaultTime,
2573
+ "value-format": _ctx.config.valueFormat || "YYYY/MM/DD HH:mm:ss",
2574
+ "date-format": _ctx.config.dateFormat || "YYYY/MM/DD",
2575
+ "time-format": _ctx.config.timeFormat || "HH:mm:ss",
2569
2576
  onChange: changeHandler
2570
- }, null, 8, ["modelValue", "size", "disabled", "default-time"]);
2577
+ }, null, 8, ["modelValue", "size", "disabled", "default-time", "value-format", "date-format", "time-format"]);
2571
2578
  };
2572
2579
  }
2573
2580
  });
@@ -2598,7 +2605,11 @@
2598
2605
  if (value === "Invalid Date") {
2599
2606
  props.model[props.name] = "";
2600
2607
  } else {
2601
- props.model[props.name] = utils.datetimeFormatter(props.model[props.name], "", props.config.valueFormat);
2608
+ props.model[props.name] = utils.datetimeFormatter(
2609
+ props.model[props.name],
2610
+ "",
2611
+ props.config.valueFormat || "YYYY/MM/DD HH:mm:ss"
2612
+ );
2602
2613
  }
2603
2614
  }
2604
2615
  const changeHandler = (v) => {
@@ -4163,7 +4174,7 @@
4163
4174
  return;
4164
4175
  }
4165
4176
  if (Array.isArray(v)) {
4166
- props.model[item] = utils.datetimeFormatter(v[index]?.toString(), "");
4177
+ props.model[item] = v[index];
4167
4178
  } else {
4168
4179
  props.model[item] = void 0;
4169
4180
  }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
- "version": "1.4.16",
2
+ "version": "1.4.18",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
+ "dist/style.css",
6
7
  "src/theme/*"
7
8
  ],
8
9
  "main": "dist/tmagic-form.umd.cjs",
@@ -54,8 +55,8 @@
54
55
  "peerDependencies": {
55
56
  "vue": "^3.4.35",
56
57
  "typescript": "*",
57
- "@tmagic/utils": "1.4.16",
58
- "@tmagic/design": "1.4.16"
58
+ "@tmagic/design": "1.4.18",
59
+ "@tmagic/utils": "1.4.18"
59
60
  },
60
61
  "peerDependenciesMeta": {
61
62
  "typescript": {
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div
3
3
  v-if="config"
4
- :id="config.id"
5
- :data-magic-id="config.id"
4
+ :data-tmagic-id="config.id"
5
+ :data-tmagic-form-item-prop="itemProp"
6
6
  :style="config.tip ? 'display: flex;align-items: baseline;' : ''"
7
7
  :class="`m-form-container m-container-${type || ''} ${config.className || ''}`"
8
8
  >
@@ -37,7 +37,7 @@
37
37
  <template v-else-if="type && display && !showDiff">
38
38
  <TMagicFormItem
39
39
  :style="config.tip ? 'flex: 1' : ''"
40
- :class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
40
+ :class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
41
41
  :prop="itemProp"
42
42
  :label-width="itemLabelWidth"
43
43
  :rules="rule"
@@ -93,7 +93,7 @@
93
93
  <!-- 上次内容 -->
94
94
  <TMagicFormItem
95
95
  :style="config.tip ? 'flex: 1' : ''"
96
- :class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
96
+ :class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
97
97
  :prop="itemProp"
98
98
  :label-width="itemLabelWidth"
99
99
  :rules="rule"
@@ -142,7 +142,7 @@
142
142
  <!-- 当前内容 -->
143
143
  <TMagicFormItem
144
144
  :style="config.tip ? 'flex: 1' : ''"
145
- :class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
145
+ :class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
146
146
  :prop="itemProp"
147
147
  :label-width="itemLabelWidth"
148
148
  :rules="rule"
@@ -5,8 +5,8 @@
5
5
  :size="size"
6
6
  :placeholder="config.placeholder"
7
7
  :disabled="disabled"
8
- :format="config.format"
9
- :value-format="config.valueFormat || 'YYYY/MM/DD HH:mm:ss'"
8
+ :format="config.format || 'YYYY/MM/DD'"
9
+ :value-format="config.valueFormat || 'YYYY/MM/DD'"
10
10
  @change="changeHandler"
11
11
  ></TMagicDatePicker>
12
12
  </template>
@@ -30,7 +30,7 @@ const emit = defineEmits<{
30
30
 
31
31
  useAddField(props.prop);
32
32
 
33
- props.model[props.name] = datetimeFormatter(props.model[props.name], '');
33
+ props.model[props.name] = datetimeFormatter(props.model[props.name], '', 'YYYY/MM/DD');
34
34
 
35
35
  const changeHandler = (v: string) => {
36
36
  emit('change', v);
@@ -37,7 +37,11 @@ if (props.model) {
37
37
  if (value === 'Invalid Date') {
38
38
  props.model[props.name] = '';
39
39
  } else {
40
- props.model[props.name] = datetimeFormatter(props.model[props.name], '', props.config.valueFormat);
40
+ props.model[props.name] = datetimeFormatter(
41
+ props.model[props.name],
42
+ '',
43
+ props.config.valueFormat || 'YYYY/MM/DD HH:mm:ss',
44
+ );
41
45
  }
42
46
  }
43
47
 
@@ -9,6 +9,9 @@
9
9
  :unlink-panels="true"
10
10
  :disabled="disabled"
11
11
  :default-time="config.defaultTime"
12
+ :value-format="config.valueFormat || 'YYYY/MM/DD HH:mm:ss'"
13
+ :date-format="config.dateFormat || 'YYYY/MM/DD'"
14
+ :time-format="config.timeFormat || 'HH:mm:ss'"
12
15
  @change="changeHandler"
13
16
  ></TMagicDatePicker>
14
17
  </template>
@@ -71,7 +74,11 @@ const setValue = (v: Date[] | Date) => {
71
74
  return;
72
75
  }
73
76
  if (Array.isArray(v)) {
74
- props.model[item] = datetimeFormatter(v[index]?.toString(), '');
77
+ props.model[item] = datetimeFormatter(
78
+ v[index]?.toString(),
79
+ '',
80
+ props.config.valueFormat || 'YYYY/MM/DD HH:mm:ss',
81
+ );
75
82
  } else {
76
83
  props.model[item] = undefined;
77
84
  }
@@ -85,7 +92,7 @@ const changeHandler = (v: Date[]) => {
85
92
  emit(
86
93
  'change',
87
94
  value.map((item?: Date) => {
88
- if (item) return datetimeFormatter(item, '');
95
+ if (item) return datetimeFormatter(item, '', props.config.valueFormat || 'YYYY/MM/DD HH:mm:ss');
89
96
  return undefined;
90
97
  }),
91
98
  );
@@ -17,7 +17,6 @@
17
17
  import { ref, watch } from 'vue';
18
18
 
19
19
  import { TMagicTimePicker } from '@tmagic/design';
20
- import { datetimeFormatter } from '@tmagic/utils';
21
20
 
22
21
  import type { DaterangeConfig, FieldProps } from '../schema';
23
22
  import { useAddField } from '../utils/useAddField';
@@ -59,7 +58,7 @@ const setValue = (v: Date[] | Date) => {
59
58
  return;
60
59
  }
61
60
  if (Array.isArray(v)) {
62
- props.model[item] = datetimeFormatter(v[index]?.toString(), '');
61
+ props.model[item] = v[index];
63
62
  } else {
64
63
  props.model[item] = undefined;
65
64
  }
package/src/schema.ts CHANGED
@@ -296,6 +296,9 @@ export interface DaterangeConfig extends FormItem {
296
296
  type: 'daterange';
297
297
  defaultTime?: Date[];
298
298
  names?: string[];
299
+ valueFormat?: string;
300
+ dateFormat?: string;
301
+ timeFormat?: string;
299
302
  }
300
303
 
301
304
  /**
@@ -29,13 +29,13 @@
29
29
  margin-bottom: 10px;
30
30
  }
31
31
 
32
- .el-form-item.hidden {
32
+ .el-form-item.tmagic-form-hidden {
33
33
  > .el-form-item__label {
34
34
  display: none;
35
35
  }
36
36
  }
37
37
 
38
- .t-form__item.hidden {
38
+ .t-form__item.tmagic-form-hidden {
39
39
  > .t-form__label {
40
40
  display: none;
41
41
  }
package/types/schema.d.ts CHANGED
@@ -229,6 +229,9 @@ export interface DaterangeConfig extends FormItem {
229
229
  type: 'daterange';
230
230
  defaultTime?: Date[];
231
231
  names?: string[];
232
+ valueFormat?: string;
233
+ dateFormat?: string;
234
+ timeFormat?: string;
232
235
  }
233
236
  /**
234
237
  * html编辑器