@capyx/components-library 0.0.1 → 0.0.3

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.
Files changed (72) hide show
  1. package/README.md +250 -210
  2. package/dist/addons/AutocompleteInput.d.ts +40 -0
  3. package/dist/addons/AutocompleteInput.d.ts.map +1 -0
  4. package/dist/addons/AutocompleteInput.js +101 -0
  5. package/dist/addons/CharacterCountInput.d.ts +73 -0
  6. package/dist/addons/CharacterCountInput.d.ts.map +1 -0
  7. package/dist/addons/CharacterCountInput.js +130 -0
  8. package/dist/addons/index.d.ts +5 -0
  9. package/dist/addons/index.d.ts.map +1 -0
  10. package/dist/addons/index.js +2 -0
  11. package/dist/components/CheckInput.d.ts +49 -0
  12. package/dist/components/CheckInput.d.ts.map +1 -0
  13. package/dist/components/CheckInput.js +58 -0
  14. package/dist/components/DateInput.d.ts +63 -0
  15. package/dist/components/DateInput.d.ts.map +1 -0
  16. package/dist/components/DateInput.js +86 -0
  17. package/dist/components/FileInput.d.ts +102 -0
  18. package/dist/components/FileInput.d.ts.map +1 -0
  19. package/dist/components/FileInput.js +164 -0
  20. package/dist/components/RichTextInput.d.ts +34 -0
  21. package/dist/components/RichTextInput.d.ts.map +1 -0
  22. package/dist/components/RichTextInput.js +57 -0
  23. package/dist/components/SelectInput.d.ts +54 -0
  24. package/dist/components/SelectInput.d.ts.map +1 -0
  25. package/dist/components/SelectInput.js +64 -0
  26. package/dist/components/SwitchInput.d.ts +46 -0
  27. package/dist/components/SwitchInput.d.ts.map +1 -0
  28. package/dist/components/SwitchInput.js +53 -0
  29. package/dist/components/TagsInput.d.ts +35 -0
  30. package/dist/components/TagsInput.d.ts.map +1 -0
  31. package/dist/components/TagsInput.js +67 -0
  32. package/dist/components/TextAreaInput.d.ts +71 -0
  33. package/dist/components/TextAreaInput.d.ts.map +1 -0
  34. package/dist/components/TextAreaInput.js +113 -0
  35. package/dist/components/TextInput.d.ts +68 -0
  36. package/dist/components/TextInput.d.ts.map +1 -0
  37. package/dist/components/TextInput.js +77 -0
  38. package/dist/components/index.d.ts +10 -0
  39. package/dist/components/index.d.ts.map +1 -0
  40. package/dist/index.cjs +18 -0
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/package.json +87 -72
  44. package/.storybook/main.ts +0 -33
  45. package/.storybook/preview.ts +0 -36
  46. package/.storybook/vitest.setup.ts +0 -7
  47. package/biome.json +0 -37
  48. package/lib/addons/CharacterCountInput.tsx +0 -204
  49. package/lib/addons/index.ts +0 -2
  50. package/lib/components/CheckInput.tsx +0 -126
  51. package/lib/components/DateInput.tsx +0 -179
  52. package/lib/components/FileInput.tsx +0 -353
  53. package/lib/components/RichTextInput.tsx +0 -112
  54. package/lib/components/SelectInput.tsx +0 -144
  55. package/lib/components/SwitchInput.tsx +0 -116
  56. package/lib/components/TagsInput.tsx +0 -118
  57. package/lib/components/TextAreaInput.tsx +0 -211
  58. package/lib/components/TextInput.tsx +0 -381
  59. package/stories/CharacterCountInput.stories.tsx +0 -104
  60. package/stories/CheckInput.stories.tsx +0 -80
  61. package/stories/DateInput.stories.tsx +0 -137
  62. package/stories/FileInput.stories.tsx +0 -125
  63. package/stories/RichTextInput.stories.tsx +0 -77
  64. package/stories/SelectInput.stories.tsx +0 -131
  65. package/stories/SwitchInput.stories.tsx +0 -80
  66. package/stories/TagsInput.stories.tsx +0 -69
  67. package/stories/TextAreaInput.stories.tsx +0 -117
  68. package/stories/TextInput.stories.tsx +0 -167
  69. package/vitest.config.ts +0 -37
  70. package/vitest.shims.d.ts +0 -1
  71. /package/{lib/components/index.ts → dist/components/index.js} +0 -0
  72. /package/{lib/index.ts → dist/index.js} +0 -0
package/README.md CHANGED
@@ -1,210 +1,250 @@
1
- # Components Library
2
-
3
- A comprehensive React component library built with TypeScript, React 19, react-hook-form, react-bootstrap, and Material-UI (MUI).
4
-
5
- ## Architecture
6
-
7
- This library follows a clear separation between **Components** and **Addons**:
8
-
9
- ### Components (Base Input Types)
10
-
11
- Components are specific input elements based on HTML input types and specialized use cases:
12
-
13
- - **CheckInput** - Checkbox input for boolean values
14
- - **DateInput** - Date picker with formatted string output (using MUI DatePicker)
15
- - **FileInput** - File upload with validation and preview
16
- - **SelectInput** - Dropdown selection for single/multiple options
17
- - **SwitchInput** - Toggle switch for on/off values
18
- - **TagsInput** - Tag management with MUI Autocomplete
19
- - **TextAreaInput** - Multiline text input with auto-growing height
20
- - **TextInput** - Single-line text input with optional autocomplete
21
-
22
- ### Addons (Enhancement Wrappers)
23
-
24
- Addons wrap existing components to add functionality:
25
-
26
- - **CharacterCountInput** - Adds character counting to text, textarea, or editor inputs
27
- - **EditorAddon** - Wraps TextAreaInput to add rich text editing (ReactQuill)
28
- - **Editor** (Legacy) - Standalone rich text editor (deprecated, use EditorAddon instead)
29
-
30
- ## Features
31
-
32
- - ✅ **React 19** compatible
33
- - ✅ **TypeScript** with full type safety
34
- - ✅ **react-hook-form** integration for form state management and validation
35
- - ✅ **react-bootstrap** for consistent styling
36
- - ✅ **Material-UI (MUI)** for advanced components (DatePicker, Autocomplete)
37
- - ✅ Standalone or form-integrated modes
38
- - ✅ Consistent error handling
39
- - ✅ Customizable styling
40
-
41
- ## Installation
42
-
43
- ```bash
44
- npm install react react-dom react-hook-form react-bootstrap @mui/material @mui/x-date-pickers dayjs react-quill-new react-autosuggest
45
- ```
46
-
47
- ## Usage
48
-
49
- ### Basic Component Usage
50
-
51
- ```tsx
52
- import { TextInput, CheckInput, DateInput } from '@your-package/components-library';
53
- import { FormProvider, useForm } from 'react-hook-form';
54
-
55
- function MyForm() {
56
- const methods = useForm();
57
-
58
- return (
59
- <FormProvider {...methods}>
60
- <form>
61
- <TextInput
62
- name='username'
63
- label='Username'
64
- required
65
- maxLength={50}
66
- />
67
-
68
- <CheckInput
69
- name='terms'
70
- label='I agree to terms'
71
- required
72
- />
73
-
74
- <DateInput
75
- name='birthdate'
76
- label='Date of Birth'
77
- required
78
- />
79
- </form>
80
- </FormProvider>
81
- );
82
- }
83
- ```
84
-
85
- ### Using Addons
86
-
87
- #### Character Count Addon
88
-
89
- ```tsx
90
- import { TextInput, CharacterCountInput } from '@your-package/components-library';
91
-
92
- function MyForm() {
93
- return (
94
- <CharacterCountInput>
95
- <TextInput
96
- name='bio'
97
- label='Biography'
98
- maxLength={200}
99
- />
100
- </CharacterCountInput>
101
- );
102
- }
103
- ```
104
-
105
- #### Editor Addon (Rich Text)
106
-
107
- ```tsx
108
- import { EditorAddon } from '@your-package/components-library';
109
- import { Controller, useFormContext } from 'react-hook-form';
110
-
111
- function MyForm() {
112
- const { control } = useFormContext();
113
-
114
- return (
115
- <Controller
116
- name='content'
117
- control={control}
118
- render={({ field }) => (
119
- <EditorAddon
120
- value={field.value}
121
- onChange={field.onChange}
122
- maxLength={5000}
123
- />
124
- )}
125
- />
126
- );
127
- }
128
- ```
129
-
130
- #### Combining Addons
131
-
132
- ```tsx
133
- import { CharacterCountInput, EditorAddon } from '@your-package/components-library';
134
-
135
- function MyForm() {
136
- const [value, setValue] = useState('');
137
-
138
- return (
139
- <CharacterCountInput>
140
- <EditorAddon
141
- value={value}
142
- onChange={setValue}
143
- maxLength={1000}
144
- />
145
- </CharacterCountInput>
146
- );
147
- }
148
- ```
149
-
150
- ## Component API
151
-
152
- ### Common Props
153
-
154
- All components support these common props when used with react-hook-form:
155
-
156
- - `name: string` (required) - Field name for form registration
157
- - `label?: string` - Label text
158
- - `required?: boolean` - Whether the field is required
159
- - `disabled?: boolean` - Whether the field is disabled
160
-
161
- ### Standalone Mode
162
-
163
- All components can be used without react-hook-form by providing `value` and `onChange` props:
164
-
165
- ```tsx
166
- <TextInput
167
- name='standalone'
168
- value={value}
169
- onChange={(newValue) => setValue(newValue)}
170
- />
171
- ```
172
-
173
- ## Styling
174
-
175
- Components use react-bootstrap and MUI components, making them easy to customize:
176
-
177
- - Override Bootstrap variables for global theming
178
- - Use MUI theme provider for MUI components
179
- - Add custom className props (where supported)
180
-
181
- ## TypeScript Support
182
-
183
- All components are fully typed with TypeScript. Import types as needed:
184
-
185
- ```tsx
186
- import type { TextAreaInputProps, CheckInputProps } from '@your-package/components-library';
187
- ```
188
-
189
- ## React 19 Compatibility
190
-
191
- This library is built and tested with React 19. All components use modern React patterns:
192
-
193
- - Functional components with hooks
194
- - No deprecated lifecycle methods
195
- - No unsafe React APIs
196
- - Full concurrent mode support
197
-
198
- ## Contributing
199
-
200
- When adding new components:
201
-
202
- 1. **Components** go in `lib/components/` - base input types
203
- 2. **Addons** go in `lib/addons/` - wrappers that enhance components
204
- 3. All components must support both react-hook-form and standalone modes
205
- 4. Export types alongside components
206
- 5. Update index files for proper exports
207
-
208
- ## License
209
-
210
- MIT
1
+ # Components Library
2
+
3
+ A comprehensive React component library built with TypeScript, React 19, react-hook-form, react-bootstrap, and Material-UI (MUI).
4
+
5
+ ## Architecture
6
+
7
+ This library follows a clear separation between **Components** and **Addons**:
8
+
9
+ ### Components (Base Input Types)
10
+
11
+ Components are specific input elements based on HTML input types and specialized use cases:
12
+
13
+ - **CheckInput** - Checkbox input for boolean values
14
+ - **DateInput** - Date picker with formatted string output (using MUI DatePicker)
15
+ - **FileInput** - File upload with validation and preview
16
+ - **SelectInput** - Dropdown selection for single/multiple options
17
+ - **SwitchInput** - Toggle switch for on/off values
18
+ - **TagsInput** - Tag management with MUI Autocomplete
19
+ - **TextAreaInput** - Multiline text input with auto-growing height
20
+ - **TextInput** - Single-line text input for various types (text, email, password, number, etc.)
21
+
22
+ ### Addons (Enhancement Wrappers)
23
+
24
+ Addons wrap existing components to add functionality:
25
+
26
+ - **AutocompleteInput** - Adds autocomplete/suggestions dropdown to text inputs
27
+ - **CharacterCountInput** - Adds character counting to text, textarea, or editor inputs
28
+ - **EditorAddon** - Wraps TextAreaInput to add rich text editing (ReactQuill)
29
+ - **Editor** (Legacy) - Standalone rich text editor (deprecated, use EditorAddon instead)
30
+
31
+ ## Features
32
+
33
+ - ✅ **React 19** compatible
34
+ - ✅ **TypeScript** with full type safety and auto-generated type declarations
35
+ - ✅ **ESM and CommonJS** dual module support
36
+ - ✅ **react-hook-form** integration for form state management and validation
37
+ - ✅ **react-bootstrap** for consistent styling
38
+ - ✅ **Material-UI (MUI)** for advanced components (DatePicker, Autocomplete)
39
+ - ✅ Standalone or form-integrated modes
40
+ - ✅ Consistent error handling
41
+ - ✅ Customizable styling
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ npm install @capyx/components-library
47
+ ```
48
+
49
+ ### Peer Dependencies
50
+
51
+ This library requires the following peer dependencies to be installed in your project:
52
+
53
+ ```bash
54
+ npm install react react-dom react-hook-form react-bootstrap @mui/material @mui/x-date-pickers dayjs react-quill-new react-autosuggest
55
+ ```
56
+
57
+ ## TypeScript Support
58
+
59
+ This library is written in TypeScript and includes full type definitions. Type declarations are automatically provided when you install the package, giving you:
60
+
61
+ - Full IntelliSense and autocomplete in your IDE
62
+ - Type checking for component props
63
+ - Improved development experience with inline documentation
64
+
65
+ No additional `@types` packages are needed!
66
+
67
+ ## Usage
68
+
69
+ ### Basic Component Usage
70
+
71
+ ```tsx
72
+ import { TextInput, CheckInput, DateInput } from '@your-package/components-library';
73
+ import { FormProvider, useForm } from 'react-hook-form';
74
+
75
+ function MyForm() {
76
+ const methods = useForm();
77
+
78
+ return (
79
+ <FormProvider {...methods}>
80
+ <form>
81
+ <TextInput
82
+ name='username'
83
+ label='Username'
84
+ required
85
+ maxLength={50}
86
+ />
87
+
88
+ <CheckInput
89
+ name='terms'
90
+ label='I agree to terms'
91
+ required
92
+ />
93
+
94
+ <DateInput
95
+ name='birthdate'
96
+ label='Date of Birth'
97
+ required
98
+ />
99
+ </form>
100
+ </FormProvider>
101
+ );
102
+ }
103
+ ```
104
+
105
+ ### Using Addons
106
+
107
+ #### Autocomplete Addon
108
+
109
+ ```tsx
110
+ import { TextInput, AutocompleteInput } from '@your-package/components-library';
111
+
112
+ function MyForm() {
113
+ const countries = ['USA', 'Canada', 'UK', 'Australia'];
114
+
115
+ return (
116
+ <AutocompleteInput suggestions={countries}>
117
+ <TextInput
118
+ name='country'
119
+ label='Country'
120
+ placeholder='Type to search...'
121
+ />
122
+ </AutocompleteInput>
123
+ );
124
+ }
125
+ ```
126
+
127
+ #### Character Count Addon
128
+
129
+ ```tsx
130
+ import { TextInput, CharacterCountInput } from '@your-package/components-library';
131
+
132
+ function MyForm() {
133
+ return (
134
+ <CharacterCountInput>
135
+ <TextInput
136
+ name='bio'
137
+ label='Biography'
138
+ maxLength={200}
139
+ />
140
+ </CharacterCountInput>
141
+ );
142
+ }
143
+ ```
144
+
145
+ #### Editor Addon (Rich Text)
146
+
147
+ ```tsx
148
+ import { EditorAddon } from '@your-package/components-library';
149
+ import { Controller, useFormContext } from 'react-hook-form';
150
+
151
+ function MyForm() {
152
+ const { control } = useFormContext();
153
+
154
+ return (
155
+ <Controller
156
+ name='content'
157
+ control={control}
158
+ render={({ field }) => (
159
+ <EditorAddon
160
+ value={field.value}
161
+ onChange={field.onChange}
162
+ maxLength={5000}
163
+ />
164
+ )}
165
+ />
166
+ );
167
+ }
168
+ ```
169
+
170
+ #### Combining Addons
171
+
172
+ Addons can be nested to combine their functionality:
173
+
174
+ ```tsx
175
+ import { TextInput, AutocompleteInput, CharacterCountInput } from '@your-package/components-library';
176
+
177
+ function MyForm() {
178
+ const cities = ['New York', 'Los Angeles', 'Chicago', 'Houston'];
179
+
180
+ return (
181
+ <CharacterCountInput>
182
+ <AutocompleteInput suggestions={cities}>
183
+ <TextInput
184
+ name='city'
185
+ label='City'
186
+ maxLength={50}
187
+ />
188
+ </AutocompleteInput>
189
+ </CharacterCountInput>
190
+ );
191
+ }
192
+ ```
193
+
194
+ ## Component API
195
+
196
+ ### Common Props
197
+
198
+ All components support these common props when used with react-hook-form:
199
+
200
+ - `name: string` (required) - Field name for form registration
201
+ - `label?: string` - Label text
202
+ - `required?: boolean` - Whether the field is required
203
+ - `disabled?: boolean` - Whether the field is disabled
204
+
205
+ ### Standalone Mode
206
+
207
+ All components can be used without react-hook-form by providing `value` and `onChange` props:
208
+
209
+ ```tsx
210
+ <TextInput
211
+ name='standalone'
212
+ value={value}
213
+ onChange={(newValue) => setValue(newValue)}
214
+ />
215
+ ```
216
+
217
+ ## Styling
218
+
219
+ Components use react-bootstrap and MUI components, making them easy to customize:
220
+
221
+ - Override Bootstrap variables for global theming
222
+ - Use MUI theme provider for MUI components
223
+ - Add custom className props (where supported)
224
+
225
+ ## TypeScript Support
226
+
227
+ All components are fully typed with TypeScript. Import types as needed:
228
+
229
+ ```tsx
230
+ import type { TextAreaInputProps, CheckInputProps } from '@your-package/components-library';
231
+ ```
232
+
233
+ ## React 19 Compatibility
234
+
235
+ This library is built and tested with React 19. All components use modern React patterns:
236
+
237
+ - Functional components with hooks
238
+ - No deprecated lifecycle methods
239
+ - No unsafe React APIs
240
+ - Full concurrent mode support
241
+
242
+ ## Contributing
243
+
244
+ When adding new components:
245
+
246
+ 1. **Components** go in `lib/components/` - base input types
247
+ 2. **Addons** go in `lib/addons/` - wrappers that enhance components
248
+ 3. All components must support both react-hook-form and standalone modes
249
+ 4. Export types alongside components
250
+ 5. Update index files for proper exports
@@ -0,0 +1,40 @@
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ /**
3
+ * Props for the AutocompleteInput component
4
+ */
5
+ export type AutocompleteInputProps = PropsWithChildren<{
6
+ /** Array of suggestion values for autocomplete */
7
+ suggestions: string[];
8
+ /** Whether to highlight the first suggestion (default: true) */
9
+ highlightFirstSuggestion?: boolean;
10
+ }>;
11
+ /**
12
+ * AutocompleteInput - A wrapper addon that adds autocomplete/suggestions to text inputs
13
+ *
14
+ * Wraps any text input component (like TextInput) and enhances it with dropdown
15
+ * suggestions that filter based on user input. Works seamlessly with both standalone
16
+ * and react-hook-form integrated inputs.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // With react-hook-form
21
+ * <AutocompleteInput suggestions={["USA", "Canada", "UK"]}>
22
+ * <TextInput
23
+ * name="country"
24
+ * label="Country"
25
+ * placeholder="Type to search..."
26
+ * />
27
+ * </AutocompleteInput>
28
+ *
29
+ * // Standalone mode
30
+ * <AutocompleteInput suggestions={skills}>
31
+ * <TextInput
32
+ * name="skill"
33
+ * value={value}
34
+ * onChange={setValue}
35
+ * />
36
+ * </AutocompleteInput>
37
+ * ```
38
+ */
39
+ export declare const AutocompleteInput: FC<AutocompleteInputProps>;
40
+ //# sourceMappingURL=AutocompleteInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutocompleteInput.d.ts","sourceRoot":"","sources":["../../lib/addons/AutocompleteInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AAKjF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;IACtD,kDAAkD;IAClD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gEAAgE;IAChE,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAgHxD,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cloneElement, useEffect, useRef, useState } from 'react';
3
+ import Autosuggest from 'react-autosuggest';
4
+ import { useFormContext } from 'react-hook-form';
5
+ /**
6
+ * AutocompleteInput - A wrapper addon that adds autocomplete/suggestions to text inputs
7
+ *
8
+ * Wraps any text input component (like TextInput) and enhances it with dropdown
9
+ * suggestions that filter based on user input. Works seamlessly with both standalone
10
+ * and react-hook-form integrated inputs.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * // With react-hook-form
15
+ * <AutocompleteInput suggestions={["USA", "Canada", "UK"]}>
16
+ * <TextInput
17
+ * name="country"
18
+ * label="Country"
19
+ * placeholder="Type to search..."
20
+ * />
21
+ * </AutocompleteInput>
22
+ *
23
+ * // Standalone mode
24
+ * <AutocompleteInput suggestions={skills}>
25
+ * <TextInput
26
+ * name="skill"
27
+ * value={value}
28
+ * onChange={setValue}
29
+ * />
30
+ * </AutocompleteInput>
31
+ * ```
32
+ */
33
+ export const AutocompleteInput = ({ suggestions: allSuggestions, children, highlightFirstSuggestion = true, }) => {
34
+ const formContext = useFormContext();
35
+ const [filteredSuggestions, setFilteredSuggestions] = useState([]);
36
+ const [inputValue, setInputValue] = useState('');
37
+ const nameRef = useRef('');
38
+ // Extract child props
39
+ const childElement = children;
40
+ const childProps = childElement?.props;
41
+ const name = childProps?.name || '';
42
+ nameRef.current = name;
43
+ // Sync input value with form context or child value
44
+ useEffect(() => {
45
+ if (formContext && name) {
46
+ const formValue = formContext.getValues(name);
47
+ setInputValue(formValue || '');
48
+ }
49
+ else if (childProps?.value !== undefined) {
50
+ setInputValue(String(childProps.value));
51
+ }
52
+ }, [formContext, name, childProps?.value]);
53
+ // Filter suggestions based on input value
54
+ const getSuggestions = (value) => {
55
+ const trimmedValue = value.trim().toLowerCase();
56
+ if (trimmedValue.length === 0)
57
+ return [];
58
+ return allSuggestions.filter((suggestion) => suggestion.toLowerCase().includes(trimmedValue));
59
+ };
60
+ const onSuggestionsFetchRequested = ({ value }) => {
61
+ setFilteredSuggestions(getSuggestions(value));
62
+ };
63
+ const onSuggestionsClearRequested = () => {
64
+ setFilteredSuggestions([]);
65
+ };
66
+ const getSuggestionValue = (suggestion) => suggestion;
67
+ const renderSuggestion = (suggestion) => _jsx("span", { children: suggestion });
68
+ const handleChange = (_event, { newValue }) => {
69
+ setInputValue(newValue);
70
+ // Update form context if available
71
+ if (formContext && name) {
72
+ formContext.setValue(name, newValue);
73
+ }
74
+ // Call child's onChange if provided
75
+ childProps?.onChange?.(newValue);
76
+ };
77
+ return (_jsx(Autosuggest, { suggestions: filteredSuggestions, onSuggestionsFetchRequested: onSuggestionsFetchRequested, onSuggestionsClearRequested: onSuggestionsClearRequested, getSuggestionValue: getSuggestionValue, renderSuggestion: renderSuggestion, highlightFirstSuggestion: highlightFirstSuggestion, inputProps: {
78
+ value: inputValue,
79
+ onChange: handleChange,
80
+ }, renderInputComponent: (inputProps) => {
81
+ // Clone the child element and merge with autosuggest props
82
+ const { value, onChange: autosuggestOnChange, ...autosuggestProps } = inputProps;
83
+ return cloneElement(childElement, {
84
+ ...autosuggestProps,
85
+ value,
86
+ onChange: (newValue) => {
87
+ // Handle both event objects and direct values
88
+ const actualValue = typeof newValue === 'string'
89
+ ? newValue
90
+ : newValue?.target
91
+ ?.value || '';
92
+ // Create synthetic event for Autosuggest
93
+ const syntheticEvent = {};
94
+ autosuggestOnChange?.(syntheticEvent, {
95
+ newValue: actualValue,
96
+ method: 'type',
97
+ });
98
+ },
99
+ });
100
+ } }));
101
+ };