Commit Graph

1 Commits

Author SHA1 Message Date
MehrdadAdabi
6634ecfda7 feat(dropdown): Add async option fetching and improve search
This commit introduces the ability to fetch dropdown options asynchronously, enhancing the component's flexibility for large datasets or dynamic content.

Key changes include:
- **`fetchOptions` prop:** A new prop `fetchOptions` is added to allow external functions to provide options based on the current search query.
- **Internal state for options:** `internalOptions` state is introduced to manage options, which can be populated either from the initial `options` prop or by `fetchOptions`.
- **Loading state:** `isLoading` state is added to indicate when options are being fetched.
- **Improved search handling:** The `handleSearchInputChange` function now triggers `fetchOptions` when available, allowing real-time filtering from an external source.
- **Option type update:** The `Option` type now uses `name` instead of `label` for consistency.
- **Selected option display:** The displayed selected option now uses `value` instead of `label` for consistency.

These changes make the `BaseDropdown` component more robust and adaptable to various data sources, especially for scenarios requiring dynamic or remote option loading.
2025-11-25 16:59:12 +03:30