@buildnbuzz/buzzform 0.1.2 → 0.1.4

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.
@@ -33,7 +33,7 @@ type ValidationFn<TValue = unknown, TData = Record<string, unknown>> = (value: T
33
33
  */
34
34
  interface ConditionContext {
35
35
  /** Current operation */
36
- operation: 'create' | 'update' | 'read';
36
+ operation: "create" | "update" | "read";
37
37
  /** Path segments to this field */
38
38
  path: string[];
39
39
  }
@@ -172,7 +172,7 @@ interface BaseField<TValue = unknown, TData = Record<string, unknown>> {
172
172
  * Text field
173
173
  */
174
174
  interface TextField extends BaseField<string> {
175
- type: 'text';
175
+ type: "text";
176
176
  /** Minimum length */
177
177
  minLength?: number;
178
178
  /** Maximum length */
@@ -191,7 +191,7 @@ interface TextField extends BaseField<string> {
191
191
  * Email field
192
192
  */
193
193
  interface EmailField extends BaseField<string> {
194
- type: 'email';
194
+ type: "email";
195
195
  /** Minimum length */
196
196
  minLength?: number;
197
197
  /** Maximum length */
@@ -210,7 +210,7 @@ interface EmailField extends BaseField<string> {
210
210
  * Password field
211
211
  */
212
212
  interface PasswordField extends BaseField<string> {
213
- type: 'password';
213
+ type: "password";
214
214
  /** Minimum length (default: 8) */
215
215
  minLength?: number;
216
216
  /** Maximum length */
@@ -238,7 +238,7 @@ interface PasswordField extends BaseField<string> {
238
238
  * Textarea field
239
239
  */
240
240
  interface TextareaField extends BaseField<string> {
241
- type: 'textarea';
241
+ type: "textarea";
242
242
  /** Minimum length */
243
243
  minLength?: number;
244
244
  /** Maximum length */
@@ -257,7 +257,7 @@ interface TextareaField extends BaseField<string> {
257
257
  * Number field
258
258
  */
259
259
  interface NumberField extends BaseField<number> {
260
- type: 'number';
260
+ type: "number";
261
261
  /** Minimum value */
262
262
  min?: number;
263
263
  /** Maximum value */
@@ -269,7 +269,7 @@ interface NumberField extends BaseField<number> {
269
269
  /** Step increment */
270
270
  step?: number;
271
271
  /** Visual variant */
272
- variant?: 'default' | 'stacked' | 'pill' | 'plain';
272
+ variant?: "default" | "stacked" | "pill" | "plain";
273
273
  /** Prefix (e.g., "$") */
274
274
  prefix?: string;
275
275
  /** Suffix (e.g., "%", "kg") */
@@ -286,7 +286,7 @@ interface NumberField extends BaseField<number> {
286
286
  * Date field
287
287
  */
288
288
  interface DateField extends BaseField<Date> {
289
- type: 'date';
289
+ type: "date";
290
290
  /** Minimum date */
291
291
  minDate?: Date | string;
292
292
  /** Maximum date */
@@ -308,7 +308,7 @@ interface DateField extends BaseField<Date> {
308
308
  * Datetime field
309
309
  */
310
310
  interface DatetimeField extends BaseField<Date> {
311
- type: 'datetime';
311
+ type: "datetime";
312
312
  /** Minimum date */
313
313
  minDate?: Date | string;
314
314
  /** Maximum date */
@@ -353,7 +353,7 @@ interface SelectOption {
353
353
  * Select field
354
354
  */
355
355
  interface SelectField extends BaseField<string | string[] | number | number[] | boolean> {
356
- type: 'select';
356
+ type: "select";
357
357
  /** Options (static, string array, or async with context for dependent dropdowns) */
358
358
  options: SelectOption[] | string[] | ((context: ValidationContext) => Promise<SelectOption[]>);
359
359
  /**
@@ -364,6 +364,10 @@ interface SelectField extends BaseField<string | string[] | number | number[] |
364
364
  dependencies?: string[];
365
365
  /** Allow multiple selections */
366
366
  hasMany?: boolean;
367
+ /** Minimum number of selections (when hasMany is true) */
368
+ minSelected?: number;
369
+ /** Maximum number of selections (when hasMany is true) */
370
+ maxSelected?: number;
367
371
  /** UI options */
368
372
  ui?: {
369
373
  /** Enable search */
@@ -378,17 +382,47 @@ interface SelectField extends BaseField<string | string[] | number | number[] |
378
382
  loadingMessage?: string;
379
383
  };
380
384
  }
385
+ /**
386
+ * Checkbox group field - multiple selections from a list of options
387
+ */
388
+ interface CheckboxGroupField extends BaseField<Array<string | number | boolean>> {
389
+ type: "checkbox-group";
390
+ /** Static array or async function for options */
391
+ options: SelectOption[] | string[] | ((context: ValidationContext) => Promise<SelectOption[]>);
392
+ /** Paths that trigger options refetch when changed */
393
+ dependencies?: string[];
394
+ /** Minimum number of selections */
395
+ minSelected?: number;
396
+ /** Maximum number of selections */
397
+ maxSelected?: number;
398
+ /** UI options */
399
+ ui?: {
400
+ /** Layout direction */
401
+ direction?: "vertical" | "horizontal";
402
+ /** Grid columns (responsive, 1 on mobile) */
403
+ columns?: 1 | 2 | 3 | 4;
404
+ /** Visual variant */
405
+ variant?: "default" | "card";
406
+ /** Card settings (for variant: 'card') */
407
+ card?: {
408
+ /** Size preset ('sm', 'md', 'lg') */
409
+ size?: "sm" | "md" | "lg";
410
+ /** Show border around cards */
411
+ bordered?: boolean;
412
+ };
413
+ };
414
+ }
381
415
  /**
382
416
  * Checkbox field
383
417
  */
384
418
  interface CheckboxField extends BaseField<boolean> {
385
- type: 'checkbox';
419
+ type: "checkbox";
386
420
  }
387
421
  /**
388
422
  * Switch field
389
423
  */
390
424
  interface SwitchField extends BaseField<boolean> {
391
- type: 'switch';
425
+ type: "switch";
392
426
  /** UI options */
393
427
  ui?: {
394
428
  /**
@@ -397,29 +431,29 @@ interface SwitchField extends BaseField<boolean> {
397
431
  * - 'start': Switch on left, label on right
398
432
  * - 'end': Label on left, switch on right
399
433
  */
400
- alignment?: 'start' | 'end' | 'between';
434
+ alignment?: "start" | "end" | "between";
401
435
  };
402
436
  }
403
437
  /**
404
438
  * Radio field - single selection from a group of options
405
439
  */
406
440
  interface RadioField extends BaseField<string | number | boolean> {
407
- type: 'radio';
441
+ type: "radio";
408
442
  /** Static array or async function for options */
409
443
  options: SelectOption[] | string[] | ((context: ValidationContext) => Promise<SelectOption[]>);
410
444
  /** Paths that trigger options refetch when changed */
411
445
  dependencies?: string[];
412
446
  ui?: {
413
447
  /** Visual variant ('default' or 'card') */
414
- variant?: 'default' | 'card';
448
+ variant?: "default" | "card";
415
449
  /** Layout direction for 'default' variant */
416
- direction?: 'vertical' | 'horizontal';
450
+ direction?: "vertical" | "horizontal";
417
451
  /** Grid columns (responsive, 1 on mobile) */
418
452
  columns?: 1 | 2 | 3 | 4;
419
453
  /** Card settings (for variant: 'card') */
420
454
  card?: {
421
455
  /** Size preset ('sm', 'md', 'lg') */
422
- size?: 'sm' | 'md' | 'lg';
456
+ size?: "sm" | "md" | "lg";
423
457
  /** Show border around cards */
424
458
  bordered?: boolean;
425
459
  };
@@ -429,7 +463,7 @@ interface RadioField extends BaseField<string | number | boolean> {
429
463
  * Tags field - chip-based multi-value string input
430
464
  */
431
465
  interface TagsField extends BaseField<string[]> {
432
- type: 'tags';
466
+ type: "tags";
433
467
  /** Minimum number of tags */
434
468
  minTags?: number;
435
469
  /** Maximum number of tags */
@@ -441,9 +475,9 @@ interface TagsField extends BaseField<string[]> {
441
475
  /** UI options */
442
476
  ui?: {
443
477
  /** Keys that create a new tag (default: ['enter']) */
444
- delimiters?: ('enter' | 'comma' | 'space' | 'tab')[];
478
+ delimiters?: ("enter" | "comma" | "space" | "tab")[];
445
479
  /** Visual variant */
446
- variant?: 'chips' | 'pills' | 'inline';
480
+ variant?: "chips" | "pills" | "inline";
447
481
  /** Show copy button to copy all tags */
448
482
  copyable?: boolean;
449
483
  };
@@ -452,7 +486,7 @@ interface TagsField extends BaseField<string[]> {
452
486
  * Upload field
453
487
  */
454
488
  interface UploadField extends BaseField<File | File[] | string | string[]> {
455
- type: 'upload';
489
+ type: "upload";
456
490
  /** Allow multiple files */
457
491
  hasMany?: boolean;
458
492
  /** Minimum files (when hasMany) */
@@ -466,11 +500,11 @@ interface UploadField extends BaseField<File | File[] | string | string[]> {
466
500
  /** MIME type filter */
467
501
  accept?: string;
468
502
  /** Visual variant */
469
- variant?: 'dropzone' | 'avatar' | 'inline' | 'gallery';
503
+ variant?: "dropzone" | "avatar" | "inline" | "gallery";
470
504
  /** Shape (for avatar) */
471
- shape?: 'circle' | 'square' | 'rounded';
505
+ shape?: "circle" | "square" | "rounded";
472
506
  /** Size preset */
473
- size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
507
+ size?: "xs" | "sm" | "md" | "lg" | "xl";
474
508
  /** Enable cropping */
475
509
  crop?: boolean | {
476
510
  aspectRatio?: number;
@@ -486,15 +520,15 @@ interface UploadField extends BaseField<File | File[] | string | string[]> {
486
520
  * Group field - wraps fields in a named object
487
521
  */
488
522
  interface GroupField extends BaseField<Record<string, unknown>> {
489
- type: 'group';
523
+ type: "group";
490
524
  /** Nested fields */
491
525
  fields: Field[];
492
526
  /** UI options */
493
527
  ui?: {
494
528
  /** Visual variant ('card', 'flat', 'ghost', 'bordered') */
495
- variant?: 'card' | 'flat' | 'ghost' | 'bordered';
529
+ variant?: "card" | "flat" | "ghost" | "bordered";
496
530
  /** Spacing between fields ('sm', 'md', 'lg') */
497
- spacing?: 'sm' | 'md' | 'lg';
531
+ spacing?: "sm" | "md" | "lg";
498
532
  /** Start in collapsed state */
499
533
  collapsed?: boolean;
500
534
  /** Show error badge */
@@ -505,7 +539,7 @@ interface GroupField extends BaseField<Record<string, unknown>> {
505
539
  * Array field - repeatable fields
506
540
  */
507
541
  interface ArrayField extends BaseField<unknown[]> {
508
- type: 'array';
542
+ type: "array";
509
543
  /** Fields for each array item */
510
544
  fields: Field[];
511
545
  /** Minimum items */
@@ -536,7 +570,7 @@ interface ArrayField extends BaseField<unknown[]> {
536
570
  * Row field - horizontal layout container
537
571
  */
538
572
  interface RowField {
539
- type: 'row';
573
+ type: "row";
540
574
  /** Fields to display in a row */
541
575
  fields: Field[];
542
576
  /** Layout options */
@@ -544,13 +578,13 @@ interface RowField {
544
578
  /** Gap between fields (e.g., 4, '1rem', '16px') */
545
579
  gap?: number | string;
546
580
  /** Vertical alignment */
547
- align?: 'start' | 'center' | 'end' | 'stretch';
581
+ align?: "start" | "center" | "end" | "stretch";
548
582
  /** Horizontal distribution */
549
- justify?: 'start' | 'center' | 'end' | 'between';
583
+ justify?: "start" | "center" | "end" | "between";
550
584
  /** Allow wrapping to next line */
551
585
  wrap?: boolean;
552
586
  /** Responsive behavior: 'stack' collapses to vertical on mobile */
553
- responsive?: boolean | 'stack';
587
+ responsive?: boolean | "stack";
554
588
  };
555
589
  }
556
590
  /**
@@ -574,7 +608,7 @@ interface Tab {
574
608
  * Tabs field - tabbed container
575
609
  */
576
610
  interface TabsField {
577
- type: 'tabs';
611
+ type: "tabs";
578
612
  /** Tab definitions */
579
613
  tabs: Tab[];
580
614
  /** UI options */
@@ -584,16 +618,16 @@ interface TabsField {
584
618
  /** Show error badge on tabs with validation errors */
585
619
  showErrorBadge?: boolean;
586
620
  /** Visual variant */
587
- variant?: 'default' | 'line';
621
+ variant?: "default" | "line";
588
622
  /** Spacing between fields within tabs */
589
- spacing?: 'sm' | 'md' | 'lg';
623
+ spacing?: "sm" | "md" | "lg";
590
624
  };
591
625
  }
592
626
  /**
593
627
  * Collapsible field - expandable container
594
628
  */
595
629
  interface CollapsibleField {
596
- type: 'collapsible';
630
+ type: "collapsible";
597
631
  /** Container label */
598
632
  label: string;
599
633
  /** Nested fields */
@@ -603,9 +637,9 @@ interface CollapsibleField {
603
637
  /** UI options */
604
638
  ui?: {
605
639
  /** Visual variant ('card', 'flat', 'ghost', 'bordered') */
606
- variant?: 'card' | 'flat' | 'ghost' | 'bordered';
640
+ variant?: "card" | "flat" | "ghost" | "bordered";
607
641
  /** Spacing between fields ('sm', 'md', 'lg') */
608
- spacing?: 'sm' | 'md' | 'lg';
642
+ spacing?: "sm" | "md" | "lg";
609
643
  /** Show error badge */
610
644
  showErrorBadge?: boolean;
611
645
  /** Optional description */
@@ -619,15 +653,15 @@ interface CollapsibleField {
619
653
  /**
620
654
  * Union of all field types.
621
655
  */
622
- type Field = TextField | EmailField | PasswordField | TextareaField | NumberField | DateField | DatetimeField | SelectField | CheckboxField | SwitchField | RadioField | TagsField | UploadField | GroupField | ArrayField | RowField | TabsField | CollapsibleField;
656
+ type Field = TextField | EmailField | PasswordField | TextareaField | NumberField | DateField | DatetimeField | SelectField | CheckboxGroupField | CheckboxField | SwitchField | RadioField | TagsField | UploadField | GroupField | ArrayField | RowField | TabsField | CollapsibleField;
623
657
  /**
624
658
  * Extract field type from a Field.
625
659
  */
626
- type FieldType = Field['type'];
660
+ type FieldType = Field["type"];
627
661
  /**
628
662
  * Data fields (fields that hold values).
629
663
  */
630
- type DataField = TextField | EmailField | PasswordField | TextareaField | NumberField | DateField | DatetimeField | SelectField | CheckboxField | SwitchField | RadioField | TagsField | UploadField | GroupField | ArrayField;
664
+ type DataField = TextField | EmailField | PasswordField | TextareaField | NumberField | DateField | DatetimeField | SelectField | CheckboxGroupField | CheckboxField | SwitchField | RadioField | TagsField | UploadField | GroupField | ArrayField;
631
665
  /**
632
666
  * Layout fields (fields that organize other fields).
633
667
  */
@@ -1139,4 +1173,4 @@ type AdapterFactory<TData = Record<string, unknown>> = (options: AdapterOptions<
1139
1173
  */
1140
1174
  declare function validateAdapter(adapter: FormAdapter, adapterName?: string): void;
1141
1175
 
1142
- export { type ArrayHelpers as A, type BaseField as B, type ConditionContext as C, type DateField as D, type EmailField as E, type Field as F, type GroupField as G, type Tab as H, type TabsField as I, type CollapsibleField as J, type FieldType as K, type DataField as L, type LayoutField as M, type NumberField as N, type BuzzFormSchema as O, type PasswordField as P, type FormSettings as Q, type ResolverResult as R, type SetValueOptions as S, type TextField as T, type UseFormOptions as U, type ValidationContext as V, type FormConfig as a, type FormAdapter as b, type FormState as c, type FieldError as d, type Resolver as e, type AdapterOptions as f, type AdapterFactory as g, type ValidationResult as h, type ValidationFn as i, type FieldCondition as j, type FieldComponentProps as k, type FieldInputProps as l, type FieldInputRenderFn as m, type FieldStyle as n, type TextareaField as o, type DatetimeField as p, type SelectOption as q, type SelectField as r, type CheckboxField as s, type SwitchField as t, type RadioField as u, validateAdapter as v, type TagsField as w, type UploadField as x, type ArrayField as y, type RowField as z };
1176
+ export { type ArrayHelpers as A, type BaseField as B, type ConditionContext as C, type DateField as D, type EmailField as E, type Field as F, type GroupField as G, type RowField as H, type Tab as I, type TabsField as J, type CollapsibleField as K, type FieldType as L, type DataField as M, type NumberField as N, type LayoutField as O, type PasswordField as P, type BuzzFormSchema as Q, type ResolverResult as R, type SetValueOptions as S, type TextField as T, type UseFormOptions as U, type ValidationContext as V, type FormSettings as W, type FormConfig as a, type FormAdapter as b, type FormState as c, type FieldError as d, type Resolver as e, type AdapterOptions as f, type AdapterFactory as g, type ValidationResult as h, type ValidationFn as i, type FieldCondition as j, type FieldComponentProps as k, type FieldInputProps as l, type FieldInputRenderFn as m, type FieldStyle as n, type TextareaField as o, type DatetimeField as p, type SelectOption as q, type SelectField as r, type CheckboxGroupField as s, type CheckboxField as t, type SwitchField as u, validateAdapter as v, type RadioField as w, type TagsField as x, type UploadField as y, type ArrayField as z };