@tellescope/react-components 1.237.6 → 1.238.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.237.6",
3
+ "version": "1.238.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -47,13 +47,13 @@
47
47
  "@reduxjs/toolkit": "1.9.0",
48
48
  "@stripe/react-stripe-js": "2.9.0",
49
49
  "@stripe/stripe-js": "1.52.1",
50
- "@tellescope/constants": "1.237.6",
51
- "@tellescope/sdk": "1.237.6",
52
- "@tellescope/types-client": "1.237.6",
53
- "@tellescope/types-models": "1.237.6",
54
- "@tellescope/types-utilities": "1.237.6",
55
- "@tellescope/utilities": "1.237.6",
56
- "@tellescope/validation": "1.237.6",
50
+ "@tellescope/constants": "1.238.0",
51
+ "@tellescope/sdk": "1.238.0",
52
+ "@tellescope/types-client": "1.238.0",
53
+ "@tellescope/types-models": "1.238.0",
54
+ "@tellescope/types-utilities": "1.238.0",
55
+ "@tellescope/utilities": "1.238.0",
56
+ "@tellescope/validation": "1.238.0",
57
57
  "@typescript-eslint/eslint-plugin": "4.33.0",
58
58
  "@typescript-eslint/parser": "4.33.0",
59
59
  "css-to-react-native": "3.0.0",
@@ -83,7 +83,7 @@
83
83
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
84
84
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
85
85
  },
86
- "gitHead": "27e63e1df7af12bc985c2717d9bbb15bcc684e51",
86
+ "gitHead": "4986230d93e81703dbf27e595f8949645b35cdba",
87
87
  "publishConfig": {
88
88
  "access": "public"
89
89
  }
@@ -2885,6 +2885,7 @@ export const DatabaseSelectInput = ({ AddToDatabase, field, value: _value, onCha
2885
2885
  }) => {
2886
2886
  const [typing, setTyping] = useState('')
2887
2887
  const [open, setOpen] = useState(false)
2888
+ const selectedRecordsCache = useRef<Map<string, DatabaseRecord>>(new Map())
2888
2889
  const { addChoice, choices, doneLoading, isSearching, minSearchChars } = useDatabaseChoices({
2889
2890
  databaseId: field.options?.databaseId,
2890
2891
  field,
@@ -2894,15 +2895,29 @@ export const DatabaseSelectInput = ({ AddToDatabase, field, value: _value, onCha
2894
2895
 
2895
2896
  const value = React.useMemo(() => {
2896
2897
  try {
2897
- // if the value is a string (some single answer that was save), make sure we coerce to array
2898
+ // if the value is a string (some single answer that was saved), make sure we coerce to array
2898
2899
  const __value = typeof _value === 'string' ? [_value] : _value
2899
- return (
2900
- (__value?.map(v =>
2901
- choices.find(c =>
2902
- c.id === v.recordId || (typeof v === 'string' && label_for_database_record(field, c) === v)
2903
- )
2904
- )?.filter(v => v!) ?? []) as DatabaseRecord[]
2905
- )
2900
+ const result: DatabaseRecord[] = []
2901
+
2902
+ for (const v of (__value ?? [])) {
2903
+ const recordId = typeof v === 'string' ? v : v.recordId
2904
+
2905
+ // First try to find in current choices
2906
+ const found = choices.find(c =>
2907
+ c.id === recordId || (typeof v === 'string' && label_for_database_record(field, c) === v)
2908
+ )
2909
+
2910
+ if (found) {
2911
+ // Update cache with found record
2912
+ selectedRecordsCache.current.set(found.id, found as DatabaseRecord)
2913
+ result.push(found as DatabaseRecord)
2914
+ } else if (recordId && selectedRecordsCache.current.has(recordId)) {
2915
+ // Use cached record if not in current choices (e.g., during search)
2916
+ result.push(selectedRecordsCache.current.get(recordId)!)
2917
+ }
2918
+ }
2919
+
2920
+ return result
2906
2921
  } catch(err) {
2907
2922
  console.error('Error resolving database answers for _value', err)
2908
2923
  return []