@capitaltg/vero 1.9.0 → 1.10.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.
@@ -58,20 +58,27 @@ declare type AlertSize = 'sm' | 'default';
58
58
 
59
59
  declare type AlertVariant = 'success' | 'warning' | 'danger' | 'info';
60
60
 
61
- export declare const Autocomplete: default_2.ForwardRefExoticComponent<AutocompleteProps & default_2.RefAttributes<HTMLButtonElement>>;
61
+ export declare const Autocomplete: <T, K extends keyof T, L extends keyof T>(props: AutocompleteProps<T, K, L> & {
62
+ ref?: default_2.ForwardedRef<HTMLButtonElement>;
63
+ }) => default_2.ReactElement;
62
64
 
63
65
  declare type AutocompleteFormAttributes = Pick<React.SelectHTMLAttributes<HTMLSelectElement>, 'name' | 'required' | 'autoFocus'>;
64
66
 
65
- export declare interface AutocompleteOption {
66
- value: string;
67
- label: string;
68
- }
69
-
70
- export declare interface AutocompleteProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'disabled'>, AutocompleteFormAttributes {
71
- loadOptions?: (inputValue: string) => Promise<AutocompleteOption[]>;
72
- options?: AutocompleteOption[];
73
- value: string;
74
- onChange: (value: string) => void;
67
+ export declare interface AutocompleteProps<T, K extends keyof T, L extends keyof T> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'disabled' | 'value'>, AutocompleteFormAttributes {
68
+ loadOptions?: (inputValue: string) => Promise<T[]>;
69
+ options?: T[];
70
+ value: T[K] | '';
71
+ /**
72
+ * The key to use for the value property in option objects.
73
+ * Must be a key of T.
74
+ */
75
+ valueKey: K;
76
+ /**
77
+ * The key to use for the label property in option objects.
78
+ * Must be a key of T.
79
+ */
80
+ labelKey: L;
81
+ onChange: (value: T[K]) => void;
75
82
  placeholder?: string;
76
83
  emptyMessage?: string;
77
84
  className?: string;
@@ -83,6 +90,12 @@ export declare interface AutocompleteProps extends Omit<ButtonHTMLAttributes<HTM
83
90
  errorMessage?: string;
84
91
  zIndex?: number;
85
92
  isDisabled?: boolean;
93
+ /**
94
+ * Custom render function for each option.
95
+ * Receives the option of type T and returns a React node.
96
+ * If not provided, defaults to rendering a Check icon and the option label.
97
+ */
98
+ renderOption?: (option: T, isSelected: boolean) => React.ReactNode;
86
99
  /**
87
100
  * The name attribute for form submission.
88
101
  * This is required for the autocomplete value to be included in form data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capitaltg/vero",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Accessible, modern, open source React component library inspired by USWDS built with Radix UI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",