@dev-fastn-ai/react-core 2.4.1 → 2.4.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 (2) hide show
  1. package/README.md +14 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -603,7 +603,15 @@ For fields of type `select` or `multi-select`, use the `useFieldOptions` hook to
603
603
  ```tsx
604
604
  import { useFieldOptions } from "@fastn-ai/react-core";
605
605
 
606
- function SelectField({ field, value, onChange, isMulti = false, context }) {
606
+ interface SelectFieldProps {
607
+ field: any;
608
+ value: any;
609
+ onChange: (value: any) => void;
610
+ isMulti?: boolean;
611
+ context?: any;
612
+ }
613
+
614
+ function SelectField({ field, value, onChange, isMulti = false, context }: SelectFieldProps) {
607
615
  const {
608
616
  options,
609
617
  loading,
@@ -615,7 +623,7 @@ function SelectField({ field, value, onChange, isMulti = false, context }) {
615
623
  totalLoadedOptions,
616
624
  } = useFieldOptions(field, context);
617
625
 
618
- function handleInputChange(e) {
626
+ function handleInputChange(e: React.ChangeEvent<HTMLInputElement>) {
619
627
  search(e.target.value);
620
628
  }
621
629
 
@@ -623,7 +631,7 @@ function SelectField({ field, value, onChange, isMulti = false, context }) {
623
631
  if (hasNext && !loadingMore) loadMore();
624
632
  }
625
633
 
626
- function handleSelectChange(selectedOptions) {
634
+ function handleSelectChange(selectedOptions: Array<{ label: string; value: any }>) {
627
635
  if (isMulti) {
628
636
  // For multi-select, value should be an array of { label, value } objects
629
637
  const selectedValues = selectedOptions.map(option => ({
@@ -664,12 +672,12 @@ function SelectField({ field, value, onChange, isMulti = false, context }) {
664
672
 
665
673
  <select
666
674
  multiple={isMulti}
667
- value={isMulti ? (value || []).map(v => v.value) : (value?.value || '')}
668
- onChange={(e) => {
675
+ value={isMulti ? (value || []).map((v: any) => v.value) : (value?.value || '')}
676
+ onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
669
677
  if (isMulti) {
670
678
  const selectedOptions = Array.from(e.target.selectedOptions).map(option => {
671
679
  const opt = options.find(o => o.value === option.value);
672
- return { label: opt.label, value: opt.value };
680
+ return { label: opt?.label || '', value: opt?.value };
673
681
  });
674
682
  handleSelectChange(selectedOptions);
675
683
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-fastn-ai/react-core",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "React hooks and components for integrating Fastn AI connector marketplace into your applications. Built on top of @fastn-ai/core with React Query for optimal performance.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",