Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
24 lines
1.2 KiB
Plaintext
24 lines
1.2 KiB
Plaintext
'use client';
|
|
|
|
export const fieldBaseClass = 'field-type';
|
|
/**
|
|
* Determines whether a field should be displayed as right-to-left (RTL) based on its configuration, payload's localization configuration and the adming user's currently enabled locale.
|
|
|
|
* @returns Whether the field should be displayed as RTL.
|
|
*/
|
|
export function isFieldRTL({
|
|
fieldLocalized,
|
|
fieldRTL,
|
|
locale,
|
|
localizationConfig
|
|
}) {
|
|
const hasMultipleLocales = locale && localizationConfig && localizationConfig.locales && localizationConfig.locales.length > 1;
|
|
const isCurrentLocaleDefaultLocale = locale?.code === localizationConfig?.defaultLocale;
|
|
return fieldRTL !== false && locale?.rtl === true && (fieldLocalized || !fieldLocalized && !hasMultipleLocales ||
|
|
// If there is only one locale which is also rtl, that field is rtl too
|
|
!fieldLocalized && isCurrentLocaleDefaultLocale) ||
|
|
// If the current locale is the default locale, but the field is not localized, that field is rtl too
|
|
fieldRTL === true // If fieldRTL is true. This should be useful for when no localization is set at all in the payload config, but you still want fields to be rtl.
|
|
;
|
|
}
|
|
//# sourceMappingURL=index.js.map |