vue-form-craft 4.3.1 → 4.4.0

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.d.ts CHANGED
@@ -2,125 +2,14 @@ import { App } from 'vue';
2
2
  import { Component } from 'vue';
3
3
  import { ComponentOptionsMixin } from 'vue';
4
4
  import { ComponentProvideOptions } from 'vue';
5
- import { DeepReadonly } from 'vue';
6
5
  import { DefineComponent } from 'vue';
7
6
  import { ExtractPropTypes } from 'vue';
8
7
  import { FormValidationResult } from 'element-plus';
9
8
  import { PropType } from 'vue';
10
9
  import { PublicProps } from 'vue';
11
- import { Ref } from 'vue';
12
- import { ToRefs } from 'vue';
13
- import { UnwrapNestedRefs } from 'vue';
14
10
  import { VNode } from 'vue';
15
11
 
16
- export declare type $Global = {
17
- request?: (options: Record<string, any>) => Promise<Record<string, any>>;
18
- elements: Record<string, FormElement>;
19
- };
20
-
21
- declare type __VLS_WithTemplateSlots<T, S> = T & {
22
- new (): {
23
- $slots: S;
24
- };
25
- };
26
-
27
- declare const _default: {
28
- install: (app: App<Element>, options?: {
29
- request?: ((options: Record<string, any>) => Promise<Record<string, any>>) | undefined;
30
- extendElements?: Record<string, FormElement> | undefined;
31
- lang?: "en" | "zh" | undefined;
32
- } | undefined) => void;
33
- };
34
- export default _default;
35
-
36
- declare type FormChange = {
37
- target: string;
38
- value?: any;
39
- condition?: any;
40
- };
41
-
42
- export declare const FormDesign: DefineComponent<ExtractPropTypes< {
43
- modelValue: PropType<FormSchema>;
44
- schemaContext: {
45
- type: PropType<Record<string, any>>;
46
- default: () => {};
47
- };
48
- templates: {
49
- type: PropType<TemplateData>;
50
- };
51
- omitMenus: {
52
- type: PropType<string[]>;
53
- };
54
- }>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
55
- add: (element: FormElement) => void;
56
- save: () => void;
57
- onSave: () => void;
58
- }, string, PublicProps, Readonly<ExtractPropTypes< {
59
- modelValue: PropType<FormSchema>;
60
- schemaContext: {
61
- type: PropType<Record<string, any>>;
62
- default: () => {};
63
- };
64
- templates: {
65
- type: PropType<TemplateData>;
66
- };
67
- omitMenus: {
68
- type: PropType<string[]>;
69
- };
70
- }>> & Readonly<{
71
- onAdd?: ((element: FormElement) => any) | undefined;
72
- onSave?: (() => any) | undefined;
73
- onOnSave?: (() => any) | undefined;
74
- }>, {
75
- schemaContext: Record<string, any>;
76
- }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
77
-
78
- export declare type FormElement = {
79
- name: string;
80
- component: string | VNode | Component;
81
- icon: string | VNode | Component;
82
- type: 'assist' | 'layout' | 'basic' | 'highBasic';
83
- order: number;
84
- initialValues: Omit<FormItemType, 'name'>;
85
- modelName?: string;
86
- attrSchema: FormSchema;
87
- };
88
-
89
- export declare type FormInstance = DeepReadonly<UnwrapNestedRefs<FormInstanceSource>>;
90
-
91
- declare interface FormInstanceSource extends ToRefs<FormRenderProps> {
92
- formValues: Ref<Record<string, any>>;
93
- selectData: Record<string, Record<string, any>>;
94
- initialValues: Record<string, Record<string, any>>;
95
- context: Ref<Record<string, any>>;
96
- updateFormValues: (values: Record<string, any>) => void;
97
- updateSelectData: (key: string, value: Record<string, any>) => void;
98
- updateInitialValues: (values: Record<string, any>) => void;
99
- validate: () => FormValidationResult | undefined;
100
- resetFields: (names?: string[]) => void;
101
- submit: () => Promise<void>;
102
- }
103
-
104
- export declare interface FormItemType {
105
- label?: string;
106
- name: string;
107
- component: string;
108
- required?: boolean;
109
- props?: Record<string, any>;
110
- initialValue?: any;
111
- help?: string;
112
- children?: FormItemType[];
113
- hidden?: boolean | string;
114
- hideLabel?: boolean;
115
- designKey?: string;
116
- rules?: FormRule[];
117
- class?: any;
118
- style?: any;
119
- change?: FormChange[];
120
- dialog?: boolean;
121
- }
122
-
123
- export declare const FormRender: __VLS_WithTemplateSlots<DefineComponent<ExtractPropTypes< {
12
+ declare const __VLS_component: DefineComponent<ExtractPropTypes< {
124
13
  modelValue: PropType<Record<string, any>>;
125
14
  schema: {
126
15
  type: PropType<FormSchema>;
@@ -198,16 +87,17 @@ updateFormValues: (values: Record<string, any>) => void;
198
87
  updateSelectData: (key: string, value: Record<string, any>) => void;
199
88
  updateInitialValues: (values: Record<string, any>) => void;
200
89
  validate: () => FormValidationResult | undefined;
201
- resetFields: (names?: string[] | undefined) => void;
90
+ resetFields: (names?: string[]) => void;
202
91
  submit: () => Promise<void>;
203
92
  schema: {
204
93
  readonly labelWidth?: number | undefined;
205
- readonly labelAlign?: "top" | "left" | "right" | undefined;
94
+ readonly labelAlign?: ("top" | "left" | "right") | undefined;
206
95
  readonly labelSuffix?: string | undefined;
207
- readonly size?: "default" | "small" | "large" | undefined;
96
+ readonly size?: ("default" | "small" | "large") | undefined;
208
97
  readonly disabled?: boolean | undefined;
209
98
  readonly hideRequiredAsterisk?: boolean | undefined;
210
99
  readonly labelBold?: boolean | undefined;
100
+ readonly scrollToError?: boolean | undefined;
211
101
  readonly items: readonly {
212
102
  readonly label?: string | undefined;
213
103
  readonly name: string;
@@ -219,11 +109,11 @@ readonly [x: string]: any;
219
109
  readonly initialValue?: any;
220
110
  readonly help?: string | undefined;
221
111
  readonly children?: readonly any[] | undefined;
222
- readonly hidden?: string | boolean | undefined;
112
+ readonly hidden?: (boolean | string) | undefined;
223
113
  readonly hideLabel?: boolean | undefined;
224
114
  readonly designKey?: string | undefined;
225
115
  readonly rules?: readonly {
226
- readonly type: string;
116
+ readonly type: "email" | "url" | "custom" | string;
227
117
  readonly customReg?: string | undefined;
228
118
  readonly message?: string | undefined;
229
119
  readonly trigger: "blur" | "change";
@@ -266,9 +156,1157 @@ type: PropType<boolean>;
266
156
  };
267
157
  }>> & Readonly<{
268
158
  onOnFinish?: ((values: Record<string, any>) => any) | undefined;
269
- }>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>, {
159
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
160
+
161
+ declare function __VLS_template(): {
270
162
  default?(_: {}): any;
271
- }>;
163
+ };
164
+
165
+ declare type __VLS_WithTemplateSlots<T, S> = T & {
166
+ new (): {
167
+ $slots: S;
168
+ };
169
+ };
170
+
171
+ declare const _default: {
172
+ install: (app: App<Element>, options?: Options) => void;
173
+ };
174
+ export default _default;
175
+
176
+ declare type FormChange = {
177
+ target: string;
178
+ value?: any;
179
+ condition?: any;
180
+ };
181
+
182
+ export declare const FormDesign: DefineComponent<ExtractPropTypes< {
183
+ modelValue: PropType<FormSchema>;
184
+ schemaContext: {
185
+ type: PropType<Record<string, any>>;
186
+ default: () => {};
187
+ };
188
+ templates: {
189
+ type: PropType<TemplateData>;
190
+ default: () => ({
191
+ name: string;
192
+ schema: {
193
+ labelWidth: number;
194
+ labelAlign: "right";
195
+ size: "default";
196
+ items: ({
197
+ label: string;
198
+ component: string;
199
+ props: {
200
+ placeholder: string;
201
+ autosize?: undefined;
202
+ mode?: undefined;
203
+ options?: undefined;
204
+ optionType?: undefined;
205
+ space?: undefined;
206
+ labelKey?: undefined;
207
+ valueKey?: undefined;
208
+ api?: undefined;
209
+ width?: undefined;
210
+ height?: undefined;
211
+ action?: undefined;
212
+ fileTypes?: undefined;
213
+ size?: undefined;
214
+ uploadKey?: undefined;
215
+ dataPath?: undefined;
216
+ };
217
+ designKey: string;
218
+ name: string;
219
+ required: true;
220
+ } | {
221
+ label: string;
222
+ component: string;
223
+ props: {
224
+ autosize: {
225
+ minRows: number;
226
+ maxRows: number;
227
+ };
228
+ placeholder: string;
229
+ mode?: undefined;
230
+ options?: undefined;
231
+ optionType?: undefined;
232
+ space?: undefined;
233
+ labelKey?: undefined;
234
+ valueKey?: undefined;
235
+ api?: undefined;
236
+ width?: undefined;
237
+ height?: undefined;
238
+ action?: undefined;
239
+ fileTypes?: undefined;
240
+ size?: undefined;
241
+ uploadKey?: undefined;
242
+ dataPath?: undefined;
243
+ };
244
+ designKey: string;
245
+ name: string;
246
+ required?: undefined;
247
+ } | {
248
+ label: string;
249
+ component: string;
250
+ props: {
251
+ mode: string;
252
+ options: {
253
+ label: string;
254
+ value: string;
255
+ }[];
256
+ optionType: string;
257
+ space: number;
258
+ labelKey: string;
259
+ valueKey: string;
260
+ api: {
261
+ url: string;
262
+ dataPath: string;
263
+ method: string;
264
+ params: {};
265
+ data: {};
266
+ };
267
+ placeholder?: undefined;
268
+ autosize?: undefined;
269
+ width?: undefined;
270
+ height?: undefined;
271
+ action?: undefined;
272
+ fileTypes?: undefined;
273
+ size?: undefined;
274
+ uploadKey?: undefined;
275
+ dataPath?: undefined;
276
+ };
277
+ designKey: string;
278
+ name: string;
279
+ required: true;
280
+ } | {
281
+ label: string;
282
+ component: string;
283
+ props: {
284
+ mode: string;
285
+ options: {
286
+ name: string;
287
+ value: number;
288
+ }[];
289
+ optionType: string;
290
+ space: number;
291
+ labelKey: string;
292
+ valueKey: string;
293
+ placeholder?: undefined;
294
+ autosize?: undefined;
295
+ api?: undefined;
296
+ width?: undefined;
297
+ height?: undefined;
298
+ action?: undefined;
299
+ fileTypes?: undefined;
300
+ size?: undefined;
301
+ uploadKey?: undefined;
302
+ dataPath?: undefined;
303
+ };
304
+ designKey: string;
305
+ name: string;
306
+ required: true;
307
+ } | {
308
+ label: string;
309
+ component: string;
310
+ props: {
311
+ width: number;
312
+ height: number;
313
+ action: string;
314
+ fileTypes: string[];
315
+ size: number;
316
+ uploadKey: string;
317
+ dataPath: string;
318
+ placeholder?: undefined;
319
+ autosize?: undefined;
320
+ mode?: undefined;
321
+ options?: undefined;
322
+ optionType?: undefined;
323
+ space?: undefined;
324
+ labelKey?: undefined;
325
+ valueKey?: undefined;
326
+ api?: undefined;
327
+ };
328
+ designKey: string;
329
+ name: string;
330
+ required?: undefined;
331
+ } | {
332
+ label: string;
333
+ component: string;
334
+ designKey: string;
335
+ name: string;
336
+ required: true;
337
+ props?: undefined;
338
+ })[];
339
+ };
340
+ id: string;
341
+ } | {
342
+ name: string;
343
+ schema: {
344
+ labelWidth: number;
345
+ labelAlign: "right";
346
+ size: "default";
347
+ items: ({
348
+ label: string;
349
+ name: string;
350
+ component: string;
351
+ props: {
352
+ 'inline-prompt': boolean;
353
+ mode?: undefined;
354
+ };
355
+ designKey: string;
356
+ change: {
357
+ target: string;
358
+ condition: string;
359
+ value: number;
360
+ }[];
361
+ children?: undefined;
362
+ } | {
363
+ label: string;
364
+ component: string;
365
+ children: ({
366
+ label: string;
367
+ component: string;
368
+ props: {
369
+ placeholder: string;
370
+ 'inline-prompt'?: undefined;
371
+ 'active-value'?: undefined;
372
+ 'inactive-value'?: undefined;
373
+ };
374
+ designKey: string;
375
+ name: string;
376
+ change: {
377
+ target: string;
378
+ condition: string;
379
+ value: number;
380
+ }[];
381
+ } | {
382
+ label: string;
383
+ component: string;
384
+ props: {
385
+ placeholder: string;
386
+ 'inline-prompt'?: undefined;
387
+ 'active-value'?: undefined;
388
+ 'inactive-value'?: undefined;
389
+ };
390
+ designKey: string;
391
+ name: string;
392
+ change?: undefined;
393
+ } | {
394
+ label: string;
395
+ component: string;
396
+ designKey: string;
397
+ name: string;
398
+ props: {
399
+ 'inline-prompt': boolean;
400
+ 'active-value': number;
401
+ 'inactive-value': number;
402
+ placeholder?: undefined;
403
+ };
404
+ change?: undefined;
405
+ })[];
406
+ props: {
407
+ mode: string;
408
+ 'inline-prompt'?: undefined;
409
+ };
410
+ designKey: string;
411
+ name: string;
412
+ change?: undefined;
413
+ })[];
414
+ };
415
+ id: string;
416
+ } | {
417
+ name: string;
418
+ schema: {
419
+ labelWidth: number;
420
+ labelAlign: "right";
421
+ size: "default";
422
+ items: ({
423
+ label: string;
424
+ component: string;
425
+ props: {
426
+ max: number;
427
+ 'allow-half': boolean;
428
+ autocomplete?: undefined;
429
+ showWordLimit?: undefined;
430
+ type?: undefined;
431
+ autosize?: undefined;
432
+ placeholder?: undefined;
433
+ };
434
+ designKey: string;
435
+ name: string;
436
+ required: true;
437
+ hidden?: undefined;
438
+ } | {
439
+ label: string;
440
+ component: string;
441
+ props: {
442
+ autocomplete: string;
443
+ showWordLimit: boolean;
444
+ type: string;
445
+ autosize: {
446
+ minRows: number;
447
+ maxRows: number;
448
+ };
449
+ placeholder: string;
450
+ max?: undefined;
451
+ 'allow-half'?: undefined;
452
+ };
453
+ designKey: string;
454
+ name: string;
455
+ hidden: string;
456
+ required?: undefined;
457
+ })[];
458
+ };
459
+ id: string;
460
+ } | {
461
+ name: string;
462
+ schema: {
463
+ labelWidth: number;
464
+ labelAlign: "right";
465
+ size: "default";
466
+ items: ({
467
+ label: string;
468
+ component: string;
469
+ props: {
470
+ mode: string;
471
+ options: {
472
+ name: string;
473
+ id: number;
474
+ }[];
475
+ labelKey: string;
476
+ valueKey: string;
477
+ optionType: string;
478
+ space: number;
479
+ placeholder?: undefined;
480
+ api?: undefined;
481
+ direction?: undefined;
482
+ };
483
+ name: string;
484
+ required: true;
485
+ designKey: string;
486
+ hidden?: undefined;
487
+ } | {
488
+ label: string;
489
+ component: string;
490
+ props: {
491
+ mode: string;
492
+ placeholder: string;
493
+ labelKey: string;
494
+ valueKey: string;
495
+ api: {
496
+ url: string;
497
+ method: string;
498
+ params: {
499
+ filters: {
500
+ category: string;
501
+ };
502
+ };
503
+ dataPath: string;
504
+ };
505
+ optionType: string;
506
+ direction: string;
507
+ space: number;
508
+ options?: undefined;
509
+ };
510
+ name: string;
511
+ required: true;
512
+ hidden: string;
513
+ designKey: string;
514
+ })[];
515
+ };
516
+ id: string;
517
+ } | {
518
+ name: string;
519
+ schema: {
520
+ labelWidth: number;
521
+ labelAlign: "right";
522
+ size: "default";
523
+ items: ({
524
+ label: string;
525
+ component: string;
526
+ props: {
527
+ mode: string;
528
+ options: {
529
+ name: string;
530
+ id: string;
531
+ price: number;
532
+ }[];
533
+ placeholder: string;
534
+ labelKey: string;
535
+ valueKey: string;
536
+ min?: undefined;
537
+ max?: undefined;
538
+ step?: undefined;
539
+ unit?: undefined;
540
+ disabled?: undefined;
541
+ controlsPosition?: undefined;
542
+ };
543
+ designKey: string;
544
+ name: string;
545
+ change: {
546
+ target: string;
547
+ value: string;
548
+ }[];
549
+ } | {
550
+ label: string;
551
+ component: string;
552
+ designKey: string;
553
+ name: string;
554
+ props: {
555
+ min: number;
556
+ max: number;
557
+ step: number;
558
+ unit: string;
559
+ disabled: boolean;
560
+ controlsPosition: string;
561
+ mode?: undefined;
562
+ options?: undefined;
563
+ placeholder?: undefined;
564
+ labelKey?: undefined;
565
+ valueKey?: undefined;
566
+ };
567
+ change?: undefined;
568
+ })[];
569
+ };
570
+ id: string;
571
+ } | {
572
+ name: string;
573
+ schema: {
574
+ labelWidth: number;
575
+ labelAlign: "right";
576
+ size: "default";
577
+ items: ({
578
+ label: string;
579
+ component: string;
580
+ props: {
581
+ mode: string;
582
+ options: {
583
+ label: string;
584
+ value: string;
585
+ vv: string;
586
+ }[];
587
+ labelKey: string;
588
+ valueKey: string;
589
+ optionType: string;
590
+ direction: string;
591
+ space: number;
592
+ placeholder?: undefined;
593
+ };
594
+ designKey: string;
595
+ name: string;
596
+ change: {
597
+ target: string;
598
+ value: string;
599
+ }[];
600
+ } | {
601
+ label: string;
602
+ component: string;
603
+ props: {
604
+ placeholder: string;
605
+ mode?: undefined;
606
+ options?: undefined;
607
+ labelKey?: undefined;
608
+ valueKey?: undefined;
609
+ optionType?: undefined;
610
+ direction?: undefined;
611
+ space?: undefined;
612
+ };
613
+ designKey: string;
614
+ name: string;
615
+ change?: undefined;
616
+ })[];
617
+ };
618
+ id: string;
619
+ } | {
620
+ name: string;
621
+ schema: {
622
+ labelWidth: number;
623
+ labelAlign: "right";
624
+ size: "default";
625
+ items: {
626
+ label: string;
627
+ component: string;
628
+ props: {
629
+ placeholder: string;
630
+ };
631
+ designKey: string;
632
+ name: string;
633
+ }[];
634
+ };
635
+ id: string;
636
+ } | {
637
+ name: string;
638
+ schema: {
639
+ labelWidth: number;
640
+ labelAlign: "right";
641
+ size: "default";
642
+ items: ({
643
+ label: string;
644
+ component: string;
645
+ props: {
646
+ placeholder: string;
647
+ 'inline-prompt'?: undefined;
648
+ header?: undefined;
649
+ };
650
+ designKey: string;
651
+ name: string;
652
+ children?: undefined;
653
+ } | {
654
+ label: string;
655
+ component: string;
656
+ props: {
657
+ 'inline-prompt': boolean;
658
+ placeholder?: undefined;
659
+ header?: undefined;
660
+ };
661
+ designKey: string;
662
+ name: string;
663
+ children?: undefined;
664
+ } | {
665
+ component: string;
666
+ children: ({
667
+ label: string;
668
+ component: string;
669
+ props: {
670
+ placeholder: string;
671
+ mode?: undefined;
672
+ options?: undefined;
673
+ labelKey?: undefined;
674
+ valueKey?: undefined;
675
+ optionType?: undefined;
676
+ direction?: undefined;
677
+ space?: undefined;
678
+ };
679
+ designKey: string;
680
+ name: string;
681
+ } | {
682
+ label: string;
683
+ component: string;
684
+ props: {
685
+ mode: string;
686
+ options: {
687
+ label: string;
688
+ value: string;
689
+ }[];
690
+ labelKey: string;
691
+ valueKey: string;
692
+ optionType: string;
693
+ direction: string;
694
+ space: number;
695
+ placeholder?: undefined;
696
+ };
697
+ designKey: string;
698
+ name: string;
699
+ })[];
700
+ props: {
701
+ header: string;
702
+ placeholder?: undefined;
703
+ 'inline-prompt'?: undefined;
704
+ };
705
+ designKey: string;
706
+ name: string;
707
+ label?: undefined;
708
+ })[];
709
+ };
710
+ id: string;
711
+ })[];
712
+ };
713
+ omitMenus: {
714
+ type: PropType<string[]>;
715
+ default: () => never[];
716
+ };
717
+ }>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
718
+ add: (element: FormElement) => void;
719
+ save: () => void;
720
+ onSave: () => void;
721
+ }, string, PublicProps, Readonly<ExtractPropTypes< {
722
+ modelValue: PropType<FormSchema>;
723
+ schemaContext: {
724
+ type: PropType<Record<string, any>>;
725
+ default: () => {};
726
+ };
727
+ templates: {
728
+ type: PropType<TemplateData>;
729
+ default: () => ({
730
+ name: string;
731
+ schema: {
732
+ labelWidth: number;
733
+ labelAlign: "right";
734
+ size: "default";
735
+ items: ({
736
+ label: string;
737
+ component: string;
738
+ props: {
739
+ placeholder: string;
740
+ autosize?: undefined;
741
+ mode?: undefined;
742
+ options?: undefined;
743
+ optionType?: undefined;
744
+ space?: undefined;
745
+ labelKey?: undefined;
746
+ valueKey?: undefined;
747
+ api?: undefined;
748
+ width?: undefined;
749
+ height?: undefined;
750
+ action?: undefined;
751
+ fileTypes?: undefined;
752
+ size?: undefined;
753
+ uploadKey?: undefined;
754
+ dataPath?: undefined;
755
+ };
756
+ designKey: string;
757
+ name: string;
758
+ required: true;
759
+ } | {
760
+ label: string;
761
+ component: string;
762
+ props: {
763
+ autosize: {
764
+ minRows: number;
765
+ maxRows: number;
766
+ };
767
+ placeholder: string;
768
+ mode?: undefined;
769
+ options?: undefined;
770
+ optionType?: undefined;
771
+ space?: undefined;
772
+ labelKey?: undefined;
773
+ valueKey?: undefined;
774
+ api?: undefined;
775
+ width?: undefined;
776
+ height?: undefined;
777
+ action?: undefined;
778
+ fileTypes?: undefined;
779
+ size?: undefined;
780
+ uploadKey?: undefined;
781
+ dataPath?: undefined;
782
+ };
783
+ designKey: string;
784
+ name: string;
785
+ required?: undefined;
786
+ } | {
787
+ label: string;
788
+ component: string;
789
+ props: {
790
+ mode: string;
791
+ options: {
792
+ label: string;
793
+ value: string;
794
+ }[];
795
+ optionType: string;
796
+ space: number;
797
+ labelKey: string;
798
+ valueKey: string;
799
+ api: {
800
+ url: string;
801
+ dataPath: string;
802
+ method: string;
803
+ params: {};
804
+ data: {};
805
+ };
806
+ placeholder?: undefined;
807
+ autosize?: undefined;
808
+ width?: undefined;
809
+ height?: undefined;
810
+ action?: undefined;
811
+ fileTypes?: undefined;
812
+ size?: undefined;
813
+ uploadKey?: undefined;
814
+ dataPath?: undefined;
815
+ };
816
+ designKey: string;
817
+ name: string;
818
+ required: true;
819
+ } | {
820
+ label: string;
821
+ component: string;
822
+ props: {
823
+ mode: string;
824
+ options: {
825
+ name: string;
826
+ value: number;
827
+ }[];
828
+ optionType: string;
829
+ space: number;
830
+ labelKey: string;
831
+ valueKey: string;
832
+ placeholder?: undefined;
833
+ autosize?: undefined;
834
+ api?: undefined;
835
+ width?: undefined;
836
+ height?: undefined;
837
+ action?: undefined;
838
+ fileTypes?: undefined;
839
+ size?: undefined;
840
+ uploadKey?: undefined;
841
+ dataPath?: undefined;
842
+ };
843
+ designKey: string;
844
+ name: string;
845
+ required: true;
846
+ } | {
847
+ label: string;
848
+ component: string;
849
+ props: {
850
+ width: number;
851
+ height: number;
852
+ action: string;
853
+ fileTypes: string[];
854
+ size: number;
855
+ uploadKey: string;
856
+ dataPath: string;
857
+ placeholder?: undefined;
858
+ autosize?: undefined;
859
+ mode?: undefined;
860
+ options?: undefined;
861
+ optionType?: undefined;
862
+ space?: undefined;
863
+ labelKey?: undefined;
864
+ valueKey?: undefined;
865
+ api?: undefined;
866
+ };
867
+ designKey: string;
868
+ name: string;
869
+ required?: undefined;
870
+ } | {
871
+ label: string;
872
+ component: string;
873
+ designKey: string;
874
+ name: string;
875
+ required: true;
876
+ props?: undefined;
877
+ })[];
878
+ };
879
+ id: string;
880
+ } | {
881
+ name: string;
882
+ schema: {
883
+ labelWidth: number;
884
+ labelAlign: "right";
885
+ size: "default";
886
+ items: ({
887
+ label: string;
888
+ name: string;
889
+ component: string;
890
+ props: {
891
+ 'inline-prompt': boolean;
892
+ mode?: undefined;
893
+ };
894
+ designKey: string;
895
+ change: {
896
+ target: string;
897
+ condition: string;
898
+ value: number;
899
+ }[];
900
+ children?: undefined;
901
+ } | {
902
+ label: string;
903
+ component: string;
904
+ children: ({
905
+ label: string;
906
+ component: string;
907
+ props: {
908
+ placeholder: string;
909
+ 'inline-prompt'?: undefined;
910
+ 'active-value'?: undefined;
911
+ 'inactive-value'?: undefined;
912
+ };
913
+ designKey: string;
914
+ name: string;
915
+ change: {
916
+ target: string;
917
+ condition: string;
918
+ value: number;
919
+ }[];
920
+ } | {
921
+ label: string;
922
+ component: string;
923
+ props: {
924
+ placeholder: string;
925
+ 'inline-prompt'?: undefined;
926
+ 'active-value'?: undefined;
927
+ 'inactive-value'?: undefined;
928
+ };
929
+ designKey: string;
930
+ name: string;
931
+ change?: undefined;
932
+ } | {
933
+ label: string;
934
+ component: string;
935
+ designKey: string;
936
+ name: string;
937
+ props: {
938
+ 'inline-prompt': boolean;
939
+ 'active-value': number;
940
+ 'inactive-value': number;
941
+ placeholder?: undefined;
942
+ };
943
+ change?: undefined;
944
+ })[];
945
+ props: {
946
+ mode: string;
947
+ 'inline-prompt'?: undefined;
948
+ };
949
+ designKey: string;
950
+ name: string;
951
+ change?: undefined;
952
+ })[];
953
+ };
954
+ id: string;
955
+ } | {
956
+ name: string;
957
+ schema: {
958
+ labelWidth: number;
959
+ labelAlign: "right";
960
+ size: "default";
961
+ items: ({
962
+ label: string;
963
+ component: string;
964
+ props: {
965
+ max: number;
966
+ 'allow-half': boolean;
967
+ autocomplete?: undefined;
968
+ showWordLimit?: undefined;
969
+ type?: undefined;
970
+ autosize?: undefined;
971
+ placeholder?: undefined;
972
+ };
973
+ designKey: string;
974
+ name: string;
975
+ required: true;
976
+ hidden?: undefined;
977
+ } | {
978
+ label: string;
979
+ component: string;
980
+ props: {
981
+ autocomplete: string;
982
+ showWordLimit: boolean;
983
+ type: string;
984
+ autosize: {
985
+ minRows: number;
986
+ maxRows: number;
987
+ };
988
+ placeholder: string;
989
+ max?: undefined;
990
+ 'allow-half'?: undefined;
991
+ };
992
+ designKey: string;
993
+ name: string;
994
+ hidden: string;
995
+ required?: undefined;
996
+ })[];
997
+ };
998
+ id: string;
999
+ } | {
1000
+ name: string;
1001
+ schema: {
1002
+ labelWidth: number;
1003
+ labelAlign: "right";
1004
+ size: "default";
1005
+ items: ({
1006
+ label: string;
1007
+ component: string;
1008
+ props: {
1009
+ mode: string;
1010
+ options: {
1011
+ name: string;
1012
+ id: number;
1013
+ }[];
1014
+ labelKey: string;
1015
+ valueKey: string;
1016
+ optionType: string;
1017
+ space: number;
1018
+ placeholder?: undefined;
1019
+ api?: undefined;
1020
+ direction?: undefined;
1021
+ };
1022
+ name: string;
1023
+ required: true;
1024
+ designKey: string;
1025
+ hidden?: undefined;
1026
+ } | {
1027
+ label: string;
1028
+ component: string;
1029
+ props: {
1030
+ mode: string;
1031
+ placeholder: string;
1032
+ labelKey: string;
1033
+ valueKey: string;
1034
+ api: {
1035
+ url: string;
1036
+ method: string;
1037
+ params: {
1038
+ filters: {
1039
+ category: string;
1040
+ };
1041
+ };
1042
+ dataPath: string;
1043
+ };
1044
+ optionType: string;
1045
+ direction: string;
1046
+ space: number;
1047
+ options?: undefined;
1048
+ };
1049
+ name: string;
1050
+ required: true;
1051
+ hidden: string;
1052
+ designKey: string;
1053
+ })[];
1054
+ };
1055
+ id: string;
1056
+ } | {
1057
+ name: string;
1058
+ schema: {
1059
+ labelWidth: number;
1060
+ labelAlign: "right";
1061
+ size: "default";
1062
+ items: ({
1063
+ label: string;
1064
+ component: string;
1065
+ props: {
1066
+ mode: string;
1067
+ options: {
1068
+ name: string;
1069
+ id: string;
1070
+ price: number;
1071
+ }[];
1072
+ placeholder: string;
1073
+ labelKey: string;
1074
+ valueKey: string;
1075
+ min?: undefined;
1076
+ max?: undefined;
1077
+ step?: undefined;
1078
+ unit?: undefined;
1079
+ disabled?: undefined;
1080
+ controlsPosition?: undefined;
1081
+ };
1082
+ designKey: string;
1083
+ name: string;
1084
+ change: {
1085
+ target: string;
1086
+ value: string;
1087
+ }[];
1088
+ } | {
1089
+ label: string;
1090
+ component: string;
1091
+ designKey: string;
1092
+ name: string;
1093
+ props: {
1094
+ min: number;
1095
+ max: number;
1096
+ step: number;
1097
+ unit: string;
1098
+ disabled: boolean;
1099
+ controlsPosition: string;
1100
+ mode?: undefined;
1101
+ options?: undefined;
1102
+ placeholder?: undefined;
1103
+ labelKey?: undefined;
1104
+ valueKey?: undefined;
1105
+ };
1106
+ change?: undefined;
1107
+ })[];
1108
+ };
1109
+ id: string;
1110
+ } | {
1111
+ name: string;
1112
+ schema: {
1113
+ labelWidth: number;
1114
+ labelAlign: "right";
1115
+ size: "default";
1116
+ items: ({
1117
+ label: string;
1118
+ component: string;
1119
+ props: {
1120
+ mode: string;
1121
+ options: {
1122
+ label: string;
1123
+ value: string;
1124
+ vv: string;
1125
+ }[];
1126
+ labelKey: string;
1127
+ valueKey: string;
1128
+ optionType: string;
1129
+ direction: string;
1130
+ space: number;
1131
+ placeholder?: undefined;
1132
+ };
1133
+ designKey: string;
1134
+ name: string;
1135
+ change: {
1136
+ target: string;
1137
+ value: string;
1138
+ }[];
1139
+ } | {
1140
+ label: string;
1141
+ component: string;
1142
+ props: {
1143
+ placeholder: string;
1144
+ mode?: undefined;
1145
+ options?: undefined;
1146
+ labelKey?: undefined;
1147
+ valueKey?: undefined;
1148
+ optionType?: undefined;
1149
+ direction?: undefined;
1150
+ space?: undefined;
1151
+ };
1152
+ designKey: string;
1153
+ name: string;
1154
+ change?: undefined;
1155
+ })[];
1156
+ };
1157
+ id: string;
1158
+ } | {
1159
+ name: string;
1160
+ schema: {
1161
+ labelWidth: number;
1162
+ labelAlign: "right";
1163
+ size: "default";
1164
+ items: {
1165
+ label: string;
1166
+ component: string;
1167
+ props: {
1168
+ placeholder: string;
1169
+ };
1170
+ designKey: string;
1171
+ name: string;
1172
+ }[];
1173
+ };
1174
+ id: string;
1175
+ } | {
1176
+ name: string;
1177
+ schema: {
1178
+ labelWidth: number;
1179
+ labelAlign: "right";
1180
+ size: "default";
1181
+ items: ({
1182
+ label: string;
1183
+ component: string;
1184
+ props: {
1185
+ placeholder: string;
1186
+ 'inline-prompt'?: undefined;
1187
+ header?: undefined;
1188
+ };
1189
+ designKey: string;
1190
+ name: string;
1191
+ children?: undefined;
1192
+ } | {
1193
+ label: string;
1194
+ component: string;
1195
+ props: {
1196
+ 'inline-prompt': boolean;
1197
+ placeholder?: undefined;
1198
+ header?: undefined;
1199
+ };
1200
+ designKey: string;
1201
+ name: string;
1202
+ children?: undefined;
1203
+ } | {
1204
+ component: string;
1205
+ children: ({
1206
+ label: string;
1207
+ component: string;
1208
+ props: {
1209
+ placeholder: string;
1210
+ mode?: undefined;
1211
+ options?: undefined;
1212
+ labelKey?: undefined;
1213
+ valueKey?: undefined;
1214
+ optionType?: undefined;
1215
+ direction?: undefined;
1216
+ space?: undefined;
1217
+ };
1218
+ designKey: string;
1219
+ name: string;
1220
+ } | {
1221
+ label: string;
1222
+ component: string;
1223
+ props: {
1224
+ mode: string;
1225
+ options: {
1226
+ label: string;
1227
+ value: string;
1228
+ }[];
1229
+ labelKey: string;
1230
+ valueKey: string;
1231
+ optionType: string;
1232
+ direction: string;
1233
+ space: number;
1234
+ placeholder?: undefined;
1235
+ };
1236
+ designKey: string;
1237
+ name: string;
1238
+ })[];
1239
+ props: {
1240
+ header: string;
1241
+ placeholder?: undefined;
1242
+ 'inline-prompt'?: undefined;
1243
+ };
1244
+ designKey: string;
1245
+ name: string;
1246
+ label?: undefined;
1247
+ })[];
1248
+ };
1249
+ id: string;
1250
+ })[];
1251
+ };
1252
+ omitMenus: {
1253
+ type: PropType<string[]>;
1254
+ default: () => never[];
1255
+ };
1256
+ }>> & Readonly<{
1257
+ onAdd?: ((element: FormElement) => any) | undefined;
1258
+ onSave?: (() => any) | undefined;
1259
+ onOnSave?: (() => any) | undefined;
1260
+ }>, {
1261
+ schemaContext: Record<string, any>;
1262
+ templates: TemplateData;
1263
+ omitMenus: string[];
1264
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
1265
+
1266
+ export declare type FormElement = {
1267
+ name: string;
1268
+ component: string | VNode | Component;
1269
+ icon: string | VNode | Component;
1270
+ type: 'assist' | 'layout' | 'basic' | 'highBasic';
1271
+ order: number;
1272
+ initialValues: Omit<FormItemType, 'name'>;
1273
+ modelName?: string;
1274
+ attrSchema: FormSchema;
1275
+ };
1276
+
1277
+ export declare interface FormInstance extends FormRenderProps {
1278
+ formValues: Record<string, any>;
1279
+ selectData: Record<string, Record<string, any>>;
1280
+ initialValues: Record<string, Record<string, any>>;
1281
+ context: Record<string, any>;
1282
+ updateFormValues: (values: Record<string, any>) => void;
1283
+ updateSelectData: (key: string, value: Record<string, any>) => void;
1284
+ updateInitialValues: (values: Record<string, any>) => void;
1285
+ validate: () => FormValidationResult | undefined;
1286
+ resetFields: (names?: string[]) => void;
1287
+ submit: () => Promise<void>;
1288
+ }
1289
+
1290
+ export declare interface FormItemType {
1291
+ label?: string;
1292
+ name: string;
1293
+ component: string;
1294
+ required?: boolean;
1295
+ props?: Record<string, any>;
1296
+ initialValue?: any;
1297
+ help?: string;
1298
+ children?: FormItemType[];
1299
+ hidden?: boolean | string;
1300
+ hideLabel?: boolean;
1301
+ designKey?: string;
1302
+ rules?: FormRule[];
1303
+ class?: any;
1304
+ style?: any;
1305
+ change?: FormChange[];
1306
+ dialog?: boolean;
1307
+ }
1308
+
1309
+ export declare const FormRender: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
272
1310
 
273
1311
  declare interface FormRenderProps {
274
1312
  schema: FormSchema;
@@ -293,15 +1331,90 @@ export declare type FormSchema = {
293
1331
  disabled?: boolean;
294
1332
  hideRequiredAsterisk?: boolean;
295
1333
  labelBold?: boolean;
1334
+ scrollToError?: boolean;
296
1335
  items: FormItemType[];
297
1336
  };
298
1337
 
1338
+ declare type Options = {
1339
+ request?: (options: Record<string, any>) => Promise<Record<string, any>>;
1340
+ extendElements?: Record<string, FormElement>;
1341
+ lang?: 'zh' | 'en';
1342
+ };
1343
+
299
1344
  export declare type TemplateData = {
300
1345
  name: string;
301
1346
  schema: FormSchema;
302
1347
  id?: string;
303
1348
  }[];
304
1349
 
305
- export declare const useFormInstance: () => FormInstance;
1350
+ export declare const useFormInstance: () => {
1351
+ readonly formValues: {
1352
+ readonly [x: string]: any;
1353
+ };
1354
+ readonly selectData: {
1355
+ readonly [x: string]: {
1356
+ readonly [x: string]: any;
1357
+ };
1358
+ };
1359
+ readonly initialValues: {
1360
+ readonly [x: string]: {
1361
+ readonly [x: string]: any;
1362
+ };
1363
+ };
1364
+ readonly context: {
1365
+ readonly [x: string]: any;
1366
+ };
1367
+ readonly updateFormValues: (values: Record<string, any>) => void;
1368
+ readonly updateSelectData: (key: string, value: Record<string, any>) => void;
1369
+ readonly updateInitialValues: (values: Record<string, any>) => void;
1370
+ readonly validate: () => FormValidationResult | undefined;
1371
+ readonly resetFields: (names?: string[]) => void;
1372
+ readonly submit: () => Promise<void>;
1373
+ readonly schema: {
1374
+ readonly labelWidth?: number | undefined;
1375
+ readonly labelAlign?: ("top" | "left" | "right") | undefined;
1376
+ readonly labelSuffix?: string | undefined;
1377
+ readonly size?: ("default" | "small" | "large") | undefined;
1378
+ readonly disabled?: boolean | undefined;
1379
+ readonly hideRequiredAsterisk?: boolean | undefined;
1380
+ readonly labelBold?: boolean | undefined;
1381
+ readonly scrollToError?: boolean | undefined;
1382
+ readonly items: readonly {
1383
+ readonly label?: string | undefined;
1384
+ readonly name: string;
1385
+ readonly component: string;
1386
+ readonly required?: boolean | undefined;
1387
+ readonly props?: {
1388
+ readonly [x: string]: any;
1389
+ } | undefined;
1390
+ readonly initialValue?: any;
1391
+ readonly help?: string | undefined;
1392
+ readonly children?: readonly any[] | undefined;
1393
+ readonly hidden?: (boolean | string) | undefined;
1394
+ readonly hideLabel?: boolean | undefined;
1395
+ readonly designKey?: string | undefined;
1396
+ readonly rules?: readonly {
1397
+ readonly type: "email" | "url" | "custom" | string;
1398
+ readonly customReg?: string | undefined;
1399
+ readonly message?: string | undefined;
1400
+ readonly trigger: "blur" | "change";
1401
+ }[] | undefined;
1402
+ readonly class?: any;
1403
+ readonly style?: any;
1404
+ readonly change?: readonly {
1405
+ readonly target: string;
1406
+ readonly value?: any;
1407
+ readonly condition?: any;
1408
+ }[] | undefined;
1409
+ readonly dialog?: boolean | undefined;
1410
+ }[];
1411
+ };
1412
+ readonly schemaContext?: {
1413
+ readonly [x: string]: any;
1414
+ } | undefined;
1415
+ readonly design?: boolean | undefined;
1416
+ readonly footer?: boolean | undefined;
1417
+ readonly read?: boolean | undefined;
1418
+ };
306
1419
 
307
1420
  export { }