chore: re-exports languages in payload (#5771)

This commit is contained in:
Jarrod Flesch
2024-04-10 15:55:01 -04:00
committed by GitHub
parent 7cf2686097
commit 94af06466b
40 changed files with 79 additions and 517 deletions

View File

@@ -62,7 +62,7 @@ export const _ArrayField: React.FC<ArrayFieldProps> = (props) => {
labelProps,
localized,
maxRows,
minRows,
minRows: minRowsProp,
path: pathFromProps,
permissions,
readOnly: readOnlyFromProps,
@@ -72,6 +72,7 @@ export const _ArrayField: React.FC<ArrayFieldProps> = (props) => {
const { indexPath, readOnly: readOnlyFromContext } = useFieldProps()
const readOnly = readOnlyFromProps || readOnlyFromContext
const minRows = minRowsProp ?? required ? 1 : 0
const { setDocFieldPreferences } = useDocumentInfo()
const { addFieldRow, dispatchFields, setModified } = useForm()
@@ -300,7 +301,7 @@ export const _ArrayField: React.FC<ArrayFieldProps> = (props) => {
{t('validation:requiresAtLeast', {
count: minRows,
label:
getTranslation(minRows ? labels.plural : labels.singular, i18n) ||
getTranslation(minRows > 1 ? labels.plural : labels.singular, i18n) ||
t(minRows > 1 ? 'general:row' : 'general:rows'),
})}
</Banner>

View File

@@ -67,7 +67,7 @@ const _BlocksField: React.FC<BlocksFieldProps> = (props) => {
labels: labelsFromProps,
localized,
maxRows,
minRows,
minRows: minRowsProp,
path: pathFromProps,
readOnly: readOnlyFromProps,
required,
@@ -76,6 +76,7 @@ const _BlocksField: React.FC<BlocksFieldProps> = (props) => {
const { indexPath, readOnly: readOnlyFromContext } = useFieldProps()
const readOnly = readOnlyFromProps || readOnlyFromContext
const minRows = minRowsProp ?? required ? 1 : 0
const { setDocFieldPreferences } = useDocumentInfo()
const { addFieldRow, dispatchFields, setModified } = useForm()
@@ -313,12 +314,9 @@ const _BlocksField: React.FC<BlocksFieldProps> = (props) => {
<Banner type="error">
{t('validation:requiresAtLeast', {
count: minRows,
label: getTranslation(
minRows === 1 || typeof minRows === 'undefined'
? labels.singular
: labels.plural,
i18n,
),
label:
getTranslation(minRows > 1 ? labels.plural : labels.singular, i18n) ||
t(minRows > 1 ? 'general:row' : 'general:rows'),
})}
</Banner>
)}