{"version":3,"file":"getDisplayedFieldValue.js","names":["getTranslation","isValidReactElement","getDisplayedFieldValue","cellData","field","i18n","type","Array","isArray","options","selectedOption","find","opt","value","label"],"sources":["../../src/utilities/getDisplayedFieldValue.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nimport { isValidReactElement } from './isValidReactElement.js'\n\n/**\n * Returns the appropriate display value for a field.\n * - For select and radio fields:\n * - Returns JSX elements as-is.\n * - Translates localized label objects based on the current language.\n * - Returns string labels directly.\n * - Falls back to the option value if no valid label is found.\n * - For all other field types, returns `cellData` unchanged.\n */\nexport const getDisplayedFieldValue = (cellData: any, field: ClientField, i18n: I18nClient) => {\n if ((field?.type === 'select' || field?.type === 'radio') && Array.isArray(field.options)) {\n const selectedOption = field.options.find((opt) =>\n typeof opt === 'object' ? opt.value === cellData : opt === cellData,\n )\n\n if (selectedOption) {\n if (typeof selectedOption === 'object' && 'label' in selectedOption) {\n return isValidReactElement(selectedOption.label)\n ? selectedOption.label // Return JSX directly\n : getTranslation(selectedOption.label, i18n) || selectedOption.value // Use translation or fallback to value\n }\n return selectedOption // If option is a string, return it directly\n }\n }\n return cellData // Default fallback if no match found\n}\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAE/B,SAASC,mBAAmB,QAAQ;AAEpC;;;;;;;;;AASA,OAAO,MAAMC,sBAAA,GAAyBA,CAACC,QAAA,EAAeC,KAAA,EAAoBC,IAAA;EACxE,IAAI,CAACD,KAAA,EAAOE,IAAA,KAAS,YAAYF,KAAA,EAAOE,IAAA,KAAS,OAAM,KAAMC,KAAA,CAAMC,OAAO,CAACJ,KAAA,CAAMK,OAAO,GAAG;IACzF,MAAMC,cAAA,GAAiBN,KAAA,CAAMK,OAAO,CAACE,IAAI,CAAEC,GAAA,IACzC,OAAOA,GAAA,KAAQ,WAAWA,GAAA,CAAIC,KAAK,KAAKV,QAAA,GAAWS,GAAA,KAAQT,QAAA;IAG7D,IAAIO,cAAA,EAAgB;MAClB,IAAI,OAAOA,cAAA,KAAmB,YAAY,WAAWA,cAAA,EAAgB;QACnE,OAAOT,mBAAA,CAAoBS,cAAA,CAAeI,KAAK,IAC3CJ,cAAA,CAAeI,KAAK,CAAC;QAAA,EACrBd,cAAA,CAAeU,cAAA,CAAeI,KAAK,EAAET,IAAA,KAASK,cAAA,CAAeG,KAAK,CAAC;AAAA;MACzE;MACA,OAAOH,cAAA,CAAe;AAAA;IACxB;EACF;EACA,OAAOP,QAAA,CAAS;AAAA;AAClB","ignoreList":[]}