@payloadcms/ui 3.50.0-canary.2 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAqB,MAAM,SAAS,CAAA;AAI3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAuJ3D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAqB,MAAM,SAAS,CAAA;AAI3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAWzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAuJ3D,CAAA"}
@@ -9,6 +9,7 @@ import { useConfig } from '../../../providers/Config/index.js';
9
9
  import { useTranslation } from '../../../providers/Translation/index.js';
10
10
  import { formatAdminURL } from '../../../utilities/formatAdminURL.js';
11
11
  import { getDisplayedFieldValue } from '../../../utilities/getDisplayedFieldValue.js';
12
+ import { isValidReactElement } from '../../../utilities/isValidReactElement.js';
12
13
  import { Link } from '../../Link/index.js';
13
14
  import { CodeCell } from './fields/Code/index.js';
14
15
  import { cellComponents } from './fields/index.js';
@@ -95,7 +96,7 @@ export const DefaultCell = props => {
95
96
  const displayedValue = getDisplayedFieldValue(cellData, field, i18n);
96
97
  const DefaultCellComponent = typeof cellData !== "undefined" && cellComponents[field.type];
97
98
  let CellComponent = null;
98
- if (React.isValidElement(displayedValue)) {
99
+ if (isValidReactElement(displayedValue)) {
99
100
  CellComponent = displayedValue;
100
101
  } else {
101
102
  if (DefaultCellComponent) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","getTranslation","fieldAffectsData","fieldIsID","React","useConfig","useTranslation","formatAdminURL","getDisplayedFieldValue","Link","CodeCell","cellComponents","DefaultCell","props","$","cellData","className","classNameFromProps","collectionSlug","field","t0","link","onClick","onClickFromProps","rowData","viewType","admin","i18n","config","t1","getEntityConfig","routes","t2","adminRoute","t3","t4","Symbol","for","collectionConfig","classNameFromConfigContext","undefined","WrapElement","wrapElementProps","prefetch","href","slug","path","encodeURIComponent","id","type","_jsx","children","nowrap","displayedValue","DefaultCellComponent","CellComponent","isValidElement","upload","name","FileCellComponent","File","_jsxs","t","label","JSON","stringify","options","length","classes","Array","isArray","map","_temp","join","className_0","filter","Boolean","value"],"sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps, UploadFieldClient } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { fieldAffectsData, fieldIsID } from 'payload/shared'\nimport React from 'react' // TODO: abstract this out to support all routers\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatAdminURL } from '../../../utilities/formatAdminURL.js'\nimport { getDisplayedFieldValue } from '../../../utilities/getDisplayedFieldValue.js'\nimport { Link } from '../../Link/index.js'\nimport { CodeCell } from './fields/Code/index.js'\nimport { cellComponents } from './fields/index.js'\n\nexport const DefaultCell: React.FC<DefaultCellComponentProps> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionSlug,\n field,\n field: { admin },\n link,\n onClick: onClickFromProps,\n rowData,\n viewType,\n } = props\n\n const { i18n } = useTranslation()\n\n const {\n config: {\n routes: { admin: adminRoute },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}${viewType === 'trash' ? '/trash' : ''}/${encodeURIComponent(rowData.id)}`,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n if (fieldIsID(field)) {\n return (\n <WrapElement {...wrapElementProps}>\n <CodeCell\n cellData={`ID: ${cellData}`}\n collectionConfig={collectionConfig}\n collectionSlug={collectionSlug}\n field={{\n ...field,\n type: 'code',\n }}\n nowrap\n rowData={rowData}\n />\n </WrapElement>\n )\n }\n\n const displayedValue = getDisplayedFieldValue(cellData, field, i18n)\n\n const DefaultCellComponent: React.FC<DefaultCellComponentProps> =\n typeof cellData !== 'undefined' && cellComponents[field.type]\n\n let CellComponent: React.ReactNode = null\n\n // Handle JSX labels before using DefaultCellComponent\n if (React.isValidElement(displayedValue)) {\n CellComponent = displayedValue\n } else if (DefaultCellComponent) {\n CellComponent = <DefaultCellComponent cellData={cellData} rowData={rowData} {...props} />\n } else if (!DefaultCellComponent) {\n // DefaultCellComponent does not exist for certain field types like `text`\n if (\n collectionConfig?.upload &&\n fieldAffectsData(field) &&\n field.name === 'filename' &&\n field.type === 'text'\n ) {\n const FileCellComponent = cellComponents.File\n\n CellComponent = (\n <FileCellComponent\n cellData={cellData}\n rowData={rowData}\n {...(props as DefaultCellComponentProps<UploadFieldClient>)}\n collectionConfig={collectionConfig}\n field={field}\n />\n )\n } else {\n return (\n <WrapElement {...wrapElementProps}>\n {(displayedValue === '' ||\n typeof displayedValue === 'undefined' ||\n displayedValue === null) &&\n i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n })}\n {typeof displayedValue === 'string' && displayedValue}\n {typeof displayedValue === 'number' && displayedValue}\n {typeof displayedValue === 'object' &&\n displayedValue !== null &&\n JSON.stringify(displayedValue)}\n </WrapElement>\n )\n }\n }\n\n if ((field.type === 'select' || field.type === 'radio') && field.options.length && cellData) {\n const classes = Array.isArray(cellData)\n ? cellData.map((value) => `selected--${value}`).join(' ')\n : `selected--${cellData}`\n\n const className = [wrapElementProps.className, classes].filter(Boolean).join(' ')\n\n return (\n <WrapElement {...wrapElementProps} className={className}>\n {CellComponent}\n </WrapElement>\n )\n }\n\n return <WrapElement {...wrapElementProps}>{CellComponent}</WrapElement>\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,OAAOC,KAAA,MAAW,QAAO,CAAC;AAE1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,IAAI,QAAQ;AACrB,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,WAAA,GAAmDC,KAAA;EAAA,MAAAC,CAAA,GAAAd,EAAA;EAC9D;IAAAe,QAAA;IAAAC,SAAA,EAAAC,kBAAA;IAAAC,cAAA;IAAAC,KAAA;IAAAA,KAAA,EAAAC,EAAA;IAAAC,IAAA;IAAAC,OAAA,EAAAC,gBAAA;IAAAC,OAAA;IAAAC;EAAA,IAUIZ,KAAA;EALK;IAAAa;EAAA,IAAAN,EAAS;EAOlB;IAAAO;EAAA,IAAiBrB,cAAA;EAEjB;IAAAsB,MAAA,EAAAC,EAAA;IAAAC;EAAA,IAKIzB,SAAA;EAJM;IAAA0B,MAAA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;SAApCrB,E;CACT;AAvJgE,SAAAsC,MAAAK,KAAA;EAAA,OA0IhC,aAAaA,KAAA,EAAO;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","getTranslation","fieldAffectsData","fieldIsID","React","useConfig","useTranslation","formatAdminURL","getDisplayedFieldValue","isValidReactElement","Link","CodeCell","cellComponents","DefaultCell","props","$","cellData","className","classNameFromProps","collectionSlug","field","t0","link","onClick","onClickFromProps","rowData","viewType","admin","i18n","config","t1","getEntityConfig","routes","t2","adminRoute","t3","t4","Symbol","for","collectionConfig","classNameFromConfigContext","undefined","WrapElement","wrapElementProps","prefetch","href","slug","path","encodeURIComponent","id","type","_jsx","children","nowrap","displayedValue","DefaultCellComponent","CellComponent","upload","name","FileCellComponent","File","_jsxs","t","label","JSON","stringify","options","length","classes","Array","isArray","map","_temp","join","className_0","filter","Boolean","value"],"sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps, UploadFieldClient } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { fieldAffectsData, fieldIsID } from 'payload/shared'\nimport React from 'react' // TODO: abstract this out to support all routers\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatAdminURL } from '../../../utilities/formatAdminURL.js'\nimport { getDisplayedFieldValue } from '../../../utilities/getDisplayedFieldValue.js'\nimport { isValidReactElement } from '../../../utilities/isValidReactElement.js'\nimport { Link } from '../../Link/index.js'\nimport { CodeCell } from './fields/Code/index.js'\nimport { cellComponents } from './fields/index.js'\n\nexport const DefaultCell: React.FC<DefaultCellComponentProps> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionSlug,\n field,\n field: { admin },\n link,\n onClick: onClickFromProps,\n rowData,\n viewType,\n } = props\n\n const { i18n } = useTranslation()\n\n const {\n config: {\n routes: { admin: adminRoute },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}${viewType === 'trash' ? '/trash' : ''}/${encodeURIComponent(rowData.id)}`,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n if (fieldIsID(field)) {\n return (\n <WrapElement {...wrapElementProps}>\n <CodeCell\n cellData={`ID: ${cellData}`}\n collectionConfig={collectionConfig}\n collectionSlug={collectionSlug}\n field={{\n ...field,\n type: 'code',\n }}\n nowrap\n rowData={rowData}\n />\n </WrapElement>\n )\n }\n\n const displayedValue = getDisplayedFieldValue(cellData, field, i18n)\n\n const DefaultCellComponent: React.FC<DefaultCellComponentProps> =\n typeof cellData !== 'undefined' && cellComponents[field.type]\n\n let CellComponent: React.ReactNode = null\n\n // Handle JSX labels before using DefaultCellComponent\n if (isValidReactElement(displayedValue)) {\n CellComponent = displayedValue\n } else if (DefaultCellComponent) {\n CellComponent = <DefaultCellComponent cellData={cellData} rowData={rowData} {...props} />\n } else if (!DefaultCellComponent) {\n // DefaultCellComponent does not exist for certain field types like `text`\n if (\n collectionConfig?.upload &&\n fieldAffectsData(field) &&\n field.name === 'filename' &&\n field.type === 'text'\n ) {\n const FileCellComponent = cellComponents.File\n\n CellComponent = (\n <FileCellComponent\n cellData={cellData}\n rowData={rowData}\n {...(props as DefaultCellComponentProps<UploadFieldClient>)}\n collectionConfig={collectionConfig}\n field={field}\n />\n )\n } else {\n return (\n <WrapElement {...wrapElementProps}>\n {(displayedValue === '' ||\n typeof displayedValue === 'undefined' ||\n displayedValue === null) &&\n i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n })}\n {typeof displayedValue === 'string' && displayedValue}\n {typeof displayedValue === 'number' && displayedValue}\n {typeof displayedValue === 'object' &&\n displayedValue !== null &&\n JSON.stringify(displayedValue)}\n </WrapElement>\n )\n }\n }\n\n if ((field.type === 'select' || field.type === 'radio') && field.options.length && cellData) {\n const classes = Array.isArray(cellData)\n ? cellData.map((value) => `selected--${value}`).join(' ')\n : `selected--${cellData}`\n\n const className = [wrapElementProps.className, classes].filter(Boolean).join(' ')\n\n return (\n <WrapElement {...wrapElementProps} className={className}>\n {CellComponent}\n </WrapElement>\n )\n }\n\n return <WrapElement {...wrapElementProps}>{CellComponent}</WrapElement>\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,OAAOC,KAAA,MAAW,QAAO,CAAC;AAE1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AACrB,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,WAAA,GAAmDC,KAAA;EAAA,MAAAC,CAAA,GAAAf,EAAA;EAC9D;IAAAgB,QAAA;IAAAC,SAAA,EAAAC,kBAAA;IAAAC,cAAA;IAAAC,KAAA;IAAAA,KAAA,EAAAC,EAAA;IAAAC,IAAA;IAAAC,OAAA,EAAAC,gBAAA;IAAAC,OAAA;IAAAC;EA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;UAAAmC,QAAA,EAC3CI;QAAA,C;;;MAKArB,EAAA,GAAAgB,IAAA,CAACT,WAAA;QAAA,GAAgBC,gBAAgB;QAAAS,QAAA,EAAGI;MAAA,C;;;;;;;;;;;;;;;;;;;;;;;;SAApCrB,E;CACT;AAvJgE,SAAAqC,MAAAK,KAAA;EAAA,OA0IhC,aAAaA,KAAA,EAAO;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldErrors.d.ts","sourceRoot":"","sources":["../../../src/elements/Toasts/fieldErrors.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAwDzB,wBAAgB,gBAAgB,CAAC,EAAE,YAAY,EAAE;;CAAA,qBAehD"}
1
+ {"version":3,"file":"fieldErrors.d.ts","sourceRoot":"","sources":["../../../src/elements/Toasts/fieldErrors.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAwDzB,wBAAgB,gBAAgB,CAAC,EAAE,YAAY,EAAE;;CAAA,qBAmBhD"}
@@ -65,7 +65,10 @@ export function FieldErrorsToast(t0) {
65
65
  let t3;
66
66
  if ($[2] !== errors || $[3] !== message) {
67
67
  t3 = _jsxs("div", {
68
- children: [message, Array.isArray(errors) && errors.length > 0 ? _jsx("ul", {
68
+ children: [message, Array.isArray(errors) && errors.length > 0 ? errors.length === 1 ? _jsx("span", {
69
+ "data-testid": "field-error",
70
+ children: errors[0]
71
+ }) : _jsx("ul", {
69
72
  "data-testid": "field-errors",
70
73
  children: errors.map(_temp)
71
74
  }) : null]
@@ -1 +1 @@
1
- {"version":3,"file":"fieldErrors.js","names":["c","_c","React","groupSimilarErrors","items","result","item","parts","split","inserted","i","length","startsWith","splice","push","createErrorsFromMessage","message","intro","errorsString","errors","map","error","replaceAll","trim","FieldErrorsToast","t0","$","errorMessage","t1","t2","useState","t3","_jsxs","children","Array","isArray","_jsx","_temp","index"],"sources":["../../../src/elements/Toasts/fieldErrors.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nfunction groupSimilarErrors(items: string[]): string[] {\n const result: string[] = []\n\n for (const item of items) {\n if (item) {\n const parts = item.split(' → ')\n let inserted = false\n\n // Find a place where a similar path exists\n for (let i = 0; i < result.length; i++) {\n if (result[i].startsWith(parts[0])) {\n result.splice(i + 1, 0, item)\n inserted = true\n break\n }\n }\n\n // If no similar path was found, add to the end\n if (!inserted) {\n result.push(item)\n }\n }\n }\n\n return result\n}\n\nfunction createErrorsFromMessage(message: string): {\n errors?: string[]\n message: string\n} {\n const [intro, errorsString] = message.split(':')\n\n if (!errorsString) {\n return {\n message: intro,\n }\n }\n\n const errors = errorsString.split(',').map((error) => error.replaceAll(' > ', ' → ').trim())\n\n if (errors.length === 1) {\n return {\n errors,\n message: `${intro}:`,\n }\n }\n\n return {\n errors: groupSimilarErrors(errors),\n message: `${intro} (${errors.length}):`,\n }\n}\n\nexport function FieldErrorsToast({ errorMessage }) {\n const [{ errors, message }] = React.useState(() => createErrorsFromMessage(errorMessage))\n\n return (\n <div>\n {message}\n {Array.isArray(errors) && errors.length > 0 ? (\n <ul data-testid=\"field-errors\">\n {errors.map((error, index) => {\n return <li key={index}>{error}</li>\n })}\n </ul>\n ) : null}\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,OAAOC,KAAA,MAAW;AAElB,SAASC,mBAAmBC,KAAe;EACzC,MAAMC,MAAA,GAAmB,EAAE;EAE3B,KAAK,MAAMC,IAAA,IAAQF,KAAA,EAAO;IACxB,IAAIE,IAAA,EAAM;MACR,MAAMC,KAAA,GAAQD,IAAA,CAAKE,KAAK,CAAC;MACzB,IAAIC,QAAA,GAAW;MAEf;MACA,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIL,MAAA,CAAOM,MAAM,EAAED,CAAA,IAAK;QACtC,IAAIL,MAAM,CAACK,CAAA,CAAE,CAACE,UAAU,CAACL,KAAK,CAAC,EAAE,GAAG;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QAAAV,OAAA;IAGxBe,EAAA,GAAAC,KAAA,CAAC;MAAAC,QAAA,GACEjB,OAAA,EACAkB,KAAA,CAAAC,OAAA,CAAchB,MAAA,KAAWA,MAAA,CAAAR,MAAA,IAAgB,GACxCyB,IAAA,CAAC;QAAA,eAAe;QAAAH,QAAA,EACbd,MAAA,CAAAC,GAAA,CAAAiB,KAED;MAAA,C,QAEA;IAAA,C;;;;;;;SARNN,E;;AAJG,SAAAM,MAAAhB,KAAA,EAAAiB,KAAA;EAAA,OASYF,IAAA,CAAC;IAAAH,QAAA,EAAgBZ;EAAA,GAARiB,KAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"fieldErrors.js","names":["c","_c","React","groupSimilarErrors","items","result","item","parts","split","inserted","i","length","startsWith","splice","push","createErrorsFromMessage","message","intro","errorsString","errors","map","error","replaceAll","trim","FieldErrorsToast","t0","$","errorMessage","t1","t2","useState","t3","_jsxs","children","Array","isArray","_jsx","_temp","index"],"sources":["../../../src/elements/Toasts/fieldErrors.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nfunction groupSimilarErrors(items: string[]): string[] {\n const result: string[] = []\n\n for (const item of items) {\n if (item) {\n const parts = item.split(' → ')\n let inserted = false\n\n // Find a place where a similar path exists\n for (let i = 0; i < result.length; i++) {\n if (result[i].startsWith(parts[0])) {\n result.splice(i + 1, 0, item)\n inserted = true\n break\n }\n }\n\n // If no similar path was found, add to the end\n if (!inserted) {\n result.push(item)\n }\n }\n }\n\n return result\n}\n\nfunction createErrorsFromMessage(message: string): {\n errors?: string[]\n message: string\n} {\n const [intro, errorsString] = message.split(':')\n\n if (!errorsString) {\n return {\n message: intro,\n }\n }\n\n const errors = errorsString.split(',').map((error) => error.replaceAll(' > ', ' → ').trim())\n\n if (errors.length === 1) {\n return {\n errors,\n message: `${intro}:`,\n }\n }\n\n return {\n errors: groupSimilarErrors(errors),\n message: `${intro} (${errors.length}):`,\n }\n}\n\nexport function FieldErrorsToast({ errorMessage }) {\n const [{ errors, message }] = React.useState(() => createErrorsFromMessage(errorMessage))\n\n return (\n <div>\n {message}\n {Array.isArray(errors) && errors.length > 0 ? (\n errors.length === 1 ? (\n <span data-testid=\"field-error\">{errors[0]}</span>\n ) : (\n <ul data-testid=\"field-errors\">\n {errors.map((error, index) => {\n return <li key={index}>{error}</li>\n })}\n </ul>\n )\n ) : null}\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,OAAOC,KAAA,MAAW;AAElB,SAASC,mBAAmBC,KAAe;EACzC,MAAMC,MAAA,GAAmB,EAAE;EAE3B,KAAK,MAAMC,IAAA,IAAQF,KAAA,EAAO;IACxB,IAAIE,IAAA,EAAM;MACR,MAAMC,KAAA,GAAQD,IAAA,CAAKE,KAAK,CAAC;MACzB,IAAIC,QAAA,GAAW;MAEf;MACA,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIL,MAAA,CAAOM,MAAM,EAAED,CAAA,IAAK;QACtC,IAAIL,MAAM,CAACK,CAAA,CAAE,CAACE,UAAU,CAACL,KAAK,CAAC,EAAE,GAAG;UAClCF,MAAA,CAAOQ,MAAM,CAACH,CAAA,GAAI,GAAG,GAAGJ,IAAA;UACxBG,QAAA,GAAW;UACX;QACF;MACF;MAEA;MACA,IAAI,CAACA,QAAA,EAAU;QACbJ,MAAA,CAAOS,IAAI,CAACR,IAAA;MACd;IACF;EACF;EAEA,OAAOD,MAAA;AACT;AAEA,SAASU,wBAAwBC,OAAe;EAI9C,MAAM,CAACC,KAAA,EAAOC,YAAA,CAAa,GAAGF,OAAA,CAAQR,KAAK,CAAC;EAE5C,IAAI,CAACU,YAAA,EAAc;IACjB,OAAO;MACLF,OAAA,EAASC;IACX;EACF;EAEA,MAAME,MAAA,GAASD,YAAA,CAAaV,KAAK,CAAC,KAAKY,GAAG,CAAEC,KAAA,IAAUA,KAAA,CAAMC,UAAU,CAAC,OAAO,OAAOC,IAAI;EAEzF,IAAIJ,M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