@ftjs/tdesign 0.5.3 → 0.5.5

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { computed, toValue, createVNode, mergeProps, defineComponent, createBlock, openBlock, resolveDynamicComponent, unref, createElementBlock, Fragment, renderList, ref, useId, withCtx, renderSlot, createCommentVNode, createTextVNode, createElementVNode } from "vue";
2
- import { getField, set, useFormItem, unrefs, useFormInject, useForm } from "@ftjs/core";
3
- import { FormItem, AutoComplete as AutoComplete$1, Cascader as Cascader$1, Form, Button, Dialog, Tree } from "tdesign-vue-next";
1
+ import { computed, toValue, createVNode, mergeProps, createTextVNode, h, isVNode, defineComponent, createBlock, openBlock, resolveDynamicComponent, unref, createElementBlock, Fragment, renderList, normalizeStyle, ref, useId, withCtx, renderSlot, createCommentVNode, createElementVNode } from "vue";
2
+ import { getField, set, useFormItem, useFormInject, unrefs, useForm } from "@ftjs/core";
3
+ import { FormItem, AutoComplete as AutoComplete$1, Cascader as Cascader$1, CheckboxGroup, ColorPicker as ColorPicker$1, DatePicker as DatePicker$1, DateRangePicker as DateRangePicker$1, Input as Input$1, InputAdornment, InputNumber as InputNumber$1, Tag, TagInput as TagInput$1, RadioGroup, RangeInput as RangeInput$1, Select as Select$1, Slider as Slider$1, Switch as Switch$1, Textarea as Textarea$1, TimePicker as TimePicker$1, TreeSelect as TreeSelect$1, Form, Button, Dialog, Tree } from "tdesign-vue-next";
4
4
  import { MoveIcon, SettingIcon } from "tdesign-icons-vue-next";
5
5
  const useFormItemProps = (column) => {
6
6
  return computed(() => {
@@ -33,16 +33,77 @@ const AutoComplete = defineFormItem((props) => {
33
33
  });
34
34
  const formItemProps = useFormItemProps(props.column);
35
35
  return () => {
36
- const _props = unrefs(props.column.props);
37
36
  return createVNode(FormItem, formItemProps.value, {
38
37
  default: () => [props.isView ? createVNode("div", null, [valueComputed.value || "-"]) : createVNode(AutoComplete$1, mergeProps({
39
38
  "value": valueComputed.value,
40
39
  "onUpdate:value": ($event) => valueComputed.value = $event,
41
40
  "placeholder": `请输入${formItemProps.value.label}`
42
- }, _props), null)]
41
+ }, props.unrefsProps), null)]
43
42
  });
44
43
  };
45
44
  });
45
+ const isViewOptionsStyle = "display: flex; gap: 8px;";
46
+ const findLabelInfo = ({
47
+ options,
48
+ targetValue,
49
+ showAllLevels = true,
50
+ currentPath = []
51
+ }) => {
52
+ if (!options) return null;
53
+ for (const option of options) {
54
+ const currentLabel = String(option.label);
55
+ const newPath = [...currentPath, currentLabel];
56
+ if (option.value === targetValue) {
57
+ return showAllLevels ? newPath.join(" / ") : currentLabel;
58
+ }
59
+ if (option.children && Array.isArray(option.children)) {
60
+ const found = findLabelInfo({
61
+ options: option.children,
62
+ targetValue,
63
+ showAllLevels,
64
+ currentPath: newPath
65
+ });
66
+ if (found !== null) {
67
+ return found;
68
+ }
69
+ }
70
+ }
71
+ return null;
72
+ };
73
+ const renderCascaderText = (props) => {
74
+ const {
75
+ value,
76
+ multiple,
77
+ showAllLevels,
78
+ options
79
+ } = props;
80
+ const treeOptions = options;
81
+ if (!treeOptions || treeOptions.length === 0) {
82
+ return "";
83
+ }
84
+ if (multiple) {
85
+ const values = Array.isArray(value) ? value : [];
86
+ if (values.length === 0) {
87
+ return "";
88
+ }
89
+ const labels = values.map((val) => findLabelInfo({
90
+ options: treeOptions,
91
+ targetValue: val,
92
+ showAllLevels
93
+ })).filter((label) => label !== null);
94
+ return labels.join(", ");
95
+ } else {
96
+ if (value === null || value === void 0 || value === "") {
97
+ return "";
98
+ }
99
+ const label = findLabelInfo({
100
+ options: treeOptions,
101
+ targetValue: value,
102
+ showAllLevels
103
+ });
104
+ return label || "";
105
+ }
106
+ };
46
107
  const Cascader = defineFormItem((props) => {
47
108
  const {
48
109
  valueComputed
@@ -51,15 +112,446 @@ const Cascader = defineFormItem((props) => {
51
112
  });
52
113
  const formItemProps = useFormItemProps(props.column);
53
114
  return () => {
54
- const _props = unrefs(props.column.props);
115
+ const _props = props.unrefsProps;
116
+ const viewRender = () => {
117
+ return renderCascaderText({
118
+ ..._props,
119
+ value: valueComputed.value
120
+ });
121
+ };
122
+ return createVNode(FormItem, formItemProps.value, {
123
+ default: () => [props.isView ? createVNode("div", {
124
+ "style": isViewOptionsStyle
125
+ }, [viewRender()]) : createVNode(Cascader$1, mergeProps({
126
+ "value": valueComputed.value,
127
+ "onUpdate:value": ($event) => valueComputed.value = $event,
128
+ "placeholder": `请选择${formItemProps.value.label}`
129
+ }, _props), null)]
130
+ });
131
+ };
132
+ });
133
+ function renderStrOrTNode(strOrTNode) {
134
+ if (typeof strOrTNode === "function") {
135
+ return strOrTNode(h);
136
+ }
137
+ return strOrTNode;
138
+ }
139
+ function isSimpleOption(option) {
140
+ return typeof option === "string" || typeof option === "number";
141
+ }
142
+ function viewRenderOptions(renderOptions) {
143
+ const {
144
+ keys,
145
+ multiple,
146
+ value,
147
+ withChildren = false
148
+ } = renderOptions;
149
+ const options = renderOptions.options ? [...renderOptions.options] : [];
150
+ if (withChildren) {
151
+ const childrenKey = (keys == null ? void 0 : keys.children) || "children";
152
+ const addChildrenOptions = (items) => {
153
+ items.forEach((item) => {
154
+ var _a;
155
+ if (((_a = item[childrenKey]) == null ? void 0 : _a.length) > 0) {
156
+ options.push(...item[childrenKey]);
157
+ addChildrenOptions(item[childrenKey]);
158
+ }
159
+ });
160
+ };
161
+ addChildrenOptions(options);
162
+ }
163
+ let valueArray = [];
164
+ if (value) {
165
+ if (!multiple) {
166
+ valueArray = [value];
167
+ } else {
168
+ valueArray = value;
169
+ }
170
+ }
171
+ if (valueArray.length === 0) {
172
+ return createVNode("div", null, [createTextVNode("-")]);
173
+ }
174
+ const optionMap = new Map(options.map((option) => {
175
+ if (isSimpleOption(option)) {
176
+ return [option, option];
177
+ } else {
178
+ let label = option[(keys == null ? void 0 : keys.label) || "label"];
179
+ if (typeof label === "function") {
180
+ label = label(h);
181
+ }
182
+ return [option[(keys == null ? void 0 : keys.value) || "value"], label];
183
+ }
184
+ }));
185
+ return createVNode("div", {
186
+ "style": isViewOptionsStyle
187
+ }, [valueArray.map((v) => {
188
+ return createVNode("span", null, [optionMap.get(v)]);
189
+ })]);
190
+ }
191
+ const Checkbox = defineFormItem((props) => {
192
+ const {
193
+ valueComputed
194
+ } = useFormItem({
195
+ props
196
+ });
197
+ const formItemProps = useFormItemProps(props.column);
198
+ return () => {
199
+ var _a;
200
+ const options = ((_a = props.unrefsProps) == null ? void 0 : _a.options) || [];
201
+ return createVNode(FormItem, formItemProps.value, {
202
+ default: () => [props.isView ? viewRenderOptions({
203
+ options,
204
+ value: valueComputed.value,
205
+ multiple: true
206
+ }) : createVNode(CheckboxGroup, mergeProps({
207
+ "value": valueComputed.value,
208
+ "onUpdate:value": ($event) => valueComputed.value = $event
209
+ }, props.unrefsProps), null)]
210
+ });
211
+ };
212
+ });
213
+ const ColorPicker = defineFormItem((props) => {
214
+ const {
215
+ valueComputed
216
+ } = useFormItem({
217
+ props
218
+ });
219
+ const formItemProps = useFormItemProps(props.column);
220
+ return () => {
221
+ return createVNode(FormItem, formItemProps.value, {
222
+ default: () => [props.isView ? createVNode("div", {
223
+ "style": valueComputed.value && {
224
+ background: valueComputed.value,
225
+ backgroundClip: "text",
226
+ color: "transparent",
227
+ border: "1px solid var(--td-border-level-2-color)",
228
+ padding: "2px 4px",
229
+ borderRadius: "var(--td-radius-default)"
230
+ }
231
+ }, [valueComputed.value || "-"]) : (
232
+ // @ts-expect-error null 类型不兼容
233
+ createVNode(ColorPicker$1, mergeProps({
234
+ "value": valueComputed.value,
235
+ "onUpdate:value": ($event) => valueComputed.value = $event
236
+ }, props.unrefsProps), null)
237
+ )]
238
+ });
239
+ };
240
+ });
241
+ const DatePicker = defineFormItem((props) => {
242
+ const {
243
+ valueComputed
244
+ } = useFormItem({
245
+ props
246
+ });
247
+ const formItemProps = useFormItemProps(props.column);
248
+ return () => {
55
249
  return createVNode(FormItem, formItemProps.value, {
56
250
  default: () => [props.isView ? createVNode("div", null, [valueComputed.value || "-"]) : (
57
- // @ts-expect-error Type 'TdSelectInputProps | SelectInputValue | undefined' is not assignable to type 'TdSelectInputProps | undefined'.
58
- createVNode(Cascader$1, mergeProps({
251
+ // @ts-expect-error 当前版本类型bug不兼容
252
+ createVNode(DatePicker$1, mergeProps({
253
+ "value": valueComputed.value,
254
+ "onUpdate:value": ($event) => valueComputed.value = $event,
255
+ "placeholder": `请输入${formItemProps.value.label}`
256
+ }, props.unrefsProps), null)
257
+ )]
258
+ });
259
+ };
260
+ });
261
+ const DateRangePicker = defineFormItem((props) => {
262
+ const {
263
+ valueComputed
264
+ } = useFormItem({
265
+ props
266
+ });
267
+ const formItemProps = useFormItemProps(props.column);
268
+ return () => {
269
+ return createVNode(FormItem, formItemProps.value, {
270
+ default: () => [props.isView ? createVNode("div", null, [valueComputed.value ? valueComputed.value.join(" ~ ") : "-"]) : createVNode(DateRangePicker$1, mergeProps({
271
+ "value": valueComputed.value,
272
+ "onUpdate:value": ($event) => valueComputed.value = $event,
273
+ "placeholder": `请输入${formItemProps.value.label}`
274
+ }, props.unrefsProps), null)]
275
+ });
276
+ };
277
+ });
278
+ function _isSlot$1(s) {
279
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
280
+ }
281
+ const Input = defineFormItem((props) => {
282
+ const {
283
+ valueComputed
284
+ } = useFormItem({
285
+ props
286
+ });
287
+ const formItemProps = useFormItemProps(props.column);
288
+ return () => {
289
+ var _a, _b;
290
+ let _slot;
291
+ const append = (_a = props.unrefsProps) == null ? void 0 : _a.append;
292
+ const prepend = (_b = props.unrefsProps) == null ? void 0 : _b.prepend;
293
+ function renderInput() {
294
+ const inputVNode = createVNode(Input$1, mergeProps({
295
+ "value": valueComputed.value,
296
+ "onUpdate:value": ($event) => valueComputed.value = $event,
297
+ "placeholder": `请输入${formItemProps.value.label}`
298
+ }, props.unrefsProps), null);
299
+ if (append || prepend) {
300
+ return createVNode(InputAdornment, {
301
+ "append": append,
302
+ "prepend": prepend
303
+ }, _isSlot$1(inputVNode) ? inputVNode : {
304
+ default: () => [inputVNode]
305
+ });
306
+ } else {
307
+ return inputVNode;
308
+ }
309
+ }
310
+ function renderContent() {
311
+ return props.isView ? createVNode("div", {
312
+ "style": {
313
+ display: "flex",
314
+ alignItems: "center"
315
+ }
316
+ }, [prepend && createVNode("span", null, [renderStrOrTNode(prepend)]), createVNode("div", null, [valueComputed.value || "-"]), append && createVNode("span", null, [renderStrOrTNode(append)])]) : renderInput();
317
+ }
318
+ return createVNode(FormItem, formItemProps.value, _isSlot$1(_slot = renderContent()) ? _slot : {
319
+ default: () => [_slot]
320
+ });
321
+ };
322
+ });
323
+ const InputNumber = defineFormItem((props) => {
324
+ const {
325
+ valueComputed
326
+ } = useFormItem({
327
+ props
328
+ });
329
+ const formItemProps = useFormItemProps(props.column);
330
+ return () => {
331
+ return createVNode(FormItem, formItemProps.value, {
332
+ default: () => [props.isView ? createVNode("div", null, [valueComputed.value || "-"]) : createVNode(InputNumber$1, mergeProps({
333
+ "value": valueComputed.value,
334
+ "onUpdate:value": ($event) => valueComputed.value = $event,
335
+ "placeholder": `请输入${formItemProps.value.label}`
336
+ }, props.unrefsProps), null)]
337
+ });
338
+ };
339
+ });
340
+ function _isSlot(s) {
341
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
342
+ }
343
+ const TagInput = defineFormItem((props) => {
344
+ const {
345
+ valueComputed
346
+ } = useFormItem({
347
+ props
348
+ });
349
+ const formItemProps = useFormItemProps(props.column);
350
+ return () => {
351
+ return createVNode(FormItem, formItemProps.value, {
352
+ default: () => {
353
+ var _a;
354
+ return [props.isView ? createVNode("div", {
355
+ "style": isViewOptionsStyle
356
+ }, [((_a = valueComputed.value) == null ? void 0 : _a.map((str) => {
357
+ var _a2;
358
+ return createVNode(Tag, (_a2 = props.unrefsProps) == null ? void 0 : _a2.tagProps, _isSlot(str) ? str : {
359
+ default: () => [str]
360
+ });
361
+ })) || "-"]) : createVNode(TagInput$1, mergeProps({
59
362
  "value": valueComputed.value,
60
363
  "onUpdate:value": ($event) => valueComputed.value = $event,
61
364
  "placeholder": `请输入${formItemProps.value.label}`
62
- }, _props), null)
365
+ }, props.unrefsProps), null)];
366
+ }
367
+ });
368
+ };
369
+ });
370
+ const Radio = defineFormItem((props) => {
371
+ const {
372
+ valueComputed
373
+ } = useFormItem({
374
+ props
375
+ });
376
+ const formItemProps = useFormItemProps(props.column);
377
+ return () => {
378
+ return createVNode(FormItem, formItemProps.value, {
379
+ default: () => {
380
+ var _a;
381
+ return [props.isView ? viewRenderOptions({
382
+ options: (_a = props.unrefsProps) == null ? void 0 : _a.options,
383
+ value: valueComputed.value,
384
+ multiple: false
385
+ }) : createVNode(RadioGroup, mergeProps({
386
+ "value": valueComputed.value,
387
+ "onUpdate:value": ($event) => valueComputed.value = $event
388
+ }, props.unrefsProps), null)];
389
+ }
390
+ });
391
+ };
392
+ });
393
+ const RangeInput = defineFormItem((props) => {
394
+ const {
395
+ valueComputed
396
+ } = useFormItem({
397
+ props
398
+ });
399
+ const formItemProps = useFormItemProps(props.column);
400
+ return () => {
401
+ return createVNode(FormItem, formItemProps.value, {
402
+ default: () => {
403
+ var _a;
404
+ return [props.isView ? createVNode("div", {
405
+ "style": isViewOptionsStyle
406
+ }, [((_a = valueComputed.value) == null ? void 0 : _a.join(" ~ ")) || "-"]) : createVNode(RangeInput$1, mergeProps({
407
+ "value": valueComputed.value,
408
+ "onUpdate:value": ($event) => valueComputed.value = $event
409
+ }, props.unrefsProps), null)];
410
+ }
411
+ });
412
+ };
413
+ });
414
+ const Select = defineFormItem((props) => {
415
+ const {
416
+ valueComputed
417
+ } = useFormItem({
418
+ props
419
+ });
420
+ const formItemProps = useFormItemProps(props.column);
421
+ return () => {
422
+ var _a;
423
+ const options = ((_a = props.unrefsProps) == null ? void 0 : _a.options) || [];
424
+ return createVNode(FormItem, formItemProps.value, {
425
+ default: () => {
426
+ var _a2, _b;
427
+ return [props.isView ? viewRenderOptions({
428
+ options,
429
+ value: valueComputed.value,
430
+ keys: (_a2 = props.unrefsProps) == null ? void 0 : _a2.keys,
431
+ multiple: (_b = props.unrefsProps) == null ? void 0 : _b.multiple
432
+ }) : (
433
+ // @ts-expect-error 库类型错误
434
+ createVNode(Select$1, mergeProps({
435
+ "value": valueComputed.value,
436
+ "onUpdate:value": ($event) => valueComputed.value = $event
437
+ }, props.unrefsProps), null)
438
+ )];
439
+ }
440
+ });
441
+ };
442
+ });
443
+ const Slider = defineFormItem((props) => {
444
+ const {
445
+ valueComputed
446
+ } = useFormItem({
447
+ props
448
+ });
449
+ const formItemProps = useFormItemProps(props.column);
450
+ return () => {
451
+ return createVNode(FormItem, formItemProps.value, {
452
+ default: () => [props.isView ? createVNode("div", null, [valueComputed.value ?? "-"]) : createVNode(Slider$1, mergeProps({
453
+ "value": valueComputed.value,
454
+ "onUpdate:value": ($event) => valueComputed.value = $event
455
+ }, props.unrefsProps), null)]
456
+ });
457
+ };
458
+ });
459
+ const Switch = defineFormItem((props) => {
460
+ const {
461
+ valueComputed
462
+ } = useFormItem({
463
+ props
464
+ });
465
+ const formItemProps = useFormItemProps(props.column);
466
+ return () => {
467
+ var _a;
468
+ const label = ((_a = props.unrefsProps) == null ? void 0 : _a.label) || ["开", "关"];
469
+ const viewRender = () => {
470
+ if (Array.isArray(label)) {
471
+ return valueComputed.value ? label[0] : label[1];
472
+ }
473
+ if (typeof label === "function") {
474
+ return label(h, {
475
+ value: valueComputed.value
476
+ });
477
+ }
478
+ return valueComputed.value;
479
+ };
480
+ return createVNode(FormItem, formItemProps.value, {
481
+ default: () => [props.isView ? createVNode("div", null, [viewRender()]) : createVNode(Switch$1, mergeProps({
482
+ "value": valueComputed.value,
483
+ "onUpdate:value": ($event) => valueComputed.value = $event
484
+ }, props.unrefsProps), null)]
485
+ });
486
+ };
487
+ });
488
+ const Textarea = defineFormItem((props) => {
489
+ const {
490
+ valueComputed
491
+ } = useFormItem({
492
+ props
493
+ });
494
+ const formItemProps = useFormItemProps(props.column);
495
+ return () => {
496
+ const viewRender = () => {
497
+ return valueComputed.value ?? "-";
498
+ };
499
+ return createVNode(FormItem, formItemProps.value, {
500
+ default: () => [props.isView ? createVNode("div", null, [viewRender()]) : createVNode(Textarea$1, mergeProps({
501
+ "value": valueComputed.value,
502
+ "onUpdate:value": ($event) => valueComputed.value = $event,
503
+ "placeholder": `请输入${props.column.title}`
504
+ }, props.unrefsProps), null)]
505
+ });
506
+ };
507
+ });
508
+ const TimePicker = defineFormItem((props) => {
509
+ const {
510
+ valueComputed
511
+ } = useFormItem({
512
+ props
513
+ });
514
+ const formItemProps = useFormItemProps(props.column);
515
+ return () => {
516
+ const viewRender = () => {
517
+ return valueComputed.value ?? "-";
518
+ };
519
+ return createVNode(FormItem, formItemProps.value, {
520
+ default: () => [props.isView ? createVNode("div", null, [viewRender()]) : (
521
+ // @ts-expect-error 类型错误
522
+ createVNode(TimePicker$1, mergeProps({
523
+ "value": valueComputed.value,
524
+ "onUpdate:value": ($event) => valueComputed.value = $event
525
+ }, props.unrefsProps), null)
526
+ )]
527
+ });
528
+ };
529
+ });
530
+ const TreeSelect = defineFormItem((props) => {
531
+ const {
532
+ valueComputed
533
+ } = useFormItem({
534
+ props
535
+ });
536
+ const formItemProps = useFormItemProps(props.column);
537
+ return () => {
538
+ const viewRender = () => {
539
+ var _a, _b, _c;
540
+ return viewRenderOptions({
541
+ options: (_a = props.unrefsProps) == null ? void 0 : _a.data,
542
+ keys: (_b = props.unrefsProps) == null ? void 0 : _b.keys,
543
+ multiple: (_c = props.unrefsProps) == null ? void 0 : _c.multiple,
544
+ value: valueComputed.value,
545
+ withChildren: true
546
+ });
547
+ };
548
+ return createVNode(FormItem, formItemProps.value, {
549
+ default: () => [props.isView ? createVNode("div", null, [viewRender()]) : (
550
+ // @ts-expect-error 类型错误
551
+ createVNode(TreeSelect$1, mergeProps({
552
+ "value": valueComputed.value,
553
+ "onUpdate:value": ($event) => valueComputed.value = $event
554
+ }, props.unrefsProps), null)
63
555
  )]
64
556
  });
65
557
  };
@@ -68,15 +560,18 @@ function defineFormItem(setup) {
68
560
  return /* @__PURE__ */ defineComponent(setup, {
69
561
  props: {
70
562
  column: Object,
71
- isView: Boolean
563
+ isView: Boolean,
564
+ unrefsProps: Object
72
565
  }
73
566
  });
74
567
  }
75
- const formRenderMap = /* @__PURE__ */ new Map([["auto-complete", AutoComplete], ["cascader", Cascader]]);
568
+ const formRenderMap = /* @__PURE__ */ new Map([["auto-complete", AutoComplete], ["cascader", Cascader], ["checkbox", Checkbox], ["color-picker", ColorPicker], ["date-picker", DatePicker], ["date-range-picker", DateRangePicker], ["input", Input], ["input-number", InputNumber], ["tag-input", TagInput], ["radio", Radio], ["range-input", RangeInput], ["select", Select], ["slider", Slider], ["switch", Switch], ["textarea", Textarea], ["time-picker", TimePicker], ["tree-select", TreeSelect]]);
569
+ function registerForm(type, Component) {
570
+ formRenderMap.set(type, Component);
571
+ }
76
572
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
77
573
  ...{
78
- name: "FtTdFormContentItem",
79
- inheritAttrs: false
574
+ name: "FtTdFormContentItem"
80
575
  },
81
576
  __name: "form-content-item",
82
577
  props: {
@@ -89,6 +584,9 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
89
584
  const isView = computed(() => {
90
585
  return toValue(props.column.isView) ?? props.isView;
91
586
  });
587
+ const unrefsProps = computed(() => {
588
+ return unrefs(props.column.props);
589
+ });
92
590
  return (_ctx, _cache) => {
93
591
  return isView.value && _ctx.column.viewRender ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.column.viewRender), {
94
592
  key: 0,
@@ -99,8 +597,9 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
99
597
  }, null, 8, ["formData"])) : (openBlock(), createBlock(resolveDynamicComponent(unref(formRenderMap).get(_ctx.column.type)), {
100
598
  key: 2,
101
599
  column: _ctx.column,
102
- "is-view": isView.value
103
- }, null, 8, ["column", "is-view"]));
600
+ "is-view": isView.value,
601
+ "unrefs-props": unrefsProps.value
602
+ }, null, 8, ["column", "is-view", "unrefs-props"]));
104
603
  };
105
604
  }
106
605
  });
@@ -112,16 +611,28 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
112
611
  __name: "form-content",
113
612
  props: {
114
613
  columns: {},
115
- isView: { type: Boolean }
614
+ isView: { type: Boolean },
615
+ isSearch: { type: Boolean }
116
616
  },
117
617
  setup(__props) {
618
+ const props = __props;
619
+ const getStyle = (column) => {
620
+ if (!props.isSearch) return;
621
+ const span2TypeList = ["date-range-picker"];
622
+ if (span2TypeList.includes(column.type)) {
623
+ return {
624
+ gridColumn: `span 2 / span 2`
625
+ };
626
+ }
627
+ };
118
628
  return (_ctx, _cache) => {
119
629
  return openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columns, (column) => {
120
630
  return openBlock(), createBlock(_sfc_main$3, {
121
631
  key: unref(getField)(column),
122
632
  column,
123
- "is-view": _ctx.isView
124
- }, null, 8, ["column", "is-view"]);
633
+ "is-view": _ctx.isView,
634
+ style: normalizeStyle(getStyle(column))
635
+ }, null, 8, ["column", "is-view", "style"]);
125
636
  }), 128);
126
637
  };
127
638
  }
@@ -228,11 +739,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
228
739
  },
229
740
  __name: "ft-td-form-search",
230
741
  props: {
742
+ width: { default: "280px" },
743
+ gap: { default: "15px 20px" },
231
744
  columns: {},
232
745
  internalFormProps: {},
233
746
  formData: {},
234
- "onUpdate:formData": { type: Function },
235
- onSubmit: { type: Function },
747
+ "onUpdate:formData": {},
748
+ onSubmit: {},
236
749
  isView: { type: Boolean },
237
750
  cache: {}
238
751
  },
@@ -325,9 +838,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
325
838
  const onDrop = ({ dragNode, dropPosition, dropNode }) => {
326
839
  const list = columnsTree.value[0].children;
327
840
  const fromIndex = list.findIndex((e) => e.value === dragNode.value);
841
+ const dragItem = list[fromIndex];
328
842
  list.splice(fromIndex, 1);
329
- const toIndex = list.findIndex((e) => e.value === dropNode.value) + dropPosition;
330
- list.splice(toIndex, 0, dragNode);
843
+ const dropNodeIndex = list.findIndex((e) => e.value === dropNode.value);
844
+ const toIndex = dropPosition > 0 ? dropNodeIndex + dropPosition : dropNodeIndex;
845
+ list.splice(toIndex, 0, dragItem);
331
846
  };
332
847
  __expose({
333
848
  formInstance: formRef,
@@ -397,15 +912,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
397
912
  createVNode(unref(Form), mergeProps({
398
913
  ref_key: "formRef",
399
914
  ref: formRef,
400
- style: { "gap": "10px" },
915
+ style: {
916
+ gap: _ctx.gap,
917
+ display: "grid",
918
+ gridTemplateColumns: `repeat(auto-fill, ${_ctx.width})`,
919
+ "--td-comp-margin-xxl": 0
920
+ },
401
921
  rules: unref(rules)
402
922
  }, { ..._ctx.$attrs, ...formProps.value }), {
403
923
  default: withCtx(() => [
404
924
  createVNode(_sfc_main$2, {
405
925
  columns: unref(visibleColumns),
406
- "is-view": _ctx.isView
926
+ "is-view": _ctx.isView,
927
+ "is-search": ""
407
928
  }, null, 8, ["columns", "is-view"]),
408
- createVNode(unref(FormItem), { style: { "--ft-form-control-width": "220px" } }, {
929
+ createVNode(unref(FormItem), null, {
409
930
  default: withCtx(() => [
410
931
  createElementVNode("div", _hoisted_2, [
411
932
  _ctx.cache ? (openBlock(), createBlock(unref(Button), {
@@ -446,12 +967,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
446
967
  })
447
968
  ]),
448
969
  _: 1
449
- }, 16, ["rules"])
970
+ }, 16, ["style", "rules"])
450
971
  ], 64);
451
972
  };
452
973
  }
453
974
  });
454
975
  export {
455
976
  _sfc_main$1 as FtTdForm,
456
- _sfc_main as FtTdFormSearch
977
+ _sfc_main as FtTdFormSearch,
978
+ defineFormItem,
979
+ formRenderMap,
980
+ registerForm
457
981
  };