sy-form-components 0.2.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/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @sy/form-components
2
+
3
+ SY 表单组件库 2.0 —— AI-First + 测试驱动的企业级表单解决方案。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @sy/form-components
9
+ # 或
10
+ pnpm add @sy/form-components
11
+ ```
12
+
13
+ ## 使用
14
+
15
+ ```tsx
16
+ import { FormRenderer } from '@sy/form-components';
17
+ ```
18
+
19
+ ## Tailwind CSS 预设
20
+
21
+ 组件库提供 Tailwind CSS 预设,可在项目中引入:
22
+
23
+ ```js
24
+ // tailwind.config.js
25
+ const formPreset = require('@sy/form-components/tailwind-preset');
26
+
27
+ module.exports = {
28
+ presets: [formPreset],
29
+ // ...
30
+ };
31
+ ```
32
+
33
+ ## Peer Dependencies
34
+
35
+ - React >= 18.0.0
36
+ - React DOM >= 18.0.0
37
+
38
+ ## License
39
+
40
+ MIT
@@ -0,0 +1,655 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ /** 字段行为状态 */
6
+ type FieldBehavior = 'NORMAL' | 'READONLY' | 'DISABLED' | 'HIDDEN';
7
+ /** 校验规则 */
8
+ interface ValidationRule {
9
+ required?: boolean;
10
+ message?: string;
11
+ min?: number;
12
+ max?: number;
13
+ pattern?: RegExp | string;
14
+ validator?: (value: any) => Promise<void> | void;
15
+ }
16
+ /** 字段声明(schema 中的每个字段定义) */
17
+ interface FieldDefinition {
18
+ fieldId: string;
19
+ componentName: string;
20
+ label: string;
21
+ required?: boolean;
22
+ rules?: ValidationRule[];
23
+ behavior?: FieldBehavior;
24
+ placeholder?: string;
25
+ tips?: string;
26
+ defaultValue?: any;
27
+ defaultValueType?: 'static' | 'expression';
28
+ defaultValueExpression?: string;
29
+ [key: string]: any;
30
+ }
31
+ /** 表单 Schema 定义 */
32
+ interface FormSchema {
33
+ formMeta: {
34
+ formUuid: string;
35
+ appType: string;
36
+ title: string;
37
+ };
38
+ fields: FieldDefinition[];
39
+ }
40
+ interface RuntimeResponse<T = any> {
41
+ code?: number;
42
+ success?: boolean;
43
+ data?: T;
44
+ result?: T;
45
+ message?: string;
46
+ error?: string;
47
+ }
48
+ interface RuntimeRequestConfig {
49
+ url: string;
50
+ method?: string;
51
+ params?: Record<string, any>;
52
+ data?: any;
53
+ headers?: Record<string, string>;
54
+ responseType?: 'json' | 'blob';
55
+ }
56
+ interface FormRuntimeApi {
57
+ request: <T = any>(config: RuntimeRequestConfig) => Promise<RuntimeResponse<T> | Blob>;
58
+ uploadFile: (file: File, bucketName?: string, onProgress?: (percent: number) => void) => Promise<AttachmentItem>;
59
+ deleteFile: (objectName: string, bucketName?: string) => Promise<{
60
+ success: boolean;
61
+ }>;
62
+ createDownloadTicket: (bucketName: string, objectName: string, fileName?: string) => Promise<any>;
63
+ createFileAccessTicket: (bucketName: string, objectName: string, fileName?: string, purpose?: 'download' | 'preview' | 'onlyoffice') => Promise<any>;
64
+ getUserById: (id: string) => Promise<any>;
65
+ getUserList: (params?: Record<string, any>) => Promise<any[]>;
66
+ getDepartmentRoots: () => Promise<any[]>;
67
+ getDepartmentChildren: (parentId: string) => Promise<any[]>;
68
+ getDepartmentParentDepartments: (id: string) => Promise<any[]>;
69
+ getDepartmentMembers: (id: string) => Promise<any[]>;
70
+ getChinaDivisions: (parentAdcode?: string) => Promise<any[]>;
71
+ advancedSearch: (params: Record<string, any>) => Promise<any>;
72
+ getDingTalkSignature: (url: string) => Promise<any>;
73
+ submitFormData: (payload: Record<string, any>) => Promise<any>;
74
+ updateFormData: (payload: Record<string, any>) => Promise<any>;
75
+ }
76
+ type FormRuntimeApiConfig = Partial<FormRuntimeApi> & {
77
+ baseUrl?: string;
78
+ };
79
+ /** 表单引擎配置 */
80
+ interface FormEngineConfig {
81
+ mode: 'submit' | 'edit' | 'readonly';
82
+ formUuid: string;
83
+ appType: string;
84
+ formInstanceId?: string;
85
+ permissions?: {
86
+ fieldPermissions: Record<string, FieldBehavior>;
87
+ operations: string[];
88
+ };
89
+ submit?: {
90
+ beforeSubmit?: (values: Record<string, any>) => Promise<boolean | void>;
91
+ afterSubmit?: (response: any) => Promise<void>;
92
+ submitSuccessMode?: 'redirect' | 'stay' | 'callback';
93
+ redirectUrl?: string;
94
+ };
95
+ api?: FormRuntimeApiConfig;
96
+ effects?: FormEffect[];
97
+ }
98
+ /** 字段联动效果 */
99
+ interface FormEffect {
100
+ when: {
101
+ field: string;
102
+ operator: 'eq' | 'ne' | 'in' | 'changed';
103
+ value?: any;
104
+ };
105
+ then: Array<{
106
+ field: string;
107
+ action: 'show' | 'hide' | 'enable' | 'disable' | 'setValue';
108
+ value?: any;
109
+ }>;
110
+ }
111
+ /** 基础字段组件 Props */
112
+ interface BaseFieldProps {
113
+ fieldId: string;
114
+ label: string;
115
+ behavior?: FieldBehavior;
116
+ required?: boolean;
117
+ rules?: ValidationRule[];
118
+ placeholder?: string;
119
+ tips?: string;
120
+ className?: string;
121
+ labelClassName?: string;
122
+ inputClassName?: string;
123
+ tipsClassName?: string;
124
+ readonlyClassName?: string;
125
+ onChange?: (value: any) => void;
126
+ onBlur?: (value: any) => void;
127
+ }
128
+ /** TextField 专用 Props */
129
+ interface TextFieldProps extends BaseFieldProps {
130
+ defaultValue?: string;
131
+ maxLength?: number;
132
+ }
133
+ /** NumberField 专用 Props */
134
+ interface NumberFieldProps extends BaseFieldProps {
135
+ defaultValue?: number | null;
136
+ min?: number;
137
+ max?: number;
138
+ step?: number;
139
+ precision?: number;
140
+ }
141
+ /** TextAreaField 专用 Props */
142
+ interface TextAreaFieldProps extends BaseFieldProps {
143
+ defaultValue?: string;
144
+ rows?: number;
145
+ maxLength?: number;
146
+ showCount?: boolean;
147
+ }
148
+ /** 选项类型 */
149
+ interface OptionItem {
150
+ value: string;
151
+ label: string;
152
+ }
153
+ /** SelectField 专用 Props */
154
+ interface SelectFieldProps extends BaseFieldProps {
155
+ defaultValue?: OptionItem | null;
156
+ options: OptionItem[];
157
+ allowClear?: boolean;
158
+ }
159
+ /** MultiSelectField 专用 Props */
160
+ interface MultiSelectFieldProps extends BaseFieldProps {
161
+ defaultValue?: OptionItem[];
162
+ options: OptionItem[];
163
+ maxCount?: number;
164
+ }
165
+ /** RadioField 专用 Props */
166
+ interface RadioFieldProps extends BaseFieldProps {
167
+ defaultValue?: OptionItem | null;
168
+ options: OptionItem[];
169
+ direction?: 'horizontal' | 'vertical';
170
+ }
171
+ /** CheckboxField 专用 Props */
172
+ interface CheckboxFieldProps extends BaseFieldProps {
173
+ defaultValue?: OptionItem[];
174
+ options: OptionItem[];
175
+ direction?: 'horizontal' | 'vertical';
176
+ }
177
+ /** DateField 专用 Props */
178
+ interface DateFieldProps extends BaseFieldProps {
179
+ defaultValue?: string;
180
+ dateFormat?: string;
181
+ showTime?: boolean;
182
+ }
183
+ /** CascadeDateField 专用 Props */
184
+ interface CascadeDateFieldProps extends BaseFieldProps {
185
+ defaultValue?: {
186
+ start: string;
187
+ end: string;
188
+ } | null;
189
+ dateFormat?: string;
190
+ startLabel?: string;
191
+ endLabel?: string;
192
+ }
193
+ /** 附件项 */
194
+ interface AttachmentItem {
195
+ url: string;
196
+ name: string;
197
+ id: string;
198
+ uid?: string;
199
+ status?: 'uploading' | 'done' | 'error';
200
+ objectName?: string;
201
+ bucketName?: string;
202
+ originalName?: string;
203
+ contentType?: string;
204
+ mimeType?: string;
205
+ extension?: string;
206
+ previewUrl?: string;
207
+ downloadUrl?: string;
208
+ size?: number;
209
+ percent?: number;
210
+ error?: string;
211
+ }
212
+ /** AttachmentField 专用 Props */
213
+ interface AttachmentFieldProps extends BaseFieldProps {
214
+ defaultValue?: AttachmentItem[];
215
+ maxCount?: number;
216
+ accept?: string;
217
+ maxSize?: number;
218
+ uploadAction?: string;
219
+ bucketName?: string;
220
+ multiple?: boolean;
221
+ allowedTypes?: string[];
222
+ }
223
+ /** ImageField 专用 Props */
224
+ interface ImageFieldProps extends BaseFieldProps {
225
+ defaultValue?: AttachmentItem[];
226
+ maxCount?: number;
227
+ accept?: string;
228
+ uploadAction?: string;
229
+ bucketName?: string;
230
+ multiple?: boolean;
231
+ maxSize?: number;
232
+ }
233
+ /** 子表单列定义 */
234
+ interface SubFormColumn {
235
+ fieldId: string;
236
+ label: string;
237
+ componentName: string;
238
+ [key: string]: any;
239
+ }
240
+ /** SubFormField 专用 Props */
241
+ interface SubFormFieldProps extends BaseFieldProps {
242
+ defaultValue?: Record<string, any>[];
243
+ columns: SubFormColumn[];
244
+ maxRows?: number;
245
+ minRows?: number;
246
+ }
247
+ /** 用户数据源项 */
248
+ interface UserItem {
249
+ id: string;
250
+ name: string;
251
+ value?: string;
252
+ label?: string;
253
+ username?: string;
254
+ jobNumber?: string;
255
+ avatar?: string;
256
+ departments?: Array<{
257
+ id?: string;
258
+ name?: string;
259
+ }>;
260
+ }
261
+ /** UserSelectField 专用 Props */
262
+ interface UserSelectFieldProps extends BaseFieldProps {
263
+ defaultValue?: UserItem[];
264
+ multiple?: boolean;
265
+ searchable?: boolean;
266
+ dataSource?: UserItem[];
267
+ }
268
+ /** 部门树节点 */
269
+ interface DepartmentTreeNode {
270
+ id: string;
271
+ name: string;
272
+ value?: string;
273
+ label?: string;
274
+ key?: string;
275
+ title?: string;
276
+ hasChildren?: boolean;
277
+ isLeaf?: boolean;
278
+ children?: DepartmentTreeNode[];
279
+ }
280
+ /** DepartmentSelectField 专用 Props */
281
+ interface DepartmentSelectFieldProps extends BaseFieldProps {
282
+ defaultValue?: {
283
+ id: string;
284
+ name: string;
285
+ }[];
286
+ multiple?: boolean;
287
+ treeData?: DepartmentTreeNode[];
288
+ }
289
+ interface CascadeSelectFieldProps extends BaseFieldProps {
290
+ defaultValue?: OptionItem[] | OptionItem[][];
291
+ options?: Array<OptionItem & {
292
+ children?: any[];
293
+ isLeaf?: boolean;
294
+ }>;
295
+ multiple?: boolean;
296
+ allowClear?: boolean;
297
+ changeOnSelect?: boolean;
298
+ showSearch?: boolean;
299
+ fieldNames?: {
300
+ label?: string;
301
+ value?: string;
302
+ children?: string;
303
+ };
304
+ }
305
+ interface AddressValue {
306
+ country?: OptionItem;
307
+ province?: OptionItem;
308
+ city?: OptionItem;
309
+ district?: OptionItem;
310
+ street?: OptionItem;
311
+ detail?: string;
312
+ fullAddress?: string;
313
+ }
314
+ interface AddressFieldProps extends BaseFieldProps {
315
+ defaultValue?: AddressValue;
316
+ mode?: 'province-city' | 'province-city-district' | 'province-city-district-street' | 'province-city-district-street-detail';
317
+ detailPlaceholder?: string;
318
+ allowClear?: boolean;
319
+ }
320
+ interface AssociationFormConfig {
321
+ appType: string;
322
+ formUuid: string;
323
+ mainFieldId: string;
324
+ selectorColumns?: Array<string | {
325
+ title?: string;
326
+ dataIndex: string;
327
+ key?: string;
328
+ }>;
329
+ dataFilterRules?: any[];
330
+ dataFilterConditionType?: 'AND' | 'OR';
331
+ }
332
+ interface AssociationValue {
333
+ label: string;
334
+ value: string | number;
335
+ record?: Record<string, any>;
336
+ }
337
+ interface AssociationFormFieldProps extends BaseFieldProps {
338
+ defaultValue?: AssociationValue | AssociationValue[];
339
+ associationForm?: AssociationFormConfig;
340
+ multiple?: boolean;
341
+ allowClear?: boolean;
342
+ showSearch?: boolean;
343
+ }
344
+ interface EditorFieldProps extends BaseFieldProps {
345
+ defaultValue?: string;
346
+ rows?: number;
347
+ maxLength?: number;
348
+ }
349
+ interface SerialNumberFieldProps extends BaseFieldProps {
350
+ defaultValue?: string;
351
+ serialNumberRule?: Array<Record<string, any>>;
352
+ }
353
+ interface LocationValue {
354
+ latitude: number;
355
+ longitude: number;
356
+ address?: string;
357
+ city?: string;
358
+ district?: string;
359
+ province?: string;
360
+ name?: string;
361
+ accuracy?: number;
362
+ source?: 'browser' | 'dingTalk' | 'manual';
363
+ time?: number;
364
+ }
365
+ interface LocationFieldProps extends BaseFieldProps {
366
+ defaultValue?: LocationValue;
367
+ allowClear?: boolean;
368
+ locateButtonText?: string;
369
+ clearButtonText?: string;
370
+ }
371
+ interface SignaturePoint {
372
+ x: number;
373
+ y: number;
374
+ t: number;
375
+ }
376
+ interface DigitalSignatureValue {
377
+ url?: string;
378
+ bucketName?: string;
379
+ objectName?: string;
380
+ previewUrl?: string;
381
+ points?: SignaturePoint[];
382
+ timestamp?: number;
383
+ hash?: string;
384
+ }
385
+ interface DigitalSignatureFieldProps extends BaseFieldProps {
386
+ defaultValue?: DigitalSignatureValue;
387
+ bucketName?: string;
388
+ allowClear?: boolean;
389
+ }
390
+ interface JSONFieldProps extends BaseFieldProps {
391
+ defaultValue?: any;
392
+ }
393
+
394
+ interface FormContextValue {
395
+ mode: 'submit' | 'edit' | 'readonly';
396
+ schema: FormSchema;
397
+ formData: Record<string, any>;
398
+ fieldErrors: Record<string, string>;
399
+ fieldBehaviors: Record<string, FieldBehavior>;
400
+ api: FormRuntimeApi;
401
+ config: Pick<FormEngineConfig, 'mode' | 'formUuid' | 'appType' | 'formInstanceId' | 'submit'>;
402
+ setFieldValue: (fieldId: string, value: any) => void;
403
+ getFieldValue: (fieldId: string) => any;
404
+ getFormData: () => Record<string, any>;
405
+ validateField: (fieldId: string) => Promise<boolean>;
406
+ validateAll: () => Promise<boolean>;
407
+ resetForm: () => void;
408
+ registerField: (fieldId: string) => void;
409
+ unregisterField: (fieldId: string) => void;
410
+ }
411
+ declare const FormContext: React.Context<FormContextValue | null>;
412
+ declare function useFormContext(): FormContextValue;
413
+
414
+ interface FormProviderProps {
415
+ schema: FormSchema;
416
+ config: FormEngineConfig;
417
+ initialValues?: Record<string, any>;
418
+ components?: Record<string, React__default.ComponentType<any>>;
419
+ children: React__default.ReactNode;
420
+ }
421
+ declare function FormProvider({ schema, config, initialValues, components, children, }: FormProviderProps): React__default.FunctionComponentElement<React__default.ProviderProps<FormContextValue | null>>;
422
+
423
+ interface ComponentRegistryContextValue {
424
+ registry: Record<string, React__default.ComponentType<any>>;
425
+ register: (name: string, component: React__default.ComponentType<any>) => void;
426
+ }
427
+ declare const ComponentRegistryContext: React__default.Context<ComponentRegistryContextValue | null>;
428
+ declare function ComponentRegistryProvider({ components, children, }: {
429
+ components: Record<string, React__default.ComponentType<any>>;
430
+ children: React__default.ReactNode;
431
+ }): React__default.ReactElement;
432
+ declare function useComponent(componentName: string): React__default.ComponentType<any> | null;
433
+
434
+ interface FormRendererProps {
435
+ className?: string;
436
+ fieldClassName?: string;
437
+ columns?: 1 | 2 | 3 | 4;
438
+ size?: 'compact' | 'default' | 'large';
439
+ }
440
+ declare function FormRenderer({ className, fieldClassName, columns, size, }: FormRendererProps): react_jsx_runtime.JSX.Element;
441
+
442
+ interface FormActionsProps {
443
+ className?: string;
444
+ submitText?: string;
445
+ resetText?: string;
446
+ showReset?: boolean;
447
+ onSubmit?: (values: Record<string, any>) => Promise<void>;
448
+ submitSuccessMode?: 'stay' | 'callback';
449
+ }
450
+ declare function FormActions({ className, submitText, resetText, showReset, onSubmit, }: FormActionsProps): react_jsx_runtime.JSX.Element | null;
451
+
452
+ declare const defaultComponentRegistry: Record<string, React__default.ComponentType<any>>;
453
+
454
+ /**
455
+ * Validate a single field value against its rules.
456
+ * Returns the first error message encountered, or null if valid.
457
+ */
458
+ declare function validateField(value: any, rules: ValidationRule[]): Promise<string | null>;
459
+ /**
460
+ * Validate all fields in a form.
461
+ * Returns a map of fieldId → error message for fields that have errors.
462
+ */
463
+ declare function validateAllFields(formData: Record<string, any>, fieldRules: Record<string, ValidationRule[]>): Promise<Record<string, string>>;
464
+
465
+ /**
466
+ * Evaluate form effects based on current form data.
467
+ * Returns a map of fieldId → FieldBehavior adjustments.
468
+ * Only behavior-changing actions (show/hide/enable/disable) are processed.
469
+ * setValue actions are ignored in behavior evaluation.
470
+ */
471
+ declare function evaluateEffects(effects: FormEffect[], formData: Record<string, any>, currentBehaviors: Record<string, FieldBehavior>): Record<string, FieldBehavior>;
472
+
473
+ interface FieldWrapperProps {
474
+ fieldId: string;
475
+ label: string;
476
+ required?: boolean;
477
+ tips?: string;
478
+ className?: string;
479
+ labelClassName?: string;
480
+ tipsClassName?: string;
481
+ children: React__default.ReactNode;
482
+ }
483
+ declare function FieldWrapper({ fieldId, label, required, tips, className, labelClassName, tipsClassName, children, }: FieldWrapperProps): react_jsx_runtime.JSX.Element;
484
+
485
+ interface FormContainerProps {
486
+ title?: string;
487
+ description?: string;
488
+ children: React__default.ReactNode;
489
+ maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
490
+ className?: string;
491
+ }
492
+ declare function FormContainer({ title, description, children, maxWidth, className, }: FormContainerProps): react_jsx_runtime.JSX.Element;
493
+
494
+ declare function createFormRuntimeApi(config?: FormRuntimeApiConfig): FormRuntimeApi;
495
+
496
+ declare function TextField(props: TextFieldProps): react_jsx_runtime.JSX.Element | null;
497
+
498
+ declare function NumberField(props: NumberFieldProps): react_jsx_runtime.JSX.Element | null;
499
+
500
+ declare function TextAreaField(props: TextAreaFieldProps): react_jsx_runtime.JSX.Element | null;
501
+
502
+ declare function SelectField(props: SelectFieldProps): react_jsx_runtime.JSX.Element | null;
503
+
504
+ declare function MultiSelectField(props: MultiSelectFieldProps): react_jsx_runtime.JSX.Element | null;
505
+
506
+ declare function RadioField(props: RadioFieldProps): react_jsx_runtime.JSX.Element | null;
507
+
508
+ declare function CheckboxField(props: CheckboxFieldProps): react_jsx_runtime.JSX.Element | null;
509
+
510
+ declare function DateField(props: DateFieldProps): react_jsx_runtime.JSX.Element | null;
511
+
512
+ declare function CascadeDateField(props: CascadeDateFieldProps): react_jsx_runtime.JSX.Element | null;
513
+
514
+ declare function AttachmentField(props: AttachmentFieldProps): react_jsx_runtime.JSX.Element | null;
515
+
516
+ declare function ImageField(props: ImageFieldProps): react_jsx_runtime.JSX.Element | null;
517
+
518
+ declare function SubFormField(props: SubFormFieldProps): react_jsx_runtime.JSX.Element | null;
519
+
520
+ declare function UserSelectField(props: UserSelectFieldProps): react_jsx_runtime.JSX.Element | null;
521
+
522
+ declare function DepartmentSelectField(props: DepartmentSelectFieldProps): react_jsx_runtime.JSX.Element | null;
523
+
524
+ declare function CascadeSelectField(props: CascadeSelectFieldProps): react_jsx_runtime.JSX.Element | null;
525
+
526
+ declare function AddressField(props: AddressFieldProps): react_jsx_runtime.JSX.Element | null;
527
+
528
+ declare function AssociationFormField(props: AssociationFormFieldProps): react_jsx_runtime.JSX.Element | null;
529
+
530
+ declare function EditorField(props: EditorFieldProps): react_jsx_runtime.JSX.Element | null;
531
+
532
+ declare function SerialNumberField(props: SerialNumberFieldProps): react_jsx_runtime.JSX.Element | null;
533
+
534
+ declare function LocationField(props: LocationFieldProps): react_jsx_runtime.JSX.Element | null;
535
+
536
+ declare function DigitalSignatureField(props: DigitalSignatureFieldProps): react_jsx_runtime.JSX.Element | null;
537
+
538
+ declare function JSONField(props: JSONFieldProps): react_jsx_runtime.JSX.Element | null;
539
+
540
+ interface FormSectionProps {
541
+ title: string;
542
+ description?: string;
543
+ collapsible?: boolean;
544
+ defaultCollapsed?: boolean;
545
+ className?: string;
546
+ titleClassName?: string;
547
+ contentClassName?: string;
548
+ children: React__default.ReactNode;
549
+ }
550
+ declare function FormSection({ title, description, collapsible, defaultCollapsed, className, titleClassName, contentClassName, children, }: FormSectionProps): react_jsx_runtime.JSX.Element;
551
+
552
+ interface FormGridProps {
553
+ columns?: 1 | 2 | 3 | 4;
554
+ gap?: number;
555
+ className?: string;
556
+ children: React__default.ReactNode;
557
+ }
558
+ declare function FormGrid({ columns, gap, className, children }: FormGridProps): react_jsx_runtime.JSX.Element;
559
+
560
+ interface FormTabItem {
561
+ key: string;
562
+ label: string;
563
+ children: React__default.ReactNode;
564
+ }
565
+ interface FormTabsProps {
566
+ items: FormTabItem[];
567
+ defaultActiveKey?: string;
568
+ className?: string;
569
+ tabClassName?: string;
570
+ }
571
+ declare function FormTabs({ items, defaultActiveKey, className, tabClassName }: FormTabsProps): react_jsx_runtime.JSX.Element;
572
+
573
+ interface FormStepItem {
574
+ key: string;
575
+ title: string;
576
+ description?: string;
577
+ children: React__default.ReactNode;
578
+ }
579
+ interface FormStepsProps {
580
+ items: FormStepItem[];
581
+ className?: string;
582
+ onStepChange?: (step: number) => void;
583
+ }
584
+ declare function FormSteps({ items, className, onStepChange }: FormStepsProps): react_jsx_runtime.JSX.Element;
585
+
586
+ interface FormSummaryProps {
587
+ className?: string;
588
+ labelClassName?: string;
589
+ valueClassName?: string;
590
+ columns?: 1 | 2 | 3;
591
+ fields?: string[];
592
+ }
593
+ declare function FormSummary({ className, labelClassName, valueClassName, columns, fields, }: FormSummaryProps): react_jsx_runtime.JSX.Element;
594
+
595
+ interface UseFormEngineReturn {
596
+ formData: Record<string, any>;
597
+ setFieldValue: (fieldId: string, value: any) => void;
598
+ getFieldValue: (fieldId: string) => any;
599
+ getFormData: () => Record<string, any>;
600
+ validateAll: () => Promise<boolean>;
601
+ resetForm: () => void;
602
+ mode: string;
603
+ fieldBehaviors: Record<string, FieldBehavior>;
604
+ fieldErrors: Record<string, string>;
605
+ }
606
+ declare function useFormEngine(schema: FormSchema, config: FormEngineConfig): UseFormEngineReturn;
607
+
608
+ interface UseFormDataReturn {
609
+ formData: Record<string, any>;
610
+ setFieldValue: (fieldId: string, value: any) => void;
611
+ getFieldValue: (fieldId: string) => any;
612
+ getFormData: () => Record<string, any>;
613
+ resetForm: () => void;
614
+ dirtyFields: Set<string>;
615
+ }
616
+ declare function useFormData(initialValues?: Record<string, any>): UseFormDataReturn;
617
+
618
+ interface UseFieldBehaviorOptions {
619
+ fieldId: string;
620
+ permissions?: Record<string, FieldBehavior>;
621
+ effects?: FormEffect[];
622
+ formData: Record<string, any>;
623
+ defaultBehavior?: FieldBehavior;
624
+ }
625
+ /**
626
+ * Computes the final behavior for a field.
627
+ * Priority: permissions > effects > defaultBehavior > 'NORMAL'
628
+ */
629
+ declare function useFieldBehavior({ fieldId, permissions, effects, formData, defaultBehavior, }: UseFieldBehaviorOptions): FieldBehavior;
630
+
631
+ interface SubmitConfig {
632
+ beforeSubmit?: (values: Record<string, any>) => Promise<boolean | void>;
633
+ afterSubmit?: (response: any) => Promise<void>;
634
+ submitSuccessMode?: 'redirect' | 'stay' | 'callback';
635
+ redirectUrl?: string;
636
+ }
637
+ interface UseFormSubmitReturn {
638
+ submit: (formData: Record<string, any>, validateFn: () => Promise<boolean>) => Promise<void>;
639
+ isSubmitting: boolean;
640
+ submitError: string | null;
641
+ }
642
+ declare function useFormSubmit(config?: SubmitConfig): UseFormSubmitReturn;
643
+
644
+ interface DeviceDetectResult {
645
+ isMobile: boolean;
646
+ }
647
+ declare function useDeviceDetect(): DeviceDetectResult;
648
+
649
+ /**
650
+ * 类型安全的表单 Schema 定义辅助函数
651
+ * 提供 TypeScript 类型推导和编辑器智能提示
652
+ */
653
+ declare function defineFormSchema(schema: FormSchema): FormSchema;
654
+
655
+ export { AddressField, type AddressFieldProps, type AddressValue, type AssociationFormConfig, AssociationFormField, type AssociationFormFieldProps, type AssociationValue, AttachmentField, type AttachmentFieldProps, type AttachmentItem, type BaseFieldProps, CascadeDateField, type CascadeDateFieldProps, CascadeSelectField, type CascadeSelectFieldProps, CheckboxField, type CheckboxFieldProps, ComponentRegistryContext, type ComponentRegistryContextValue, ComponentRegistryProvider, DateField, type DateFieldProps, DepartmentSelectField, type DepartmentSelectFieldProps, type DepartmentTreeNode, type DeviceDetectResult, DigitalSignatureField, type DigitalSignatureFieldProps, type DigitalSignatureValue, EditorField, type EditorFieldProps, UserSelectField as EmployeeSelectField, type FieldBehavior, type FieldDefinition, FieldWrapper, type FieldWrapperProps, FormActions, type FormActionsProps, FormContainer, type FormContainerProps, FormContext, type FormContextValue, type FormEffect, type FormEngineConfig, FormGrid, type FormGridProps, FormProvider, type FormProviderProps, FormRenderer, type FormRendererProps, type FormRuntimeApi, type FormRuntimeApiConfig, type FormSchema, FormSection, type FormSectionProps, type FormStepItem, FormSteps, type FormStepsProps, FormSummary, type FormSummaryProps, type FormTabItem, FormTabs, type FormTabsProps, ImageField, type ImageFieldProps, JSONField, type JSONFieldProps, LocationField, type LocationFieldProps, type LocationValue, MultiSelectField, type MultiSelectFieldProps, NumberField, type NumberFieldProps, type OptionItem, RadioField, type RadioFieldProps, type RuntimeRequestConfig, type RuntimeResponse, SelectField, type SelectFieldProps, SerialNumberField, type SerialNumberFieldProps, type SignaturePoint, type SubFormColumn, SubFormField, type SubFormFieldProps, type SubmitConfig, TextAreaField, type TextAreaFieldProps, TextField, type TextFieldProps, TextAreaField as TextareaField, type UseFieldBehaviorOptions, type UseFormDataReturn, type UseFormEngineReturn, type UseFormSubmitReturn, type UserItem, UserSelectField, type UserSelectFieldProps, type ValidationRule, createFormRuntimeApi, defaultComponentRegistry, defineFormSchema, evaluateEffects, useComponent, useDeviceDetect, useFieldBehavior, useFormContext, useFormData, useFormEngine, useFormSubmit, validateAllFields, validateField };