// __SDEFILE__ - This file is a dependency for the stand-alone environment // Dependencies import mustache from 'mustache' import { nsMerge } from 'shared/utils.mjs' // Hooks import { useTranslation } from 'next-i18next' // Components import { ChatIcon, TipIcon, WarningIcon, ErrorIcon, WrenchIcon as FixmeIcon, ExpandIcon, FlagIcon, OptionsIcon, DocsIcon, } from 'shared/components/icons.mjs' import { Mdx } from 'shared/components/mdx/dynamic.mjs' import { SubAccordion } from 'shared/components/accordion.mjs' const flagIcons = { note: ChatIcon, info: DocsIcon, tip: TipIcon, warn: WarningIcon, error: ErrorIcon, fixme: FixmeIcon, // Used in content expand: ExpandIcon, options: OptionsIcon, } // This is also the order in which they will be displayed export const flagTypes = ['error', 'warn', 'note', 'info', 'tip', 'fixme'] export const Flag = ({ data, t, handleUpdate }) => { const BtnIcon = data.suggest?.icon ? flagIcons[data.suggest.icon] : false const button = data.suggest?.text && data.suggest?.update ? ( ) : null const desc = data.replace ? mustache.render(t(data.desc), data.replace) : t(data.desc) const notes = data.notes ? Array.isArray(data.notes) ? '\n\n' + data.notes .map((note) => (data.replace ? mustache.render(t(note), data.replace) : t(note))) .join('\n\n') : '\n\n' + (data.replace ? mustache.render(t(data.notes), data.replace) : t(data.notes)) : null return (
{Object.keys(flagList).length > 1 ? t('flag:flagMenuMany.d') : t('flag:flagMenuOne.d')}
> ) } export const FlagsAccordionEntries = ({ flags, update }) => { const [flagList, ns] = flattenFlags(flags) const { t } = useTranslation(nsMerge(ns)) if (Object.keys(flagList).length < 1) return null const handleUpdate = (config) => { if (config.settings) update.settings(...config.settings) if (config.ui) update.ui(...config.settings) } return (