@classytic/formkit 1.0.3 → 1.2.2

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.
@@ -0,0 +1,625 @@
1
+ import { ClassValue } from "clsx";
2
+ import { Control, FieldError, FieldValues, Path, RegisterOptions } from "react-hook-form";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region src/utils.d.ts
6
+ /**
7
+ * Utility function to merge CSS classes with Tailwind CSS conflict resolution.
8
+ *
9
+ * Combines `clsx` for conditional class handling with `tailwind-merge`
10
+ * for proper Tailwind CSS class conflict resolution.
11
+ *
12
+ * @param inputs - Class values to merge (strings, arrays, objects, or conditionals)
13
+ * @returns Merged and deduplicated class string
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * // Basic usage
18
+ * cn("px-2 py-1", "px-4") // "py-1 px-4"
19
+ *
20
+ * // Conditional classes
21
+ * cn("base", isActive && "active", { "disabled": isDisabled })
22
+ *
23
+ * // Arrays
24
+ * cn(["flex", "items-center"], "gap-2")
25
+ * ```
26
+ */
27
+ declare function cn(...inputs: ClassValue[]): string;
28
+ //#endregion
29
+ //#region src/types.d.ts
30
+ /**
31
+ * Field type identifier.
32
+ * Can be built-in types or custom string identifiers.
33
+ */
34
+ type FieldType = "text" | "email" | "password" | "number" | "tel" | "url" | "textarea" | "select" | "checkbox" | "radio" | "switch" | "date" | "time" | "datetime" | "file" | "hidden" | "group" | "array" | "custom" | (string & {});
35
+ /**
36
+ * Layout type identifier.
37
+ */
38
+ type LayoutType = "section" | "grid" | "default" | (string & {});
39
+ /**
40
+ * Variant identifier for component styling.
41
+ */
42
+ type Variant = "default" | "compact" | "inline" | (string & {}) | undefined;
43
+ interface ConditionRule<TFieldValues extends FieldValues = FieldValues> {
44
+ watch: Path<TFieldValues>;
45
+ operator: "===" | "!==" | "in" | "not-in" | "truthy" | "falsy";
46
+ value?: unknown;
47
+ }
48
+ /**
49
+ * Condition configuration with explicit logic operator.
50
+ * Allows combining rules with AND or OR logic.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * // Show field if country is "US" OR "CA"
55
+ * condition: {
56
+ * rules: [
57
+ * { watch: "country", operator: "===", value: "US" },
58
+ * { watch: "country", operator: "===", value: "CA" },
59
+ * ],
60
+ * logic: "or",
61
+ * }
62
+ * ```
63
+ */
64
+ interface ConditionConfig<TFieldValues extends FieldValues = FieldValues> {
65
+ /** Array of condition rules to evaluate */
66
+ rules: ConditionRule<TFieldValues>[];
67
+ /** Logic operator: "and" (all must match) or "or" (any must match). Defaults to "and". */
68
+ logic?: "and" | "or";
69
+ }
70
+ /**
71
+ * Single option for select/radio/checkbox fields.
72
+ */
73
+ interface FieldOption<TValue = string> {
74
+ /** Display label */
75
+ label: string;
76
+ /** Option value */
77
+ value: TValue;
78
+ /** Whether option is disabled */
79
+ disabled?: boolean;
80
+ /** Optional description */
81
+ description?: string;
82
+ /** Optional icon */
83
+ icon?: ReactNode;
84
+ }
85
+ /**
86
+ * Option group for select fields.
87
+ */
88
+ interface FieldOptionGroup<TValue = string> {
89
+ /** Group label */
90
+ label: string;
91
+ /** Group options */
92
+ options: FieldOption<TValue>[];
93
+ /** Whether group is disabled */
94
+ disabled?: boolean;
95
+ }
96
+ /**
97
+ * Base field configuration shared by all field types.
98
+ * @template TFieldValues - Form field values type for type-safe field names
99
+ */
100
+ interface BaseField<TFieldValues extends FieldValues = FieldValues> {
101
+ /** Field name (must be a valid path in form values) */
102
+ name: Path<TFieldValues> | (string & {});
103
+ /** Field type identifier */
104
+ type: FieldType;
105
+ /** Field label */
106
+ label?: string;
107
+ /** Placeholder text */
108
+ placeholder?: string;
109
+ /** Helper text shown below the field */
110
+ helperText?: string;
111
+ /** Whether field is disabled */
112
+ disabled?: boolean;
113
+ /** Whether field is required */
114
+ required?: boolean;
115
+ /** Whether field is read-only */
116
+ readOnly?: boolean;
117
+ /** Field variant */
118
+ variant?: Variant;
119
+ /** Whether field should span full width in grid */
120
+ fullWidth?: boolean;
121
+ /** Custom CSS class name */
122
+ className?: string;
123
+ /**
124
+ * Conditional rendering function, declarative rules, or a condition config with logic.
125
+ * Return true to show the field, false to hide.
126
+ */
127
+ condition?: ((formValues: Partial<TFieldValues>) => boolean) | ConditionRule<TFieldValues> | ConditionRule<TFieldValues>[] | ConditionConfig<TFieldValues>;
128
+ /** Default value */
129
+ defaultValue?: unknown;
130
+ /** Options for select/radio/checkbox fields */
131
+ options?: (FieldOption | FieldOptionGroup)[];
132
+ /** Minimum value (for number/date fields) */
133
+ min?: number | string;
134
+ /** Maximum value (for number/date fields) */
135
+ max?: number | string;
136
+ /** Step value (for number fields) */
137
+ step?: number;
138
+ /** Pattern for validation (regex string) */
139
+ pattern?: string;
140
+ /** Minimum length */
141
+ minLength?: number;
142
+ /** Maximum length */
143
+ maxLength?: number;
144
+ /** Number of rows (for textarea) */
145
+ rows?: number;
146
+ /** Multiple selection (for select/file) */
147
+ multiple?: boolean;
148
+ /** Accepted file types (for file input) */
149
+ accept?: string;
150
+ /** Auto-complete attribute */
151
+ autoComplete?: string;
152
+ /** Auto-focus on mount */
153
+ autoFocus?: boolean;
154
+ /** Debounce loadOptions requests in milliseconds, helps prevent API storms */
155
+ debounceMs?: number;
156
+ /**
157
+ * Dynamic options loaded based on current form values.
158
+ * Useful for dependent selects (e.g., state depends on country).
159
+ */
160
+ loadOptions?: (formValues: Partial<TFieldValues>) => Promise<(FieldOption | FieldOptionGroup)[]> | (FieldOption | FieldOptionGroup)[];
161
+ /**
162
+ * Error callback for loadOptions failures.
163
+ * Called when loadOptions rejects. Defaults to console.error.
164
+ */
165
+ onLoadError?: (error: unknown) => void;
166
+ /**
167
+ * Fields for array or object types.
168
+ * Useful for 'array' or 'group' field types that need a sub-schema.
169
+ */
170
+ itemFields?: BaseField<TFieldValues>[];
171
+ /**
172
+ * Custom render function to override the component registry for this specific field.
173
+ * Completely bypasses the globally registered FieldComponent for this type.
174
+ */
175
+ render?: (props: FieldComponentProps<TFieldValues>) => ReactNode;
176
+ /**
177
+ * Cross-field validation function.
178
+ * Receives the field value and all form values for cross-field checks.
179
+ * Return `true` for valid, or a string error message for invalid.
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * validate: (value, formValues) =>
184
+ * value > formValues.minPrice || "Must be greater than min price"
185
+ * ```
186
+ */
187
+ validate?: (value: unknown, formValues: Partial<TFieldValues>) => string | true;
188
+ /**
189
+ * Dependencies for optimizing conditionally rendered fields.
190
+ * Allows specifying specific field names to watch, preventing full form re-renders.
191
+ */
192
+ watchNames?: Path<TFieldValues> | Path<TFieldValues>[];
193
+ /** Additional field-specific props for custom components */
194
+ customProps?: Record<string, unknown>;
195
+ }
196
+ /**
197
+ * Props passed to field components.
198
+ *
199
+ * Components receive both:
200
+ * 1. A `field` object with the complete field configuration
201
+ * 2. All field properties spread at the top level
202
+ *
203
+ * @template TFieldValues - Form field values type
204
+ *
205
+ * @example
206
+ * ```tsx
207
+ * // Schema
208
+ * { name: "email", type: "email", label: "Email", placeholder: "user@example.com" }
209
+ *
210
+ * // Your component receives:
211
+ * {
212
+ * field: { name: "email", type: "email", label: "Email", placeholder: "..." },
213
+ * control: {...},
214
+ * disabled: false,
215
+ * variant: undefined,
216
+ * // PLUS all field props at top level:
217
+ * name: "email",
218
+ * type: "email",
219
+ * label: "Email",
220
+ * placeholder: "user@example.com"
221
+ * }
222
+ * ```
223
+ */
224
+ interface FieldComponentProps<TFieldValues extends FieldValues = FieldValues> extends BaseField<TFieldValues> {
225
+ /** Field configuration object (contains all field props) */
226
+ field: BaseField<TFieldValues>;
227
+ /** React Hook Form control for Controller integration */
228
+ control: Control<TFieldValues>;
229
+ /** Whether field is globally disabled */
230
+ disabled?: boolean;
231
+ /** Component variant */
232
+ variant?: Variant;
233
+ /** Field validation error from react-hook-form */
234
+ error?: FieldError;
235
+ /** Field state from react-hook-form */
236
+ fieldState?: {
237
+ invalid: boolean;
238
+ isDirty: boolean;
239
+ isTouched: boolean;
240
+ isValidating: boolean;
241
+ error?: FieldError;
242
+ };
243
+ /** Generated field ID for label-input association (e.g. `formkit-field-email`) */
244
+ fieldId: string;
245
+ /** Whether dynamic options are currently loading */
246
+ isLoading?: boolean;
247
+ }
248
+ /**
249
+ * Validation rules compatible with react-hook-form's RegisterOptions.
250
+ * Returned by `buildValidationRules()`.
251
+ */
252
+ type ValidationRules = Pick<RegisterOptions, "required" | "min" | "max" | "minLength" | "maxLength" | "pattern" | "validate">;
253
+ /**
254
+ * Section configuration for grouping fields.
255
+ * @template TFieldValues - Form field values type
256
+ */
257
+ interface Section<TFieldValues extends FieldValues = FieldValues> {
258
+ /** Unique section identifier */
259
+ id?: string;
260
+ /** Section title */
261
+ title?: string;
262
+ /** Section description */
263
+ description?: string;
264
+ /** Section icon */
265
+ icon?: ReactNode;
266
+ /** Namespace to prepend to all field names in this section */
267
+ nameSpace?: string;
268
+ /** Fields in this section */
269
+ fields?: BaseField<TFieldValues>[];
270
+ /** Number of columns in grid layout */
271
+ cols?: 1 | 2 | 3 | 4 | 5 | 6 | number;
272
+ /** Gap between grid items (Tailwind spacing scale) */
273
+ gap?: number;
274
+ /**
275
+ * Custom render function for complete control.
276
+ * When provided, fields array is ignored.
277
+ */
278
+ render?: (props: SectionRenderProps<TFieldValues>) => ReactNode;
279
+ /** Section variant */
280
+ variant?: Variant;
281
+ /** Custom CSS class name */
282
+ className?: string;
283
+ /**
284
+ * Conditional rendering function, declarative rules, or a condition config with logic.
285
+ * Return true to show the section, false to hide.
286
+ */
287
+ condition?: ((formValues?: Partial<TFieldValues>) => boolean) | ConditionRule<TFieldValues> | ConditionRule<TFieldValues>[] | ConditionConfig<TFieldValues>;
288
+ /** Whether section is collapsible */
289
+ collapsible?: boolean;
290
+ /** Default collapsed state */
291
+ defaultCollapsed?: boolean;
292
+ }
293
+ /**
294
+ * Props passed to section render function.
295
+ */
296
+ interface SectionRenderProps<TFieldValues extends FieldValues = FieldValues> {
297
+ control?: Control<TFieldValues>;
298
+ disabled?: boolean;
299
+ section: Section<TFieldValues>;
300
+ }
301
+ /**
302
+ * Section layout component props.
303
+ */
304
+ interface SectionLayoutProps {
305
+ /** Section title */
306
+ title?: string;
307
+ /** Section description */
308
+ description?: string;
309
+ /** Section icon */
310
+ icon?: ReactNode;
311
+ /** Layout variant */
312
+ variant?: Variant;
313
+ /** Custom CSS class name */
314
+ className?: string;
315
+ /** Whether section is collapsible */
316
+ collapsible?: boolean;
317
+ /** Default collapsed state */
318
+ defaultCollapsed?: boolean;
319
+ /** Children content */
320
+ children: ReactNode;
321
+ }
322
+ /**
323
+ * Grid layout component props.
324
+ */
325
+ interface GridLayoutProps {
326
+ /** Number of columns */
327
+ cols?: number;
328
+ /** Gap between items */
329
+ gap?: number;
330
+ /** Custom CSS class name */
331
+ className?: string;
332
+ /** Children content */
333
+ children: ReactNode;
334
+ }
335
+ /**
336
+ * Default layout component props.
337
+ */
338
+ interface DefaultLayoutProps {
339
+ /** Custom CSS class name */
340
+ className?: string;
341
+ /** Children content */
342
+ children: ReactNode;
343
+ }
344
+ /**
345
+ * Union of all layout component props.
346
+ */
347
+ type LayoutComponentProps = SectionLayoutProps | GridLayoutProps | DefaultLayoutProps;
348
+ /**
349
+ * Complete form schema configuration.
350
+ * @template TFieldValues - Form field values type for type-safe schemas
351
+ */
352
+ interface FormSchema<TFieldValues extends FieldValues = FieldValues> {
353
+ /** Form sections */
354
+ sections: Section<TFieldValues>[];
355
+ }
356
+ /**
357
+ * Extract field names from a schema.
358
+ */
359
+ type SchemaFieldNames<TSchema extends FormSchema> = TSchema extends FormSchema<infer T> ? keyof T : never;
360
+ /**
361
+ * Infer field values type from a schema.
362
+ */
363
+ type InferSchemaValues<TSchema extends FormSchema> = TSchema extends FormSchema<infer T> ? T : FieldValues;
364
+ /**
365
+ * Helper type for creating type-safe field definitions.
366
+ */
367
+ type DefineField<TFieldValues extends FieldValues, TType extends FieldType = FieldType> = BaseField<TFieldValues> & {
368
+ type: TType;
369
+ };
370
+ //#endregion
371
+ //#region src/schema.d.ts
372
+ /**
373
+ * All supported condition shapes.
374
+ */
375
+ type Condition<TFieldValues extends FieldValues = FieldValues> = ((formValues: Partial<TFieldValues>) => boolean) | ConditionRule<TFieldValues> | ConditionRule<TFieldValues>[] | ConditionConfig<TFieldValues> | undefined;
376
+ /**
377
+ * Evaluates a conditional rule, array of rules, or a ConditionConfig against form values.
378
+ * Supports AND (default) and OR logic via ConditionConfig.
379
+ *
380
+ * @param condition - The condition function, rule(s), or config
381
+ * @param formValues - The form values to evaluate against
382
+ * @returns boolean indicating if condition matches
383
+ */
384
+ declare function evaluateCondition<TFieldValues extends FieldValues = FieldValues>(condition: Condition<TFieldValues>, formValues: Partial<TFieldValues>): boolean;
385
+ /**
386
+ * Extracts all watch names from a condition to optimize `useWatch`.
387
+ * Handles single rules, arrays, and ConditionConfig objects.
388
+ */
389
+ declare function extractWatchNames<TFieldValues extends FieldValues = FieldValues>(condition: Condition<TFieldValues>): string[];
390
+ /**
391
+ * Strictly types a comprehensive form schema, granting exact intellisense bounds across conditions and nested watches.
392
+ */
393
+ declare function defineSchema<TFieldValues extends FieldValues = FieldValues>(schema: FormSchema<TFieldValues>): FormSchema<TFieldValues>;
394
+ /**
395
+ * Standard utility to strictly type a standalone field out-of-bounds, useful for externalizing massive schema structures.
396
+ */
397
+ declare function defineField<TFieldValues extends FieldValues = FieldValues>(field: BaseField<TFieldValues>): BaseField<TFieldValues>;
398
+ /**
399
+ * Standard utility to strictly type a standalone logic section layout block.
400
+ */
401
+ declare function defineSection<TFieldValues extends FieldValues = FieldValues>(section: Section<TFieldValues>): Section<TFieldValues>;
402
+ /**
403
+ * Extracts default values from a form schema.
404
+ * Walks all sections and fields, respecting nameSpace prefixes and group nesting.
405
+ *
406
+ * @example
407
+ * ```ts
408
+ * const defaults = extractDefaultValues(schema);
409
+ * const form = useForm({ defaultValues: defaults });
410
+ * ```
411
+ */
412
+ declare function extractDefaultValues<TFieldValues extends FieldValues = FieldValues>(schema: FormSchema<TFieldValues>): Partial<TFieldValues>;
413
+ /**
414
+ * Generates react-hook-form `RegisterOptions`-compatible validation rules
415
+ * from a field's schema props. Maps `required`, `min`, `max`, `minLength`,
416
+ * `maxLength`, `pattern`, and `validate` to RHF rules.
417
+ *
418
+ * @example
419
+ * ```tsx
420
+ * import { buildValidationRules } from '@classytic/formkit';
421
+ *
422
+ * function FormInput({ field, control }: FieldComponentProps) {
423
+ * const rules = buildValidationRules(field);
424
+ * return <Controller name={field.name} control={control} rules={rules} render={...} />;
425
+ * }
426
+ * ```
427
+ */
428
+ declare function buildValidationRules<TFieldValues extends FieldValues = FieldValues>(field: BaseField<TFieldValues>): ValidationRules;
429
+ //#endregion
430
+ //#region src/builders.d.ts
431
+ /**
432
+ * Additional field props for builder helpers.
433
+ * Accepts all BaseField properties except `name`, `type`, and `label`
434
+ * which are set by the builder method.
435
+ */
436
+ type FieldProps<TFieldValues extends FieldValues = FieldValues> = Omit<BaseField<TFieldValues>, "name" | "type" | "label"> & {
437
+ /** Grid column class (e.g., "col-span-2") */gridColumn?: string; /** Icon for the left side of input */
438
+ iconLeft?: ReactNode; /** Icon for the right side of input */
439
+ iconRight?: ReactNode; /** Additional custom props */
440
+ [key: string]: unknown;
441
+ };
442
+ /**
443
+ * Section configuration props.
444
+ */
445
+ interface SectionProps<TFieldValues extends FieldValues = FieldValues> extends Omit<Section<TFieldValues>, "id" | "title" | "fields" | "cols"> {
446
+ cols?: number;
447
+ }
448
+ /**
449
+ * Render function for custom field types.
450
+ */
451
+ type CustomRenderFn = (props: {
452
+ control: Control<FieldValues>;
453
+ disabled?: boolean;
454
+ error?: FieldError;
455
+ }) => ReactNode;
456
+ /**
457
+ * Type-safe field builder helpers for schema-driven forms.
458
+ *
459
+ * Provides shorthand methods for common field types with sensible defaults,
460
+ * reducing boilerplate while maintaining full type safety.
461
+ *
462
+ * @example
463
+ * ```ts
464
+ * import { field, section } from '@classytic/formkit';
465
+ *
466
+ * const schema = {
467
+ * sections: [
468
+ * section("personal", "Personal Info", [
469
+ * field.text("firstName", "First Name", { required: true }),
470
+ * field.email("email", "Email"),
471
+ * field.select("role", "Role", [
472
+ * { label: "Admin", value: "admin" },
473
+ * { label: "User", value: "user" },
474
+ * ]),
475
+ * ], { cols: 2 }),
476
+ * ],
477
+ * };
478
+ * ```
479
+ */
480
+ declare const field: {
481
+ /**
482
+ * Text input field.
483
+ */
484
+ text: (name: string, label: string, props?: FieldProps) => BaseField;
485
+ /**
486
+ * Email input field with default placeholder.
487
+ */
488
+ email: (name: string, label: string, props?: FieldProps) => BaseField;
489
+ /**
490
+ * URL input field with default placeholder.
491
+ */
492
+ url: (name: string, label: string, props?: FieldProps) => BaseField;
493
+ /**
494
+ * Phone/tel input field with default placeholder.
495
+ */
496
+ tel: (name: string, label: string, props?: FieldProps) => BaseField;
497
+ /**
498
+ * Password input field.
499
+ */
500
+ password: (name: string, label: string, props?: FieldProps) => BaseField;
501
+ /**
502
+ * Number input field with min: 0 default.
503
+ */
504
+ number: (name: string, label: string, props?: FieldProps) => BaseField;
505
+ /**
506
+ * Textarea field with default 3 rows.
507
+ */
508
+ textarea: (name: string, label: string, props?: FieldProps) => BaseField;
509
+ /**
510
+ * Select dropdown field.
511
+ */
512
+ select: (name: string, label: string, options: (FieldOption | FieldOptionGroup)[], props?: FieldProps) => BaseField;
513
+ /**
514
+ * Searchable combobox field.
515
+ */
516
+ combobox: (name: string, label: string, options: (FieldOption | FieldOptionGroup)[], props?: FieldProps) => BaseField;
517
+ /**
518
+ * Multi-select field (tag choice).
519
+ */
520
+ multiselect: (name: string, label: string, options: (FieldOption | FieldOptionGroup)[], props?: FieldProps) => BaseField;
521
+ /**
522
+ * Dependent select field that reacts to parent field changes.
523
+ */
524
+ dependentSelect: (name: string, label: string, props?: FieldProps) => BaseField;
525
+ /**
526
+ * Switch/toggle field.
527
+ */
528
+ switch: (name: string, label: string, props?: FieldProps) => BaseField;
529
+ /**
530
+ * Boolean field (alias for switch).
531
+ */
532
+ boolean: (name: string, label: string, props?: FieldProps) => BaseField;
533
+ /**
534
+ * Checkbox field.
535
+ */
536
+ checkbox: (name: string, label: string, props?: FieldProps) => BaseField;
537
+ /**
538
+ * Radio button group field.
539
+ */
540
+ radio: (name: string, label: string, options: FieldOption[], props?: FieldProps) => BaseField;
541
+ /**
542
+ * Date picker field.
543
+ */
544
+ date: (name: string, label: string, props?: FieldProps) => BaseField;
545
+ /**
546
+ * Tag input field with default placeholder.
547
+ */
548
+ tags: (name: string, label: string, props?: FieldProps) => BaseField;
549
+ /**
550
+ * Slug field with auto-generation from source value.
551
+ */
552
+ slug: (name: string, label: string, props?: FieldProps) => BaseField;
553
+ /**
554
+ * File upload field.
555
+ */
556
+ file: (name: string, label: string, props?: FieldProps) => BaseField;
557
+ /**
558
+ * Hidden field (no UI).
559
+ */
560
+ hidden: (name: string, props?: FieldProps) => BaseField;
561
+ /**
562
+ * Group field for nested objects.
563
+ * Renders itemFields as a sub-grid within the form.
564
+ *
565
+ * @example
566
+ * ```ts
567
+ * field.group("address", "Address", [
568
+ * field.text("street", "Street"),
569
+ * field.text("city", "City"),
570
+ * field.text("zip", "ZIP Code"),
571
+ * ], { cols: 3 })
572
+ * ```
573
+ */
574
+ group: (name: string, label: string, itemFields: BaseField[], props?: FieldProps) => BaseField;
575
+ /**
576
+ * Array/repeatable field.
577
+ * Renders a dynamic list of sub-forms using react-hook-form's useFieldArray.
578
+ *
579
+ * @example
580
+ * ```ts
581
+ * field.array("contacts", "Contacts", [
582
+ * field.text("name", "Name"),
583
+ * field.email("email", "Email"),
584
+ * ])
585
+ * ```
586
+ */
587
+ array: (name: string, label: string, itemFields: BaseField[], props?: FieldProps) => BaseField;
588
+ /**
589
+ * Custom field with a render function.
590
+ * Bypasses the component registry entirely.
591
+ *
592
+ * @example
593
+ * ```ts
594
+ * field.custom("skills", "Skills", ({ control, disabled }) => (
595
+ * <SkillSelector control={control} disabled={disabled} />
596
+ * ))
597
+ * ```
598
+ */
599
+ custom: (name: string, label: string, render: CustomRenderFn, props?: FieldProps) => BaseField;
600
+ };
601
+ /**
602
+ * Create a section definition with sensible defaults.
603
+ *
604
+ * @param id - Unique section identifier
605
+ * @param title - Section title
606
+ * @param fields - Array of field definitions
607
+ * @param props - Additional section configuration
608
+ *
609
+ * @example
610
+ * ```ts
611
+ * section("personal", "Personal Info", [
612
+ * field.text("name", "Name", { required: true }),
613
+ * field.email("email", "Email"),
614
+ * ], { cols: 2, variant: "card" })
615
+ * ```
616
+ */
617
+ declare function section<TFieldValues extends FieldValues = FieldValues>(id: string, title: string, fields: BaseField<TFieldValues>[], props?: SectionProps<TFieldValues>): Section<TFieldValues>;
618
+ /**
619
+ * Create a section without a title (transparent section).
620
+ * Useful for grouping fields without visual separation.
621
+ */
622
+ declare function sectionUntitled<TFieldValues extends FieldValues = FieldValues>(fields: BaseField<TFieldValues>[], props?: Omit<SectionProps<TFieldValues>, "variant">): Section<TFieldValues>;
623
+ //#endregion
624
+ export { type BaseField, type ClassValue, type Condition, type ConditionConfig, type ConditionRule, type DefaultLayoutProps, type DefineField, type FieldOption, type FieldOptionGroup, type FieldType, type FormSchema, type GridLayoutProps, type InferSchemaValues, type LayoutComponentProps, type LayoutType, type SchemaFieldNames, type Section, type SectionLayoutProps, type SectionRenderProps, type Variant, buildValidationRules, cn, defineField, defineSchema, defineSection, evaluateCondition, extractDefaultValues, extractWatchNames, field, section, sectionUntitled };
625
+ //# sourceMappingURL=server.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../src/utils.ts","../src/types.ts","../src/schema.ts","../src/builders.ts"],"mappings":";;;;;;;;;AAyBA;;;;;;;;ACdA;;;;;AAyBA;;;;iBDXgB,EAAA,CAAA,GAAM,MAAA,EAAQ,UAAA;;;;;;AAA9B;KCdY,SAAA;;;;KAyBA,UAAA;;;AAzBZ;KA8BY,OAAA;AAAA,UAWK,aAAA,sBAAmC,WAAA,GAAc,WAAA;EAChE,KAAA,EAAO,IAAA,CAAK,YAAA;EACZ,QAAA;EACA,KAAA;AAAA;;;;AAdF;;;;;AAWA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