@payloadcms/ui 3.50.0-canary.3 → 3.50.0-internal.759bb98
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/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +2 -1
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Toasts/fieldErrors.d.ts.map +1 -1
- package/dist/elements/Toasts/fieldErrors.js +4 -1
- package/dist/elements/Toasts/fieldErrors.js.map +1 -1
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +4 -4
- package/dist/utilities/getDisplayedFieldValue.d.ts.map +1 -1
- package/dist/utilities/getDisplayedFieldValue.js +2 -2
- package/dist/utilities/getDisplayedFieldValue.js.map +1 -1
- package/dist/utilities/hasOptionLabelJSXElement.js +2 -2
- package/dist/utilities/hasOptionLabelJSXElement.js.map +1 -1
- package/dist/utilities/isValidReactElement.d.ts +7 -0
- package/dist/utilities/isValidReactElement.d.ts.map +1 -0
- package/dist/utilities/isValidReactElement.js +10 -0
- package/dist/utilities/isValidReactElement.js.map +1 -0
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDisplayedFieldValue.d.ts","sourceRoot":"","sources":["../../src/utilities/getDisplayedFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getDisplayedFieldValue.d.ts","sourceRoot":"","sources":["../../src/utilities/getDisplayedFieldValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAM1C;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,aAAc,GAAG,SAAS,WAAW,QAAQ,UAAU,QAgBzF,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
|
-
import
|
|
2
|
+
import { isValidReactElement } from './isValidReactElement.js';
|
|
3
3
|
/**
|
|
4
4
|
* Returns the appropriate display value for a field.
|
|
5
5
|
* - For select and radio fields:
|
|
@@ -14,7 +14,7 @@ export const getDisplayedFieldValue = (cellData, field, i18n) => {
|
|
|
14
14
|
const selectedOption = field.options.find(opt => typeof opt === 'object' ? opt.value === cellData : opt === cellData);
|
|
15
15
|
if (selectedOption) {
|
|
16
16
|
if (typeof selectedOption === 'object' && 'label' in selectedOption) {
|
|
17
|
-
return
|
|
17
|
+
return isValidReactElement(selectedOption.label) ? selectedOption.label // Return JSX directly
|
|
18
18
|
: getTranslation(selectedOption.label, i18n) || selectedOption.value // Use translation or fallback to value
|
|
19
19
|
;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDisplayedFieldValue.js","names":["getTranslation","
|
|
1
|
+
{"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;QAAA;MACzE;MACA,OAAOH,cAAA,CAAe;MAAA;IACxB;EACF;EACA,OAAOP,QAAA,CAAS;EAAA;AAClB","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isValidReactElement } from './isValidReactElement.js';
|
|
2
2
|
export const hasOptionLabelJSXElement = cellClientProps => {
|
|
3
3
|
const {
|
|
4
4
|
cellData,
|
|
@@ -6,7 +6,7 @@ export const hasOptionLabelJSXElement = cellClientProps => {
|
|
|
6
6
|
} = cellClientProps;
|
|
7
7
|
if ((field?.type === 'select' || field?.type == 'radio') && Array.isArray(field?.options)) {
|
|
8
8
|
const matchingOption = field.options.find(option => typeof option === 'object' && option.value === cellData);
|
|
9
|
-
if (matchingOption && typeof matchingOption === 'object' &&
|
|
9
|
+
if (matchingOption && typeof matchingOption === 'object' && isValidReactElement(matchingOption.label)) {
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasOptionLabelJSXElement.js","names":["
|
|
1
|
+
{"version":3,"file":"hasOptionLabelJSXElement.js","names":["isValidReactElement","hasOptionLabelJSXElement","cellClientProps","cellData","field","type","Array","isArray","options","matchingOption","find","option","value","label"],"sources":["../../src/utilities/hasOptionLabelJSXElement.ts"],"sourcesContent":["import type { DefaultCellComponentProps } from 'payload'\n\nimport { isValidReactElement } from './isValidReactElement.js'\n\nexport const hasOptionLabelJSXElement = (cellClientProps: DefaultCellComponentProps) => {\n const { cellData, field } = cellClientProps\n\n if ((field?.type === 'select' || field?.type == 'radio') && Array.isArray(field?.options)) {\n const matchingOption = field.options.find(\n (option) => typeof option === 'object' && option.value === cellData,\n )\n\n if (\n matchingOption &&\n typeof matchingOption === 'object' &&\n isValidReactElement(matchingOption.label)\n ) {\n return true\n }\n }\n\n return false\n}\n"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,wBAAA,GAA4BC,eAAA;EACvC,MAAM;IAAEC,QAAQ;IAAEC;EAAK,CAAE,GAAGF,eAAA;EAE5B,IAAI,CAACE,KAAA,EAAOC,IAAA,KAAS,YAAYD,KAAA,EAAOC,IAAA,IAAQ,OAAM,KAAMC,KAAA,CAAMC,OAAO,CAACH,KAAA,EAAOI,OAAA,GAAU;IACzF,MAAMC,cAAA,GAAiBL,KAAA,CAAMI,OAAO,CAACE,IAAI,CACtCC,MAAA,IAAW,OAAOA,MAAA,KAAW,YAAYA,MAAA,CAAOC,KAAK,KAAKT,QAAA;IAG7D,IACEM,cAAA,IACA,OAAOA,cAAA,KAAmB,YAC1BT,mBAAA,CAAoBS,cAAA,CAAeI,KAAK,GACxC;MACA,OAAO;IACT;EACF;EAEA,OAAO;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Since Next.js 15.4, `React.isValidElement()` returns `false` for components that cross the server-client boundary.
|
|
4
|
+
* This utility expands on that check so that it returns true for valid React elements.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isValidReactElement<P>(object: {} | null | undefined): object is ReactElement<P>;
|
|
7
|
+
//# sourceMappingURL=isValidReactElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidReactElement.d.ts","sourceRoot":"","sources":["../../src/utilities/isValidReactElement.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AAIhD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CAE/F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
const LazyReactComponentSymbol = Symbol.for('react.lazy');
|
|
3
|
+
/**
|
|
4
|
+
* Since Next.js 15.4, `React.isValidElement()` returns `false` for components that cross the server-client boundary.
|
|
5
|
+
* This utility expands on that check so that it returns true for valid React elements.
|
|
6
|
+
*/
|
|
7
|
+
export function isValidReactElement(object) {
|
|
8
|
+
return React.isValidElement(object) || object?.['$$typeof'] === LazyReactComponentSymbol;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=isValidReactElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidReactElement.js","names":["React","LazyReactComponentSymbol","Symbol","for","isValidReactElement","object","isValidElement"],"sources":["../../src/utilities/isValidReactElement.ts"],"sourcesContent":["import React, { type ReactElement } from 'react'\n\nconst LazyReactComponentSymbol = Symbol.for('react.lazy')\n\n/**\n * Since Next.js 15.4, `React.isValidElement()` returns `false` for components that cross the server-client boundary.\n * This utility expands on that check so that it returns true for valid React elements.\n */\nexport function isValidReactElement<P>(object: {} | null | undefined): object is ReactElement<P> {\n return React.isValidElement(object) || object?.['$$typeof'] === LazyReactComponentSymbol\n}\n"],"mappings":"AAAA,OAAOA,KAAA,MAAkC;AAEzC,MAAMC,wBAAA,GAA2BC,MAAA,CAAOC,GAAG,CAAC;AAE5C;;;;AAIA,OAAO,SAASC,oBAAuBC,MAA6B;EAClE,OAAOL,KAAA,CAAMM,cAAc,CAACD,MAAA,KAAWA,MAAA,GAAS,WAAW,KAAKJ,wBAAA;AAClE","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.50.0-
|
|
3
|
+
"version": "3.50.0-internal.759bb98",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"ts-essentials": "10.0.3",
|
|
137
137
|
"use-context-selector": "2.0.0",
|
|
138
138
|
"uuid": "10.0.0",
|
|
139
|
-
"@payloadcms/translations": "3.50.0-
|
|
139
|
+
"@payloadcms/translations": "3.50.0-internal.759bb98"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"@babel/cli": "7.27.2",
|
|
@@ -145,20 +145,20 @@
|
|
|
145
145
|
"@babel/preset-react": "7.27.1",
|
|
146
146
|
"@babel/preset-typescript": "7.27.1",
|
|
147
147
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
148
|
-
"@types/react": "19.1.
|
|
149
|
-
"@types/react-dom": "19.1.
|
|
148
|
+
"@types/react": "19.1.8",
|
|
149
|
+
"@types/react-dom": "19.1.6",
|
|
150
150
|
"@types/uuid": "10.0.0",
|
|
151
151
|
"babel-plugin-react-compiler": "19.1.0-rc.2",
|
|
152
152
|
"esbuild": "0.25.5",
|
|
153
153
|
"esbuild-sass-plugin": "3.3.1",
|
|
154
154
|
"@payloadcms/eslint-config": "3.28.0",
|
|
155
|
-
"payload": "3.50.0-
|
|
155
|
+
"payload": "3.50.0-internal.759bb98"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"next": "^15.2.3",
|
|
159
159
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
160
160
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
161
|
-
"payload": "3.50.0-
|
|
161
|
+
"payload": "3.50.0-internal.759bb98"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": "^18.20.2 || >=20.9.0"
|