@i18n-micro/solid 1.2.16 → 2.0.0

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.mjs","names":["TranslationKey","Component","JSX","splitProps","useI18nContext","I18nGroupProps","HTMLAttributes","HTMLDivElement","prefix","groupClass","I18nGroup","props","Element","i18n","local","others","translate","key","params","Record","result","t","undefined","getRoute","String","_el$","_tmpl$","_$spread","_$mergeProps","class","filter","Boolean","join","_$insert","_c$","_$memo","children","_tmpl$","_$mergeProps","_$memo","Accessor","Component","createMemo","JSX","splitProps","useI18nContext","useI18nRouter","I18nRoutingStrategy","I18nLinkProps","AnchorHTMLAttributes","HTMLAnchorElement","to","path","localeRoute","locale","activeStyle","CSSProperties","I18nLink","props","Element","router","i18n","local","others","extendedRouter","getCurrentPathAccessor","pathnameAccessor","targetPath","currentLocale","localeAccessor","result","res","resolvePath","isExternal","test","isActive","current","getCurrentPath","window","location","pathname","target","normCurrent","replace","normTarget","mergedStyle","baseStyle","style","active","LinkComponent","linkComponent","_el$","_tmpl$","_$spread","_$mergeProps","href","_$memo","_$insert","children","_$createComponent","Record","_el$2","_tmpl$2","onClick","e","MouseEvent","preventDefault","push","_tmpl$","_tmpl$2","extendedRouter","_$mergeProps","_$memo","_$createComponent","Locale","Accessor","Component","createMemo","createSignal","JSX","onCleanup","onMount","splitProps","useI18nContext","useI18nLocales","useI18nRouter","I18nRoutingStrategy","I18nSwitcherProps","HTMLAttributes","HTMLDivElement","locales","currentLocale","getLocaleName","switchLocale","locale","localeRoute","to","path","customLabels","Record","customWrapperStyle","CSSProperties","customButtonStyle","customDropdownStyle","customItemStyle","customLinkStyle","customActiveLinkStyle","customDisabledLinkStyle","customIconStyle","I18nSwitcher","props","Element","i18n","router","injectedLocales","local","others","dropdownOpen","setDropdownOpen","wrapperRef","allLocales","filter","disabled","undefined","localeAccessor","currentLocaleDisabled","some","l","code","currentLocaleName","current","find","displayName","toggleDropdown","event","Event","stopPropagation","preventDefault","localeLabel","localeItem","currentLocaleLabel","handleSwitchLocale","extendedRouter","getCurrentPathAccessor","currentPath","getCurrentPath","newPath","res","resolvePath","push","wrapperStyle","position","display","buttonStyle","padding","cursor","border","transition","dropdownStyle","top","left","margin","itemStyle","linkStyle","color","activeLinkStyle","iconStyle","openIconStyle","transform","handleClickOutside","MouseEvent","target","HTMLElement","isClickInside","contains","isButtonClick","closest","document","addEventListener","removeEventListener","_el$","_tmpl$","_el$2","firstChild","_el$3","_el$4","nextSibling","_$use","el","_$spread","_$mergeProps","style","$$click","e","_$insert","_c$","_$memo","_el$5","_tmpl$2","map","isActive","window","location","pathname","result","routeTo","_el$6","_tmpl$3","_el$7","_$setAttribute","_$effect","_p$","_v$4","_v$5","_v$6","_$style","t","_$className","a","_$p","_v$","_v$2","_v$3","_$delegateEvents","_$mergeProps","_$memo","_$style","_$className","_$setAttribute","_$delegateEvents","PluralFunc","TranslationKey","Component","createMemo","JSX","splitProps","Dynamic","useI18nContext","I18nTProps","HTMLAttributes","HTMLElement","keypath","params","Record","tag","plural","defaultValue","html","hideIfEmpty","customPluralRule","number","date","Date","relativeDate","I18nT","props","Element","i18n","local","others","translation","locale","localeAccessor","route","routeAccessor","undefined","numberValue","Number","formattedNumber","tn","result","t","String","formattedDate","td","formattedRelativeDate","tdr","count","parseInt","toString","translationResult","k","p","dv","tc","trim","_$createComponent","_$mergeProps","component","innerHTML","translationValue","children","_$createComponent","_$mergeProps","Locale","JSX","ParentComponent","SolidI18n","I18nContext","I18nDefaultLocaleContext","I18nLocalesContext","I18nRouterContext","I18nRoutingStrategy","I18nProviderProps","i18n","locales","defaultLocale","routingStrategy","I18nProvider","props","Element","children","_$createComponent","Provider","value","_$memo","useI18nContext","_$createComponent","_$memo","Locale","A","Location","useNavigate","Accessor","Component","createEffect","createSignal","JSX","I18nRoutingStrategy","NavigateFunction","ReturnType","createSolidRouterAdapter","locales","defaultLocale","navigate","location","getCurrentPathAccessor","localeCodes","map","loc","code","pathname","setPathname","resolvePath","to","path","locale","pathSegments","split","filter","Boolean","length","includes","shift","cleanPath","join","getCurrentPath","push","target","replace","getRoute","fullPath","query","linkComponent","props","href","children","Element","class","style","CSSProperties","key","className","restProps","_$createComponent","_$mergeProps","_$createComponent","_$mergeProps","I18nContext","createContext","I18nLocalesContext","I18nDefaultLocaleContext","I18nRouterContext","useI18nContext","context","useContext","useI18nLocales","useI18nDefaultLocale","useI18nRouter","_tmpl$$2","I18nGroup","i18n","local","others","splitProps","props","translate","result","key","params","_el$","spread","mergeProps","\"class\"","insert","_c$","memo","_tmpl$$1","_tmpl$2$1","I18nLink","router","pathnameAccessor","targetPath","createMemo","currentLocale","res","isExternal","isActive","current","target","mergedStyle","baseStyle","activeStyle","LinkComponent","createComponent","_el$2","\"onClick\"","_tmpl$","_tmpl$2","_tmpl$3","I18nSwitcher","injectedLocales","dropdownOpen","setDropdownOpen","createSignal","wrapperRef","allLocales","locales","locale","currentLocaleDisabled","l","currentLocaleName","toggleDropdown","event","localeLabel","localeItem","currentLocaleLabel","handleSwitchLocale","code","extendedRouter","currentPath","newPath","wrapperStyle","buttonStyle","dropdownStyle","itemStyle","linkStyle","activeLinkStyle","iconStyle","openIconStyle","handleClickOutside","isClickInside","isButtonClick","onMount","onCleanup","_el$3","_el$4","use","el","_el$5","routeTo","_el$6","_el$7","e","setAttribute","effect","_v$4","_v$5","_v$6","style","_p$","className","_$p","_v$","_v$2","_v$3","delegateEvents","I18nT","translation","route","numberValue","formattedNumber","formattedDate","formattedRelativeDate","count","k","p","dv","translationResult","Dynamic","translationValue","I18nProvider","children","SolidI18n","BaseI18n","storage","options","createReactiveI18nStore","setLocale","fallback","setRoute","lang","msgs","val","translations","merge","routeName","cb","createI18n","createSolidRouterAdapter","localeCodes","loc","pathname","setPathname","location","resolvePath","pathSegments","to","cleanPath","defaultLocale","restProps","A","useI18n","injectedDefaultLocale","resolveLocalePath","localeCode","newLocale","FormatService","defaultPlural","interpolate"],"sources":["../src/injection.ts","../src/components/I18nGroup.tsx","../src/components/I18nLink.tsx","../src/components/I18nSwitcher.tsx","../src/components/I18nT.tsx","../src/context.tsx","../src/i18n.ts","../src/router/adapter.tsx","../src/use-i18n.ts"],"sourcesContent":["import type { Locale } from '@i18n-micro/types'\nimport { createContext, useContext } from 'solid-js'\nimport type { SolidI18n } from './i18n'\nimport type { I18nRoutingStrategy } from './router/types'\n\n// Context keys (analogous to Vue's InjectionKey)\nexport const I18nContext = createContext<SolidI18n>()\nexport const I18nLocalesContext = createContext<Locale[]>()\nexport const I18nDefaultLocaleContext = createContext<string>()\nexport const I18nRouterContext = createContext<I18nRoutingStrategy | undefined>()\n\n// Helper hooks (analogous to Vue's inject)\nexport const useI18nContext = () => {\n const context = useContext(I18nContext)\n if (!context) {\n throw new Error('[i18n-micro] I18nContext not found. Make sure I18nProvider is used.')\n }\n return context\n}\n\nexport const useI18nLocales = () => {\n const context = useContext(I18nLocalesContext)\n if (!context) {\n throw new Error('[i18n-micro] I18nLocalesContext not found. Make sure I18nLocalesContext is provided.')\n }\n return context\n}\n\nexport const useI18nDefaultLocale = () => {\n const context = useContext(I18nDefaultLocaleContext)\n if (!context) {\n throw new Error('[i18n-micro] I18nDefaultLocaleContext not found. Make sure I18nDefaultLocaleContext is provided.')\n }\n return context\n}\n\nexport const useI18nRouter = () => {\n return useContext(I18nRouterContext)\n}\n","// @ts-nocheck\n\nimport type { TranslationKey } from '@i18n-micro/types'\nimport { type Component, type JSX, splitProps } from 'solid-js'\nimport { useI18nContext } from '../injection'\n\ninterface I18nGroupProps extends JSX.HTMLAttributes<HTMLDivElement> {\n prefix: string\n groupClass?: string\n}\n\nexport const I18nGroup: Component<I18nGroupProps> = (props): JSX.Element => {\n const i18n = useI18nContext()\n const [local, others] = splitProps(props, ['prefix', 'groupClass'])\n\n const translate = (key: string, params?: Record<string, string | number | boolean>): string => {\n // Use type assertion for dynamic keys with prefix\n // The developer is responsible for ensuring the key exists\n const result = i18n.t(`${local.prefix}.${key}` as TranslationKey, params, undefined, i18n.getRoute())\n return typeof result === 'string' ? result : String(result)\n }\n\n return (\n // @ts-expect-error - Type conflict with Vue JSX in monorepo\n (\n <div class={['i18n-group', local.groupClass].filter(Boolean).join(' ')} {...(others as unknown as JSX.HTMLAttributes<HTMLDivElement>)}>\n {typeof props.children === 'function'\n ? (\n props.children as (props: {\n prefix: string\n t: (key: string, params?: Record<string, string | number | boolean>) => string\n }) => JSX.Element\n )({ prefix: local.prefix, t: translate })\n : props.children}\n </div>\n ) as unknown as JSX.Element\n )\n}\n","// @ts-nocheck\nimport { type Accessor, type Component, createMemo, type JSX, splitProps } from 'solid-js'\nimport { useI18nContext, useI18nRouter } from '../injection'\nimport type { I18nRoutingStrategy } from '../router/types'\n\ninterface I18nLinkProps extends JSX.AnchorHTMLAttributes<HTMLAnchorElement> {\n to: string | { path?: string }\n localeRoute?: (to: string | { path?: string }, locale?: string) => string | { path?: string }\n activeStyle?: JSX.CSSProperties\n}\n\nexport const I18nLink: Component<I18nLinkProps> = (props): JSX.Element => {\n const router = useI18nRouter()\n const i18n = useI18nContext()\n // Разделяем пропсы: явно выделяем style, чтобы объединить его с activeStyle\n const [local, others] = splitProps(props, ['to', 'localeRoute', 'activeStyle', 'style', 'children'])\n\n // 1. Получаем accessor для текущего пути из роутера\n const extendedRouter = router as I18nRoutingStrategy & { getCurrentPathAccessor?: Accessor<string> }\n const pathnameAccessor = extendedRouter?.getCurrentPathAccessor\n\n // 2. Вычисление целевого пути (href) - реактивно отслеживает изменения локали\n const targetPath = createMemo(() => {\n // Используем реактивный accessor для отслеживания изменений локали\n const currentLocale = i18n.localeAccessor()\n let result: string\n if (local.localeRoute) {\n const res = local.localeRoute(local.to, currentLocale)\n result = typeof res === 'string' ? res : res?.path || '/'\n } else if (router?.resolvePath) {\n const res = router.resolvePath(local.to, currentLocale)\n result = typeof res === 'string' ? res : res?.path || '/'\n } else if (typeof local.to === 'string') {\n result = local.to\n } else {\n result = (local.to as { path?: string })?.path || '/'\n }\n return result\n })\n\n // 3. Проверка на внешнюю ссылку\n const isExternal = createMemo(() => {\n if (typeof local.to === 'string') {\n return /^(?:https?:\\/\\/|\\/\\/|[a-zA-Z0-9-]+\\.[a-zA-Z]{2,})|tel:|mailto:/.test(local.to)\n }\n return false\n })\n\n // 4. Вычисление активного состояния\n // Важно: вызываем pathnameAccessor() внутри createMemo для правильного отслеживания изменений\n const isActive = createMemo(() => {\n if (isExternal()) {\n return false\n }\n\n // Получаем текущий путь - вызываем accessor внутри createMemo для реактивности\n const current = pathnameAccessor\n ? pathnameAccessor() // Вызов accessor внутри createMemo отслеживает изменения\n : router\n ? router.getCurrentPath()\n : typeof window !== 'undefined'\n ? window.location.pathname\n : '/'\n const target = targetPath()\n\n // Нормализация для сравнения (убираем слэш в конце, если это не корень)\n const normCurrent = current === '/' ? '/' : current.replace(/\\/$/, '')\n const normTarget = target === '/' ? '/' : target.replace(/\\/$/, '')\n\n return normCurrent === normTarget\n })\n\n // 5. Объединение стилей - используем isActive напрямую для реактивности\n const mergedStyle = createMemo(() => {\n const baseStyle = local.style || {}\n // Вызываем isActive() внутри createMemo для отслеживания изменений\n const active = isActive()\n const activeStyle = active ? local.activeStyle || {} : {}\n\n // SolidJS умеет работать с объектами стилей корректно при слиянии\n return {\n ...(typeof baseStyle === 'object' ? baseStyle : {}),\n ...(typeof activeStyle === 'object' ? activeStyle : {}),\n } as JSX.CSSProperties\n })\n\n // Используем linkComponent из роутера, если доступен\n const LinkComponent = router?.linkComponent\n\n if (isExternal()) {\n return (\n // @ts-expect-error - Type conflict with Vue JSX\n (\n <a\n href={typeof local.to === 'string' ? local.to : ''}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={mergedStyle()}\n {...(others as unknown as JSX.AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {local.children}\n </a>\n ) as unknown as JSX.Element\n )\n }\n\n // Если есть linkComponent из роутера (например, A из @solidjs/router), используем его\n if (LinkComponent) {\n return (\n // @ts-expect-error - Type conflict with router component types\n (\n <LinkComponent href={targetPath()} style={mergedStyle()} {...(others as unknown as Record<string, unknown>)}>\n {local.children}\n </LinkComponent>\n ) as unknown as JSX.Element\n )\n }\n\n // Fallback на нативный <a> с onClick обработчиком\n return (\n // @ts-expect-error - Type conflict with Vue JSX\n (\n <a\n href={targetPath()}\n style={mergedStyle()}\n {...(others as unknown as JSX.AnchorHTMLAttributes<HTMLAnchorElement>)}\n onClick={(e: MouseEvent) => {\n if (router && !isExternal()) {\n e.preventDefault()\n router.push({ path: targetPath() })\n }\n }}\n >\n {local.children}\n </a>\n ) as unknown as JSX.Element\n )\n}\n","// @ts-nocheck\n\nimport type { Locale } from '@i18n-micro/types'\nimport { type Accessor, type Component, createMemo, createSignal, type JSX, onCleanup, onMount, splitProps } from 'solid-js'\nimport { useI18nContext, useI18nLocales, useI18nRouter } from '../injection'\nimport type { I18nRoutingStrategy } from '../router/types'\n\ninterface I18nSwitcherProps extends JSX.HTMLAttributes<HTMLDivElement> {\n locales?: Locale[]\n currentLocale?: string | (() => string)\n getLocaleName?: () => string | null\n switchLocale?: (locale: string) => void\n localeRoute?: (to: string | { path?: string }, locale?: string) => string | { path?: string }\n customLabels?: Record<string, string>\n customWrapperStyle?: JSX.CSSProperties\n customButtonStyle?: JSX.CSSProperties\n customDropdownStyle?: JSX.CSSProperties\n customItemStyle?: JSX.CSSProperties\n customLinkStyle?: JSX.CSSProperties\n customActiveLinkStyle?: JSX.CSSProperties\n /**\n * Inline style applied to the main switcher button when the current locale is\n * marked as `disabled: true` in locale config.\n *\n * Disabled locales are omitted from dropdown items.\n */\n customDisabledLinkStyle?: JSX.CSSProperties\n customIconStyle?: JSX.CSSProperties\n}\n\nexport const I18nSwitcher: Component<I18nSwitcherProps> = (props): JSX.Element => {\n const i18n = useI18nContext()\n const router = useI18nRouter()\n const injectedLocales = useI18nLocales()\n\n const [local, others] = splitProps(props, [\n 'locales',\n 'currentLocale',\n 'getLocaleName',\n 'switchLocale',\n 'localeRoute',\n 'customLabels',\n 'customWrapperStyle',\n 'customButtonStyle',\n 'customDropdownStyle',\n 'customItemStyle',\n 'customLinkStyle',\n 'customActiveLinkStyle',\n 'customDisabledLinkStyle',\n 'customIconStyle',\n ])\n\n const [dropdownOpen, setDropdownOpen] = createSignal(false)\n let wrapperRef: HTMLDivElement | undefined\n\n const allLocales = createMemo(() => local.locales || injectedLocales || [])\n const locales = createMemo(() => allLocales().filter((locale) => !locale.disabled))\n const currentLocale = createMemo(() => {\n if (local.currentLocale !== undefined) {\n return typeof local.currentLocale === 'function' ? local.currentLocale() : local.currentLocale\n }\n // Используем реактивный accessor для отслеживания изменений\n return i18n.localeAccessor()\n })\n const currentLocaleDisabled = createMemo(() => allLocales().some((l) => l.code === currentLocale() && l.disabled))\n const currentLocaleName = createMemo(() => {\n if (local.getLocaleName) {\n return local.getLocaleName() || null\n }\n // Используем реактивный accessor для отслеживания изменений\n const current = locales().find((l) => l.code === i18n.localeAccessor())\n return current?.displayName || null\n })\n\n const toggleDropdown = (event?: Event) => {\n if (event) {\n event.stopPropagation()\n event.preventDefault()\n }\n setDropdownOpen(!dropdownOpen())\n }\n\n const localeLabel = (localeItem: Locale): string => {\n const current = local.customLabels?.[localeItem.code] || localeItem.displayName\n return current || localeItem.code\n }\n\n const currentLocaleLabel = createMemo(() => {\n const current = locales().find((l) => l.code === currentLocale())\n return current ? localeLabel(current) : currentLocaleName() || currentLocale()\n })\n\n const handleSwitchLocale = async (code: string) => {\n setDropdownOpen(false)\n\n if (local.switchLocale) {\n local.switchLocale(code)\n return\n }\n\n i18n.locale = code\n\n if (!router) {\n return\n }\n\n // Используем accessor напрямую, если доступен, иначе fallback на getCurrentPath()\n const extendedRouter = router as I18nRoutingStrategy & { getCurrentPathAccessor?: Accessor<string> }\n const currentPath = extendedRouter.getCurrentPathAccessor ? extendedRouter.getCurrentPathAccessor() : router.getCurrentPath()\n const newPath = local.localeRoute\n ? (() => {\n const res = local.localeRoute(currentPath, code)\n return typeof res === 'string' ? res : res.path || '/'\n })()\n : router?.resolvePath\n ? (() => {\n const res = router.resolvePath(currentPath, code)\n return typeof res === 'string' ? res : res.path || '/'\n })()\n : currentPath\n\n router.push({ path: newPath })\n }\n\n // Default Styles\n const wrapperStyle: JSX.CSSProperties = {\n position: 'relative',\n display: 'inline-block',\n 'vertical-align': 'middle',\n }\n\n const buttonStyle: JSX.CSSProperties = {\n padding: '4px 12px',\n 'font-size': '16px',\n cursor: 'pointer',\n 'background-color': '#fff',\n border: '1px solid #333',\n transition: 'background-color 0.3s ease',\n display: 'flex',\n 'align-items': 'center',\n 'justify-content': 'space-between',\n }\n\n const dropdownStyle: JSX.CSSProperties = {\n position: 'absolute',\n top: '100%',\n left: '0',\n 'z-index': 1000,\n 'background-color': '#fff',\n border: '1px solid #333',\n 'list-style': 'none',\n padding: '0',\n margin: '4px 0 0 0',\n 'min-width': '150px',\n 'box-shadow': '0 2px 8px rgba(0,0,0,0.15)',\n }\n\n const itemStyle: JSX.CSSProperties = {\n margin: '0',\n padding: '0',\n }\n\n const linkStyle: JSX.CSSProperties = {\n display: 'block',\n padding: '8px 12px',\n color: '#333',\n 'text-decoration': 'none',\n transition: 'background-color 0.3s ease',\n cursor: 'pointer',\n }\n\n const activeLinkStyle: JSX.CSSProperties = {\n 'font-weight': 'bold',\n color: '#007bff',\n cursor: 'not-allowed',\n }\n\n const iconStyle: JSX.CSSProperties = {\n 'margin-left': '8px',\n display: 'inline-block',\n transition: 'transform 0.3s ease',\n }\n\n const openIconStyle: JSX.CSSProperties = {\n transform: 'rotate(180deg)',\n }\n\n const handleClickOutside = (event: MouseEvent) => {\n if (!dropdownOpen()) return\n\n const target = event.target as HTMLElement\n if (!target || !wrapperRef) return\n\n const isClickInside = wrapperRef.contains(target)\n const isButtonClick = target.closest('.i18n-switcher-button') !== null\n\n if (!isClickInside && !isButtonClick) {\n setDropdownOpen(false)\n }\n }\n\n onMount(() => {\n document.addEventListener('click', handleClickOutside)\n })\n\n onCleanup(() => {\n document.removeEventListener('click', handleClickOutside)\n })\n\n return (\n <div\n // @ts-expect-error - ref type conflict with Vue JSX\n ref={(el: HTMLDivElement) => {\n wrapperRef = el\n }}\n class=\"i18n-switcher-wrapper\"\n style={{ ...wrapperStyle, ...local.customWrapperStyle }}\n {...(others as unknown as JSX.HTMLAttributes<HTMLDivElement>)}\n >\n <button\n type=\"button\"\n class=\"i18n-switcher-button\"\n style={{\n ...buttonStyle,\n ...local.customButtonStyle,\n ...(currentLocaleDisabled() ? local.customDisabledLinkStyle : {}),\n }}\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDropdown(e)\n }}\n aria-haspopup=\"true\"\n aria-expanded={dropdownOpen()}\n >\n <span>{currentLocaleLabel()}</span>\n <span\n style={{\n ...iconStyle,\n ...(dropdownOpen() ? openIconStyle : {}),\n ...local.customIconStyle,\n }}\n >\n ▼\n </span>\n </button>\n\n {dropdownOpen() && (\n <ul class=\"i18n-switcher-dropdown\" style={{ ...dropdownStyle, ...local.customDropdownStyle }}>\n {locales().map((localeItem) => {\n const isActive = localeItem.code === currentLocale()\n // Используем accessor для реактивного отслеживания пути\n const extendedRouter = router as I18nRoutingStrategy & { getCurrentPathAccessor?: Accessor<string> }\n const currentPath = extendedRouter?.getCurrentPathAccessor\n ? extendedRouter.getCurrentPathAccessor()\n : router?.getCurrentPath() || (typeof window !== 'undefined' ? window.location.pathname : '/')\n const result = local.localeRoute\n ? local.localeRoute(currentPath, localeItem.code)\n : router?.resolvePath\n ? router.resolvePath(currentPath, localeItem.code)\n : currentPath\n const routeTo = typeof result === 'string' ? result : result?.path || '#'\n\n return (\n <li style={{ ...itemStyle, ...local.customItemStyle }}>\n <a\n class={`switcher-locale-${localeItem.code}`}\n href={typeof routeTo === 'string' ? routeTo : '#'}\n style={{\n ...linkStyle,\n ...(isActive ? activeLinkStyle : {}),\n ...local.customLinkStyle,\n // active-specific customization wins over the generic link style\n // (matches the React/Preact/Vue switchers)\n ...(isActive ? local.customActiveLinkStyle : {}),\n }}\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n handleSwitchLocale(localeItem.code)\n }}\n >\n {localeLabel(localeItem)}\n </a>\n </li>\n )\n })}\n </ul>\n )}\n </div>\n ) as unknown as JSX.Element\n}\n","// @ts-nocheck\n\nimport type { PluralFunc, TranslationKey } from '@i18n-micro/types'\nimport { type Component, createMemo, type JSX, splitProps } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { useI18nContext } from '../injection'\n\ninterface I18nTProps extends JSX.HTMLAttributes<HTMLElement> {\n keypath: TranslationKey\n params?: Record<string, string | number | boolean>\n tag?: string\n plural?: number | string\n defaultValue?: string\n html?: boolean\n hideIfEmpty?: boolean\n customPluralRule?: PluralFunc\n number?: number | string\n date?: Date | string | number\n relativeDate?: Date | string | number\n}\n\nexport const I18nT: Component<I18nTProps> = (props): JSX.Element => {\n const i18n = useI18nContext()\n const [local, others] = splitProps(props, [\n 'keypath',\n 'params',\n 'tag',\n 'plural',\n 'defaultValue',\n 'html',\n 'hideIfEmpty',\n 'customPluralRule',\n 'number',\n 'date',\n 'relativeDate',\n ])\n\n // Используем createMemo для реактивности (отслеживает изменения локали и роута)\n // В Solid мемо автоматически отслеживает зависимости при использовании в JSX\n const translation = createMemo(() => {\n // Отслеживаем изменения локали и роута через accessors\n const locale = i18n.localeAccessor()\n const route = i18n.routeAccessor()\n\n // Handle number formatting\n if (local.number !== undefined) {\n const numberValue = Number(local.number)\n const formattedNumber = i18n.tn(numberValue)\n const result = i18n.t(local.keypath, { number: formattedNumber, ...(local.params || {}) }, undefined, route)\n return typeof result === 'string' ? result : String(result)\n }\n\n // Handle date formatting\n if (local.date !== undefined) {\n const formattedDate = i18n.td(local.date)\n const result = i18n.t(local.keypath, { date: formattedDate, ...(local.params || {}) }, undefined, route)\n return typeof result === 'string' ? result : String(result)\n }\n\n // Handle relative date formatting\n if (local.relativeDate !== undefined) {\n const formattedRelativeDate = i18n.tdr(local.relativeDate)\n const result = i18n.t(local.keypath, { relativeDate: formattedRelativeDate, ...(local.params || {}) }, undefined, route)\n return typeof result === 'string' ? result : String(result)\n }\n\n // Handle pluralization\n if (local.plural !== undefined) {\n const count = Number.parseInt(local.plural.toString(), 10)\n if (local.customPluralRule) {\n const translationResult = local.customPluralRule(\n local.keypath,\n count,\n local.params || {},\n locale,\n (k: TranslationKey, p?: Record<string, string | number | boolean>, dv?: string) => i18n.t(k, p, dv, route),\n )\n return translationResult || ''\n } else {\n return i18n.tc(local.keypath, { count, ...(local.params || {}) }, local.defaultValue)\n }\n }\n\n // Regular translation\n const translationResult = (i18n.t(local.keypath, local.params, local.defaultValue, route) ?? '').toString()\n\n if (local.hideIfEmpty && !translationResult.trim()) {\n return local.defaultValue || ''\n }\n\n return translationResult\n })\n\n // Если html=true, используем innerHTML и не рендерим children\n if (local.html) {\n return (\n // @ts-expect-error - Dynamic component type conflict with Vue JSX\n (\n <Dynamic component={local.tag || 'span'} {...(others as unknown as Record<string, unknown>)} innerHTML={translation()} />\n ) as unknown as JSX.Element\n )\n }\n\n // Если html=false, рендерим как текст (Solid автоматически экранирует HTML)\n const translationValue = translation()\n if (local.hideIfEmpty && !translationValue.trim()) {\n if (local.defaultValue) {\n return (\n <Dynamic component={local.tag || 'span'} {...(others as unknown as Record<string, unknown>)}>\n {local.defaultValue}\n </Dynamic>\n ) as unknown as JSX.Element\n }\n return null as unknown as JSX.Element\n }\n\n return (\n // @ts-expect-error - Dynamic component type conflict with Vue JSX\n (\n <Dynamic component={local.tag || 'span'} {...(others as unknown as Record<string, unknown>)}>\n {translationValue}\n </Dynamic>\n ) as unknown as JSX.Element\n )\n}\n","// @ts-nocheck\n\nimport type { Locale } from '@i18n-micro/types'\nimport type { JSX, ParentComponent } from 'solid-js'\nimport type { SolidI18n } from './i18n'\nimport { I18nContext, I18nDefaultLocaleContext, I18nLocalesContext, I18nRouterContext } from './injection'\nimport type { I18nRoutingStrategy } from './router/types'\n\nexport interface I18nProviderProps {\n i18n: SolidI18n\n locales?: Locale[]\n defaultLocale?: string\n routingStrategy?: I18nRoutingStrategy\n}\n\nexport const I18nProvider: ParentComponent<I18nProviderProps> = (props): JSX.Element => {\n const children = props.children as JSX.Element\n return (\n // @ts-expect-error - Provider components type conflict with Vue JSX\n (\n <I18nContext.Provider value={props.i18n}>\n {props.locales && (\n // @ts-expect-error - Provider components type conflict with Vue JSX\n <I18nLocalesContext.Provider value={props.locales}>\n {props.defaultLocale && (\n // @ts-expect-error - Provider components type conflict with Vue JSX\n <I18nDefaultLocaleContext.Provider value={props.defaultLocale}>\n {props.routingStrategy && (\n // @ts-expect-error - Provider components type conflict with Vue JSX\n <I18nRouterContext.Provider value={props.routingStrategy}>{children}</I18nRouterContext.Provider>\n )}\n {!props.routingStrategy && children}\n </I18nDefaultLocaleContext.Provider>\n )}\n {!props.defaultLocale && children}\n </I18nLocalesContext.Provider>\n )}\n {!props.locales && children}\n </I18nContext.Provider>\n ) as unknown as JSX.Element\n )\n}\n\n// Keep useI18nContext for backward compatibility\nexport { useI18nContext } from './injection'\n","import { BaseI18n, createReactiveI18nStore, type ReactiveI18nStore, type TranslationStorage } from '@i18n-micro/core'\nimport type { PluralFunc, Translations } from '@i18n-micro/types'\nimport { createSignal, type Accessor } from 'solid-js'\n\nexport interface SolidI18nOptions {\n locale: string\n fallbackLocale?: string\n messages?: Record<string, Translations>\n plural?: PluralFunc\n missingWarn?: boolean\n missingHandler?: (locale: string, key: string, routeName: string) => void\n}\n\nexport class SolidI18n extends BaseI18n {\n private readonly store: ReactiveI18nStore\n private readonly _localeSignal: Accessor<string>\n private readonly _setLocaleSignal: (v: string) => void\n private readonly _routeSignal: Accessor<string>\n private readonly _setRouteSignal: (v: string) => void\n private readonly _fallbackSignal: Accessor<string>\n\n public readonly storage: TranslationStorage\n\n constructor(options: SolidI18nOptions) {\n const storage: TranslationStorage = {\n translations: new Map<string, Translations>(),\n }\n\n super({\n storage,\n plural: options.plural,\n missingWarn: options.missingWarn,\n missingHandler: options.missingHandler,\n })\n\n this.storage = storage\n this.store = createReactiveI18nStore({\n locale: options.locale,\n fallbackLocale: options.fallbackLocale || options.locale,\n })\n\n const [locale, setLocale] = createSignal(options.locale)\n const [fallback] = createSignal(options.fallbackLocale || options.locale)\n const [route, setRoute] = createSignal('index')\n\n this._localeSignal = locale\n this._setLocaleSignal = setLocale\n this._fallbackSignal = fallback\n this._routeSignal = route\n this._setRouteSignal = setRoute\n\n this.store.subscribe(() => {\n setLocale(this.store.getLocale())\n setRoute(this.store.getRoute())\n })\n\n if (options.messages) {\n for (const [lang, msgs] of Object.entries(options.messages)) {\n this.addTranslations(lang, msgs)\n }\n }\n }\n\n public getLocale(): string {\n return this.store.getLocale()\n }\n\n public getFallbackLocale(): string {\n return this.store.getFallbackLocale()\n }\n\n public getRoute(): string {\n return this.store.getRoute()\n }\n\n public set locale(val: string) {\n this.store.setLocale(val)\n this._setLocaleSignal(val)\n this.notifyListeners()\n }\n\n public get locale(): string {\n return this._localeSignal()\n }\n\n public get localeAccessor(): Accessor<string> {\n return this._localeSignal\n }\n\n public get fallbackLocale(): string {\n return this._fallbackSignal()\n }\n\n public get currentRoute(): string {\n return this._routeSignal()\n }\n\n public get routeAccessor(): Accessor<string> {\n return this._routeSignal\n }\n\n public setRoute(val: string): void {\n this.store.setRoute(val)\n this._setRouteSignal(val)\n this.notifyListeners()\n }\n\n public addTranslations(locale: string, translations: Translations, merge = true): void {\n super.loadTranslationsCore(locale, translations, merge)\n this.store.notify()\n this.notifyListeners()\n }\n\n public addRouteTranslations(locale: string, routeName: string, translations: Translations, merge = true): void {\n super.loadRouteTranslationsCore(locale, routeName, translations, merge)\n this.store.notify()\n this.notifyListeners()\n }\n\n public override clearCache(): void {\n super.clearCache()\n this.store.notify()\n this.notifyListeners()\n }\n\n protected override onTranslationsChanged(): void {\n this.store.notify()\n this.notifyListeners()\n }\n\n private listeners = new Set<() => void>()\n\n public subscribe(cb: () => void): () => void {\n this.listeners.add(cb)\n return () => this.listeners.delete(cb)\n }\n\n public getSnapshot(): string {\n return this.store.getSnapshot()\n }\n\n private notifyListeners(): void {\n this.listeners.forEach((cb) => cb())\n }\n}\n\nexport function createI18n(options: SolidI18nOptions): SolidI18n {\n return new SolidI18n(options)\n}\n","// @ts-nocheck\n\nimport type { Locale } from '@i18n-micro/types'\nimport { A, type Location, type useNavigate } from '@solidjs/router'\nimport { type Accessor, type Component, createEffect, createSignal, type JSX } from 'solid-js'\nimport type { I18nRoutingStrategy } from './types'\n\ntype NavigateFunction = ReturnType<typeof useNavigate>\n\n/**\n * Factory for Solid Router adapter\n * Implements routing utilities for Solid Router\n * Uses @solidjs/router APIs for navigation and path resolution\n *\n * **IMPORTANT**: This function must be called inside a SolidJS component or reactive context\n * (e.g., inside a component function, not at module level). This is required because\n * `createSignal` and `createEffect` need to be within a reactive owner context.\n *\n * @example\n * ```tsx\n * const RouterRoot: Component = () => {\n * const navigate = useNavigate()\n * const location = useLocation()\n * const routingStrategy = createSolidRouterAdapter(\n * locales,\n * defaultLocale,\n * navigate,\n * location,\n * )\n * // ...\n * }\n * ```\n *\n * @param locales - Array of locale configurations\n * @param defaultLocale - Default locale code\n * @param navigate - Navigation function from @solidjs/router's useNavigate hook\n * @param location - Location object from @solidjs/router's useLocation hook\n * @returns I18nRoutingStrategy with reactive pathname accessor\n */\nexport function createSolidRouterAdapter(\n locales: Locale[],\n defaultLocale: string,\n navigate: NavigateFunction,\n location: Location,\n): I18nRoutingStrategy & { getCurrentPathAccessor: Accessor<string> } {\n const localeCodes = locales.map((loc) => loc.code)\n\n // Create signal to track pathname changes\n // NOTE: This requires a reactive context (component/effect), so this function\n // must be called inside a component, not at module level\n const [pathname, setPathname] = createSignal(location.pathname)\n\n // Track location.pathname changes\n // NOTE: createEffect requires a reactive owner, so this function must be called\n // inside a component or runWithOwner context\n createEffect(() => {\n setPathname(location.pathname)\n })\n\n const resolvePath = (to: string | { path?: string }, locale: string): string | { path?: string } => {\n const path = typeof to === 'string' ? to : to.path || '/'\n const pathSegments = path.split('/').filter(Boolean)\n\n if (pathSegments.length > 0 && localeCodes.includes(pathSegments[0])) {\n pathSegments.shift()\n }\n\n const cleanPath = `/${pathSegments.join('/')}`\n return locale === defaultLocale ? cleanPath : `/${locale}${cleanPath === '/' ? '' : cleanPath}`\n }\n\n return {\n getCurrentPath: () => pathname(), // Returns current value for compatibility\n getCurrentPathAccessor: pathname, // Returns accessor for reactivity\n\n push: (target: { path: string }) => {\n // Use navigate from @solidjs/router\n navigate(target.path)\n },\n\n replace: (target: { path: string }) => {\n // Use navigate with replace option\n navigate(target.path, { replace: true })\n },\n\n resolvePath: (to: string | { path?: string }, locale: string) => resolvePath(to, locale),\n\n getRoute: () => ({\n fullPath: pathname(),\n query: {},\n }),\n\n // Use A component from @solidjs/router\n linkComponent: ((props: { href: string; children?: JSX.Element; class?: string; style?: JSX.CSSProperties; [key: string]: unknown }) => {\n const { href, children, class: className, style, ...restProps } = props\n return (\n <A href={href} class={className} style={style} {...restProps}>\n {children}\n </A>\n ) as unknown as JSX.Element\n }) as unknown as Component<{\n href: string\n children?: JSX.Element\n style?: JSX.CSSProperties\n class?: string\n [key: string]: unknown\n }>,\n }\n}\n","import type { Locale } from '@i18n-micro/types'\nimport { createMemo } from 'solid-js'\nimport { useI18nContext, useI18nDefaultLocale, useI18nLocales, useI18nRouter } from './injection'\n\nexport interface UseI18nOptions {\n locales?: Locale[]\n defaultLocale?: string\n}\n\nexport function useI18n(options?: UseI18nOptions) {\n const i18n = useI18nContext()\n const router = useI18nRouter()\n const injectedLocales = useI18nLocales()\n const injectedDefaultLocale = useI18nDefaultLocale()\n\n const locales = options?.locales || injectedLocales\n const defaultLocale = options?.defaultLocale || injectedDefaultLocale\n\n const resolveLocalePath = (to: string | { path?: string }, localeCode?: string): string | { path?: string } => {\n if (!router?.resolvePath) {\n return to\n }\n return router.resolvePath(to, localeCode || i18n.getLocale())\n }\n\n return {\n // Direct access to instance\n instance: i18n,\n\n // Locale (reactive) - use accessor to track changes\n locale: createMemo(() => i18n.localeAccessor()),\n\n // Locale helpers\n getLocales: () => locales,\n defaultLocale: () => defaultLocale,\n getLocaleName: () => {\n // Use accessor for reactivity\n const current = locales.find((l) => l.code === i18n.localeAccessor())\n return current?.displayName || null\n },\n\n // Routing helpers\n localeRoute: resolveLocalePath,\n localePath: (to: string | { path?: string }, locale?: string): string => {\n const res = resolveLocalePath(to, locale)\n return typeof res === 'string' ? res : res.path || '/'\n },\n switchLocale: (newLocale: string) => {\n i18n.locale = newLocale\n if (router) {\n const currentPath = router.getCurrentPath()\n const newPath = resolveLocalePath(currentPath, newLocale)\n router.push(typeof newPath === 'string' ? { path: newPath } : { path: newPath.path || '/' })\n }\n },\n\n // Translation methods (delegate to instance)\n t: i18n.t.bind(i18n),\n ts: i18n.ts.bind(i18n),\n tc: i18n.tc.bind(i18n),\n tn: i18n.tn.bind(i18n),\n td: i18n.td.bind(i18n),\n tdr: i18n.tdr.bind(i18n),\n has: i18n.has.bind(i18n),\n\n // Route management\n setRoute: i18n.setRoute.bind(i18n),\n getRoute: i18n.getRoute.bind(i18n),\n getLocale: () => i18n.getLocale(),\n\n // Translation management\n addTranslations: i18n.addTranslations.bind(i18n),\n addRouteTranslations: i18n.addRouteTranslations.bind(i18n),\n resolveTranslations: i18n.resolveTranslations.bind(i18n),\n setTranslation: i18n.setTranslation.bind(i18n),\n clearCache: i18n.clearCache.bind(i18n),\n }\n}\n"],"mappings":";;;;;AAMA,IAAaka,IAAcC,EAAyB,GACvCC,IAAqBD,EAAwB,GAC7CE,IAA2BF,EAAsB,GACjDG,IAAoBH,EAA+C,GAGnEI,UAAuB;CAClC,IAAMC,IAAUC,EAAWP,CAAW;CACtC,IAAI,CAACM,GACH,MAAU,MAAM,qEAAqE;CAEvF,OAAOA;AACT,GAEaE,UAAuB;CAClC,IAAMF,IAAUC,EAAWL,CAAkB;CAC7C,IAAI,CAACI,GACH,MAAU,MAAM,sFAAsF;CAExG,OAAOA;AACT,GAEaG,UAA6B;CACxC,IAAMH,IAAUC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GACxC,OAAO,OAAOvB,KAAQ,WAAWA,IAAMA,EAAI,QAAQ;EACrD;EACA,eAAe,MAAsB;GAEnC,IADA,EAAK,SAASyH,GACV9H,GAAQ;IACV,IAAMwC,IAAcxC,EAAO,eAAe,GACpCyC,IAAUmF,EAAkBpF,GAAasF,CAAS;IACxD,EAAO,KAAK,OAAOrF,KAAY,WAAW,EAAE,MAAMA,EAAQ,IAAI,EAAE,MAAMA,EAAQ,QAAQ,IAAI,CAAC;GAC7F;EACF;EAGA,GAAG5D,EAAK,EAAE,KAAKA,CAAI;EACnB,IAAIA,EAAK,GAAG,KAAKA,CAAI;EACrB,IAAIA,EAAK,GAAG,KAAKA,CAAI;EACrB,IAAIA,EAAK,GAAG,KAAKA,CAAI;EACrB,IAAIA,EAAK,GAAG,KAAKA,CAAI;EACrB,KAAKA,EAAK,IAAI,KAAKA,CAAI;EACvB,KAAKA,EAAK,IAAI,KAAKA,CAAI;EAGvB,UAAUA,EAAK,SAAS,KAAKA,CAAI;EACjC,UAAUA,EAAK,SAAS,KAAKA,CAAI;EACjC,iBAAiBA,EAAK,UAAU;EAGhC,iBAAiBA,EAAK,gBAAgB,KAAKA,CAAI;EAC/C,sBAAsBA,EAAK,qBAAqB,KAAKA,CAAI;EACzD,qBAAqBA,EAAK,oBAAoB,KAAKA,CAAI;EACvD,gBAAgBA,EAAK,eAAe,KAAKA,CAAI;EAC7C,YAAYA,EAAK,WAAW,KAAKA,CAAI;CACvC;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["TranslationKey","Component","createMemo","JSX","splitProps","useI18nContext","I18nGroupProps","Omit","HTMLAttributes","HTMLDivElement","prefix","groupClass","children","Element","props","t","key","params","Record","I18nGroup","i18n","local","others","translate","ts","className","class","filter","Boolean","join","_el$","_tmpl$","_$spread","_$mergeProps","_$insert","_c$","_$memo","_tmpl$","_$mergeProps","_$memo","externalLinkHref","isActiveLink","isPlainClick","Component","createMemo","JSX","mergeProps","splitProps","Dynamic","useI18nContextValue","RouteTarget","routePath","useI18n","mergeStyles","I18nLinkProps","AnchorHTMLAttributes","HTMLAnchorElement","to","localeRoute","locale","activeStyle","CSSProperties","callHandler","handler","event","Parameters","ClickHandler","EventHandler","MouseEvent","I18nLink","props","Element","context","i18n","api","local","others","externalHref","target","isActive","router","undefined","codes","defaultLocale","fallbackLocale","getLocales","map","l","code","getCurrentPath","handleClick","onClick","preventDefault","push","path","usesRouterLink","linkComponent","merged","href","style","rel","_$createComponent","_$mergeProps","component","_$memo","mergeProps","_$createComponent","_$mergeProps","_$memo","isPlainClick","ownValue","SWITCHER_STYLES","Locale","Component","createMemo","createSignal","For","JSX","onCleanup","onMount","Show","splitProps","useI18nContextValue","RouteTarget","routePath","useI18n","mergeStyles","I18nSwitcherProps","HTMLAttributes","HTMLDivElement","locales","currentLocale","getLocaleName","switchLocale","locale","localeRoute","to","customLabels","Record","customWrapperStyle","CSSProperties","customButtonStyle","customDropdownStyle","customItemStyle","customLinkStyle","customActiveLinkStyle","customDisabledLinkStyle","customIconStyle","css","style","Object","fromEntries","entries","map","name","value","replace","char","toLowerCase","WRAPPER_STYLE","wrapper","BUTTON_STYLE","button","DROPDOWN_STYLE","dropdown","ITEM_STYLE","item","LINK_STYLE","link","ACTIVE_LINK_STYLE","activeLink","ICON_STYLE","icon","OPEN_ICON_STYLE","openIcon","I18nSwitcher","props","Element","i18n","context","local","others","open","setOpen","allLocales","current","prop","currentItem","find","l","code","label","displayName","href","router","path","getCurrentPath","window","location","pathname","search","hash","resolvePath","select","event","MouseEvent","preventDefault","instance","push","onDocumentClick","contains","target","Node","onKeydown","KeyboardEvent","key","document","addEventListener","removeEventListener","_el$","_tmpl$2","_el$2","firstChild","_el$3","_el$4","nextSibling","_el$5","_$use","element","_$spread","_$mergeProps","class","filter","Boolean","join","$$click","_$insert","_$createComponent","when","children","_el$6","_tmpl$","each","disabled","active","language","iso","_el$7","_tmpl$3","_el$8","_$setAttribute","_$effect","_p$","_v$4","_v$5","_v$6","_v$7","dir","_v$8","undefined","_v$9","e","_$style","t","_$className","a","o","i","n","_$p","_v$","_v$2","_v$3","_$delegateEvents","_tmpl$","_$mergeProps","_$createComponent","_$style","_$className","_$setAttribute","_$delegateEvents","foldTemplate","RenderSlot","RenderSlots","interpolate","resolveText","ResolveTextOptions","Component","createMemo","createRoot","getOwner","JSX","mergeProps","onCleanup","splitProps","Dynamic","useI18nContext","I18nTComponent","Element","I18nTProps","Omit","HTMLAttributes","HTMLElement","tag","components","Record","children","props","translation","OWN_PROPS","const","CONTENT_ATTRS","isUnset","undefined","toSlots","slots","Object","create","name","keys","value","I18nT","i18n","local","attrs","resolved","localeAccessor","text","template","params","slotScope","nodes","Map","node","dispose","built","values","owner","renderSlot","slot","key","has","set","get","foldSlots","used","Set","folded","add","delete","content","element","body","merged","_$createComponent","_$mergeProps","component","_el$","_tmpl$","_$spread","HTMLSpanElement","markup","innerHTML","_$memo","defaultValue","html","interpolate","mergeProps","_$createComponent","_$mergeProps","_$memo","localeIsoMap","Locale","createComputed","JSX","ParentComponent","useContext","SolidI18n","I18nContext","I18nRoutingStrategy","I18nProviderProps","i18n","locales","defaultLocale","routingStrategy","I18nProvider","props","Element","outer","value","Error","router","addLocaleIso","_$createComponent","Provider","children","useI18nContext","_$createComponent","interpolate$1","mergeProps$1","I18nContext","createContext","useI18nContextValue","context","useContext","useI18nContext","useI18nLocales","useI18nDefaultLocale","useI18nRouter","_tmpl$$2","I18nGroup","i18n","local","others","splitProps","props","translate","key","params","className","createMemo","_el$","spread","mergeProps","\"class\"","insert","_c$","memo","routePath","target","createApi","locales","options","localeRoute","resolve","to","code","l","locale","newLocale","router","useI18n","cssText","style","name","value","mergeStyles","styles","callHandler","handler","event","I18nLink","api","externalHref","externalLinkHref","isActive","codes","isActiveLink","handleClick","isPlainClick","usesRouterLink","merged","createComponent","Dynamic","_tmpl$$1","_tmpl$2","_tmpl$3","css","char","WRAPPER_STYLE","SWITCHER_STYLES","BUTTON_STYLE","DROPDOWN_STYLE","ITEM_STYLE","LINK_STYLE","ACTIVE_LINK_STYLE","ICON_STYLE","OPEN_ICON_STYLE","I18nSwitcher","open","setOpen","createSignal","wrapper","allLocales","current","prop","currentItem","label","ownValue","href","path","select","onDocumentClick","onKeydown","onMount","onCleanup","_el$2","_el$3","_el$5","use","element","Show","_el$6","For","active","language","_el$7","_el$8","setAttribute","effect","_v$4","_v$5","_v$6","_v$7","_v$8","_v$9","_p$","_$p","_v$","_v$2","_v$3","delegateEvents","_tmpl$","OWN_PROPS","CONTENT_ATTRS","isUnset","children","toSlots","slots","components","I18nT","attrs","resolved","resolveText","text","template","slotScope","nodes","built","getOwner","renderSlot","createRoot","slot","owner","foldSlots","used","folded","foldTemplate","content","body","markup","I18nProvider","outer","createComputed","localeIsoMap","SolidI18n","I18n","revision","setRevision","setLocale","fallback","setFallback","route","setRoute","n","createI18n","FormatService","defaultPlural","interpolate"],"sources":["../src/injection.ts","../src/components/I18nGroup.tsx","../src/use-i18n.ts","../src/components/merge-styles.ts","../src/components/I18nLink.tsx","../src/components/I18nSwitcher.tsx","../src/components/I18nT.tsx","../src/context.tsx","../src/i18n.ts"],"sourcesContent":["import type { Locale } from '@i18n-micro/types'\nimport { createContext, useContext } from 'solid-js'\nimport type { SolidI18n } from './i18n'\nimport type { I18nRoutingStrategy } from './router/types'\nimport type { UseI18nReturn } from './use-i18n'\n\n/** Everything a provider hands down: getters over its props, so they stay reactive. */\nexport interface I18nContextValue {\n readonly i18n: SolidI18n\n readonly locales: Locale[] | undefined\n readonly defaultLocale: string | undefined\n readonly router: I18nRoutingStrategy | undefined\n /** The `useI18n()` object: one per provider, signals do the rest. */\n api?: UseI18nReturn\n}\n\nexport const I18nContext = createContext<I18nContextValue>()\n\nexport const useI18nContextValue = (): I18nContextValue => {\n const context = useContext(I18nContext)\n if (!context) {\n throw new Error('[i18n-micro] I18nContext not found. Make sure I18nProvider is used.')\n }\n return context\n}\n\nexport const useI18nContext = (): SolidI18n => useI18nContextValue().i18n\n// One read at setup. A component that follows a provider's changes reads `useI18n().getLocales()`, or the context, inside a memo.\nexport const useI18nLocales = (): Locale[] | undefined => useContext(I18nContext)?.locales\nexport const useI18nDefaultLocale = (): string | undefined => useContext(I18nContext)?.defaultLocale\nexport const useI18nRouter = (): I18nRoutingStrategy | undefined => useContext(I18nContext)?.router\n","import type { TranslationKey } from '@i18n-micro/types'\nimport { type Component, createMemo, type JSX, splitProps } from 'solid-js'\nimport { useI18nContext } from '../injection'\n\nexport interface I18nGroupProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'> {\n prefix: string\n groupClass?: string\n children?:\n | JSX.Element\n | ((props: { prefix: string; t: (key: string, params?: Record<string, string | number | boolean>) => string }) => JSX.Element)\n}\n\nexport const I18nGroup: Component<I18nGroupProps> = (props): JSX.Element => {\n const i18n = useI18nContext()\n const [local, others] = splitProps(props, ['prefix', 'groupClass', 'class', 'children'])\n\n const translate = (key: string, params?: Record<string, string | number | boolean>): string =>\n i18n.ts(`${local.prefix}.${key}` as TranslationKey, params)\n\n const className = createMemo(() => ['i18n-group', local.groupClass, local.class].filter(Boolean).join(' '))\n\n return (\n <div class={className()} {...others}>\n {typeof local.children === 'function' ? local.children({ prefix: local.prefix, t: translate }) : local.children}\n </div>\n )\n}\n","import type { Locale } from '@i18n-micro/types'\nimport type { Accessor } from 'solid-js'\nimport type { SolidI18n } from './i18n'\nimport { type I18nContextValue, useI18nContextValue } from './injection'\nimport type { RouteTarget } from './router/types'\n\nexport interface UseI18nOptions {\n locales?: Locale[]\n defaultLocale?: string\n}\n\nexport const routePath = (target: RouteTarget): string => (typeof target === 'string' ? target : target.path || '/')\n\nfunction createApi(context: I18nContextValue, options?: UseI18nOptions) {\n const i18n = context.i18n\n const locales = (): Locale[] => options?.locales ?? context.locales ?? []\n const localeRoute = (to: RouteTarget, code?: string): RouteTarget => {\n const resolve = context.router?.resolvePath\n return resolve ? resolve(to, code || i18n.locale) : to\n }\n\n return {\n // Direct access to instance\n instance: i18n as SolidI18n,\n\n // An accessor, the Solid way: `locale()` in JSX stays reactive, a plain value would not.\n locale: i18n.localeAccessor as Accessor<string>,\n\n getLocales: locales,\n defaultLocale: (): string => options?.defaultLocale ?? context.defaultLocale ?? i18n.fallbackLocale,\n getLocaleName: (): string | null => locales().find((l) => l.code === i18n.locale)?.displayName || null,\n\n // Routing helpers: they read the reactive locale, so an effect or memo follows it\n localeRoute,\n localePath: (to: RouteTarget, locale?: string): string => routePath(localeRoute(to, locale)),\n switchLocale: (newLocale: string): void => {\n i18n.locale = newLocale\n const router = context.router\n if (router) router.push({ path: routePath(localeRoute(router.getCurrentPath(), newLocale)) })\n },\n\n // Translation methods (delegate to instance)\n t: i18n.t.bind(i18n),\n ts: i18n.ts.bind(i18n),\n tc: i18n.tc.bind(i18n),\n tn: i18n.tn.bind(i18n),\n td: i18n.td.bind(i18n),\n tdr: i18n.tdr.bind(i18n),\n has: i18n.has.bind(i18n),\n\n // Route management\n setRoute: i18n.setRoute.bind(i18n),\n getRoute: (): string => i18n.currentRoute,\n getLocale: (): string => i18n.locale,\n\n // Translation management\n addTranslations: i18n.addTranslations.bind(i18n),\n addRouteTranslations: i18n.addRouteTranslations.bind(i18n),\n resolveTranslations: i18n.resolveTranslations.bind(i18n),\n setTranslation: i18n.setTranslation.bind(i18n),\n clearCache: i18n.clearCache.bind(i18n),\n }\n}\n\nexport type UseI18nReturn = ReturnType<typeof createApi>\n\n/** One object per provider; hook options make their own, and win over the provider. */\nexport function useI18n(options?: UseI18nOptions): UseI18nReturn {\n const context = useI18nContextValue()\n if (options?.locales || options?.defaultLocale) return createApi(context, options)\n return (context.api ??= createApi(context))\n}\n","import type { JSX } from 'solid-js'\n\ntype Style = JSX.CSSProperties | string | undefined\n\nconst cssText = (style: Style): string =>\n typeof style === 'string'\n ? style\n : Object.entries(style ?? {})\n .map(([name, value]) => `${name}:${value}`)\n .join(';')\n\n/** Later wins. Solid's `style` takes an object or a CSS string; a string among them makes the result one too. */\nexport function mergeStyles(...styles: Style[]): JSX.CSSProperties | string {\n if (styles.some((style) => typeof style === 'string')) return styles.map(cssText).filter(Boolean).join(';')\n return Object.assign({}, ...styles)\n}\n","import { externalLinkHref, isActiveLink, isPlainClick } from '@i18n-micro/core'\nimport { type Component, createMemo, type JSX, mergeProps, splitProps } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { useI18nContextValue } from '../injection'\nimport type { RouteTarget } from '../router/types'\nimport { routePath, useI18n } from '../use-i18n'\nimport { mergeStyles } from './merge-styles'\n\nexport interface I18nLinkProps extends JSX.AnchorHTMLAttributes<HTMLAnchorElement> {\n to: RouteTarget\n localeRoute?: (to: RouteTarget, locale?: string) => RouteTarget\n activeStyle?: JSX.CSSProperties\n}\n\n/** Solid's two handler shapes: a function, or `[function, data]`. */\nfunction callHandler(handler: I18nLinkProps['onClick'], event: Parameters<ClickHandler>[0]): void {\n if (typeof handler === 'function') handler(event)\n else if (handler) handler[0](handler[1], event)\n}\n\ntype ClickHandler = JSX.EventHandler<HTMLAnchorElement, MouseEvent>\n\nexport const I18nLink: Component<I18nLinkProps> = (props): JSX.Element => {\n // the provider's props are reactive: `context.router` is read where it is used\n const context = useI18nContextValue()\n const i18n = context.i18n\n const api = useI18n()\n const [local, others] = splitProps(props, ['to', 'localeRoute', 'activeStyle', 'style', 'onClick'])\n\n const externalHref = createMemo(() => externalLinkHref(local.to))\n const target = createMemo(() => routePath((local.localeRoute ?? api.localeRoute)(local.to, i18n.locale)))\n\n const isActive = createMemo(() => {\n const router = context.router\n if (!router || !local.activeStyle || externalHref() !== undefined) return false\n // The current, default and fallback locale count too, so a provider without `locales` still knows its own root.\n const codes = [i18n.locale, api.defaultLocale(), i18n.fallbackLocale, ...api.getLocales().map((l) => l.code)]\n return isActiveLink(router.getCurrentPath(), target(), codes)\n })\n\n const handleClick: ClickHandler = (event) => {\n callHandler(local.onClick, event)\n const router = context.router\n if (!router || externalHref() !== undefined || !isPlainClick(event)) return\n event.preventDefault()\n router.push({ path: target() })\n }\n\n const usesRouterLink = () => externalHref() === undefined && context.router?.linkComponent !== undefined\n\n const merged = mergeProps(others, {\n get href() {\n return externalHref() ?? target()\n },\n get style() {\n return isActive() ? mergeStyles(local.style, local.activeStyle) : local.style\n },\n // a router link handles its own clicks\n get onClick() {\n return usesRouterLink() ? local.onClick : handleClick\n },\n get target() {\n return externalHref() === undefined ? undefined : (others.target ?? '_blank')\n },\n get rel() {\n return externalHref() === undefined ? undefined : (others.rel ?? 'noopener noreferrer')\n },\n })\n\n return <Dynamic component={usesRouterLink() ? context.router!.linkComponent! : 'a'} {...merged} />\n}\n","import { isPlainClick, ownValue } from '@i18n-micro/core'\nimport { SWITCHER_STYLES } from '@i18n-micro/core/render'\nimport type { Locale } from '@i18n-micro/types'\nimport { type Component, createMemo, createSignal, For, type JSX, onCleanup, onMount, Show, splitProps } from 'solid-js'\nimport { useI18nContextValue } from '../injection'\nimport type { RouteTarget } from '../router/types'\nimport { routePath, useI18n } from '../use-i18n'\nimport { mergeStyles } from './merge-styles'\n\nexport interface I18nSwitcherProps extends JSX.HTMLAttributes<HTMLDivElement> {\n locales?: Locale[]\n currentLocale?: string | (() => string)\n getLocaleName?: () => string | null\n switchLocale?: (locale: string) => void\n localeRoute?: (to: RouteTarget, locale?: string) => RouteTarget\n customLabels?: Record<string, string>\n customWrapperStyle?: JSX.CSSProperties\n customButtonStyle?: JSX.CSSProperties\n customDropdownStyle?: JSX.CSSProperties\n customItemStyle?: JSX.CSSProperties\n customLinkStyle?: JSX.CSSProperties\n customActiveLinkStyle?: JSX.CSSProperties\n /**\n * Inline style applied to the main switcher button when the current locale is\n * marked as `disabled: true` in locale config.\n *\n * Disabled locales are omitted from dropdown items.\n */\n customDisabledLinkStyle?: JSX.CSSProperties\n customIconStyle?: JSX.CSSProperties\n}\n\n/** Core's look with Solid's property names: `style` here takes CSS names. */\nconst css = (style: object): JSX.CSSProperties =>\n Object.fromEntries(\n Object.entries(style).map(([name, value]) => [name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`), value]),\n ) as JSX.CSSProperties\n\nconst WRAPPER_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.wrapper)\nconst BUTTON_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.button)\nconst DROPDOWN_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.dropdown)\nconst ITEM_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.item)\nconst LINK_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.link)\nconst ACTIVE_LINK_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.activeLink)\nconst ICON_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.icon)\nconst OPEN_ICON_STYLE = /*#__PURE__*/ css(SWITCHER_STYLES.openIcon)\n\nexport const I18nSwitcher: Component<I18nSwitcherProps> = (props): JSX.Element => {\n const i18n = useI18n()\n // the provider's props are reactive: its values are read where they are used\n const context = useI18nContextValue()\n\n const [local, others] = splitProps(props, [\n 'locales',\n 'currentLocale',\n 'getLocaleName',\n 'switchLocale',\n 'localeRoute',\n 'customLabels',\n 'customWrapperStyle',\n 'customButtonStyle',\n 'customDropdownStyle',\n 'customItemStyle',\n 'customLinkStyle',\n 'customActiveLinkStyle',\n 'customDisabledLinkStyle',\n 'customIconStyle',\n 'class',\n 'style',\n ])\n\n const [open, setOpen] = createSignal(false)\n let wrapper: HTMLDivElement | undefined\n\n const allLocales = createMemo(() => local.locales ?? context.locales ?? [])\n const current = createMemo(() => {\n const prop = local.currentLocale\n return typeof prop === 'function' ? prop() : (prop ?? i18n.locale())\n })\n const currentItem = createMemo(() => allLocales().find((l) => l.code === current()))\n\n const label = (locale: Locale): string =>\n (local.customLabels && (ownValue(local.customLabels, locale.code) as string)) || locale.displayName || locale.code\n\n const href = (code: string): string => {\n const router = context.router\n const path =\n router?.getCurrentPath() ?? (typeof window === 'undefined' ? '/' : window.location.pathname + window.location.search + window.location.hash)\n if (local.localeRoute) return routePath(local.localeRoute(path, code))\n if (!router) return '#'\n return routePath(router.resolvePath ? router.resolvePath(path, code) : path)\n }\n\n const select = (event: MouseEvent, code: string): void => {\n if (!isPlainClick(event)) return\n // a custom `localeRoute` with nothing to navigate: `href` is a real page, the browser's to follow\n if (local.switchLocale || context.router || !local.localeRoute) event.preventDefault()\n setOpen(false)\n if (local.switchLocale) return local.switchLocale(code)\n if (!local.localeRoute) return i18n.switchLocale(code)\n i18n.instance.locale = code\n context.router?.push({ path: href(code) })\n }\n\n const onDocumentClick = (event: MouseEvent) => {\n if (open() && !wrapper?.contains(event.target as Node)) setOpen(false)\n }\n const onKeydown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') setOpen(false)\n }\n\n // inside onMount: a cleanup registered at setup also runs on the server, where document is missing\n onMount(() => {\n document.addEventListener('click', onDocumentClick)\n document.addEventListener('keydown', onKeydown)\n onCleanup(() => {\n document.removeEventListener('click', onDocumentClick)\n document.removeEventListener('keydown', onKeydown)\n })\n })\n\n return (\n <div\n {...others}\n ref={(element) => {\n wrapper = element\n }}\n class={['i18n-switcher-wrapper', local.class].filter(Boolean).join(' ')}\n style={mergeStyles(WRAPPER_STYLE, local.customWrapperStyle, local.style)}\n >\n <button\n type=\"button\"\n class=\"i18n-switcher-button language-switcher\"\n style={{ ...BUTTON_STYLE, ...local.customButtonStyle, ...(currentItem()?.disabled ? local.customDisabledLinkStyle : undefined) }}\n aria-expanded={open()}\n onClick={() => setOpen(!open())}\n >\n <span>{local.getLocaleName?.() || label(currentItem() ?? { code: current() })}</span>{' '}\n <span style={{ ...ICON_STYLE, ...(open() ? OPEN_ICON_STYLE : undefined), ...local.customIconStyle }}>▾</span>\n </button>\n\n <Show when={open()}>\n <ul class=\"i18n-switcher-dropdown\" style={{ ...DROPDOWN_STYLE, ...local.customDropdownStyle }}>\n <For each={allLocales().filter((locale) => !locale.disabled)}>\n {(locale) => {\n const active = () => locale.code === current()\n const language = locale.iso || locale.code\n return (\n <li style={{ ...ITEM_STYLE, ...local.customItemStyle }}>\n <a\n class={`switcher-locale-${locale.code}`}\n href={href(locale.code)}\n hreflang={language}\n lang={language}\n dir={locale.dir}\n aria-current={active() ? 'page' : undefined}\n style={{\n ...LINK_STYLE,\n ...(active() ? ACTIVE_LINK_STYLE : undefined),\n ...local.customLinkStyle,\n ...(active() ? local.customActiveLinkStyle : undefined),\n }}\n onClick={(event) => select(event, locale.code)}\n >\n {label(locale)}\n </a>\n </li>\n )\n }}\n </For>\n </ul>\n </Show>\n </div>\n )\n}\n","import { foldTemplate, type RenderSlot, type RenderSlots } from '@i18n-micro/core/render'\nimport { interpolate, resolveText, type ResolveTextOptions } from '@i18n-micro/core'\nimport { type Component, createMemo, createRoot, getOwner, type JSX, mergeProps, onCleanup, splitProps } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { useI18nContext } from '../injection'\n\n/** What fills a `{name}` placeholder. A function may run per occurrence; one node can only stand in one place. */\nexport type I18nTComponent = JSX.Element | (() => JSX.Element)\n\nexport interface I18nTProps extends Omit<JSX.HTMLAttributes<HTMLElement>, 'children'>, ResolveTextOptions {\n tag?: string\n /** Elements for `{name}` placeholders. Beats a param of the same name. */\n components?: Record<string, I18nTComponent>\n /** Replaces the text. As a function it gets the translation, like Vue's default slot. */\n children?: JSX.Element | ((props: { translation: string }) => JSX.Element)\n}\n\nconst OWN_PROPS = [\n 'keypath',\n 'params',\n 'tag',\n 'plural',\n 'defaultValue',\n 'html',\n 'hideIfEmpty',\n 'customPluralRule',\n 'number',\n 'date',\n 'relativeDate',\n 'components',\n 'children',\n] as const\n\n/** Attributes that would set the content, and with it get past the `html` prop. */\nconst CONTENT_ATTRS = ['innerHTML', 'textContent', 'dangerouslySetInnerHTML', 'prop:innerHTML', 'prop:textContent'] as const\n\n/** What JSX itself draws as nothing: no children, not empty ones. */\nconst isUnset = (children: unknown): boolean => children === undefined || children === null || typeof children === 'boolean'\n\nfunction toSlots(components: I18nTProps['components']): RenderSlots {\n const slots: Record<string, RenderSlot> = Object.create(null)\n for (const name of Object.keys(components ?? {})) {\n const value = components![name]\n if (value !== undefined) slots[name] = typeof value === 'function' ? (value as RenderSlot) : () => value\n }\n return slots\n}\n\nexport const I18nT: Component<I18nTProps> = (props): JSX.Element => {\n const i18n = useI18nContext()\n const [local, , attrs] = splitProps(props, OWN_PROPS, CONTENT_ATTRS as never)\n\n const resolved = createMemo(() => {\n // a custom rule may read only its `locale` argument, which core takes untracked\n i18n.localeAccessor()\n return resolveText(i18n, local)\n })\n const text = (): string => {\n const { template, params } = resolved()!\n return interpolate(template, params)\n }\n\n // A locale that reorders placeholders moves these nodes: each is built once, in a root of its own,\n // and disposed when the template drops it or new `components` replace the slots.\n const slotScope = createMemo(() => {\n const nodes = new Map<string, { node: unknown; dispose: () => void }>()\n onCleanup(() => {\n for (const built of nodes.values()) built.dispose()\n })\n return { slots: toSlots(local.components), nodes, owner: getOwner() }\n })\n const renderSlot = (slot: RenderSlot, key: string): unknown => {\n const { nodes, owner } = slotScope()\n if (!nodes.has(key))\n nodes.set(\n key,\n createRoot((dispose) => ({ node: slot({}), dispose }), owner),\n )\n return nodes.get(key)!.node\n }\n const foldSlots = (): unknown => {\n const { template, params } = resolved()!\n const { slots, nodes } = slotScope()\n const used = new Set<string>()\n const folded = foldTemplate(\n (slot, key) => {\n used.add(key)\n return renderSlot(slot, key)\n },\n template,\n params,\n slots,\n )\n for (const [key, built] of nodes) {\n if (used.has(key)) continue\n built.dispose()\n nodes.delete(key)\n }\n return folded\n }\n\n const content = (): JSX.Element => {\n const children = local.children\n if (typeof children === 'function') return children({ translation: text() })\n if (!isUnset(children)) return children\n return foldSlots() as JSX.Element\n }\n\n // a static tag skips `Dynamic`: one memo per element less\n const element = (body: object): JSX.Element => {\n const merged = mergeProps(attrs, body)\n return local.tag ? <Dynamic component={local.tag} {...merged} /> : <span {...(merged as JSX.HTMLAttributes<HTMLSpanElement>)} />\n }\n const markup = {\n get innerHTML() {\n return text()\n },\n }\n const body = {\n get children() {\n return content()\n },\n }\n\n return <>{resolved() === null ? local.defaultValue : local.html ? element(markup) : element(body)}</>\n}\n","import { localeIsoMap } from '@i18n-micro/core'\nimport type { Locale } from '@i18n-micro/types'\nimport { createComputed, type JSX, type ParentComponent, useContext } from 'solid-js'\nimport type { SolidI18n } from './i18n'\nimport { I18nContext } from './injection'\nimport type { I18nRoutingStrategy } from './router/types'\n\nexport interface I18nProviderProps {\n /** Without it, the outer provider's instance. */\n i18n?: SolidI18n\n locales?: Locale[]\n defaultLocale?: string\n routingStrategy?: I18nRoutingStrategy\n}\n\n// An omitted prop keeps the value of an outer provider.\nexport const I18nProvider: ParentComponent<I18nProviderProps> = (props): JSX.Element => {\n const outer = useContext(I18nContext)\n const value = {\n get i18n() {\n const i18n = props.i18n ?? outer?.i18n\n if (!i18n) throw new Error('[i18n-micro] I18nProvider needs an `i18n` instance or an outer provider.')\n return i18n\n },\n get locales() {\n return props.locales ?? outer?.locales\n },\n get defaultLocale() {\n return props.defaultLocale ?? outer?.defaultLocale\n },\n get router() {\n return props.routingStrategy ?? outer?.router\n },\n }\n createComputed(() => {\n if (props.locales) value.i18n.addLocaleIso(localeIsoMap(props.locales))\n })\n return <I18nContext.Provider value={value}>{props.children}</I18nContext.Provider>\n}\n\nexport { useI18nContext } from './injection'\n","import { I18n, type I18nOptions } from '@i18n-micro/runtime'\nimport { type Accessor, batch, createSignal } from 'solid-js'\n\nexport type SolidI18nOptions = I18nOptions\n\n/**\n * The runtime instance with signals over its store. A translation read tracks the revision, which\n * every change bumps. Reading the locale tracks the locale alone, so `createEffect(() => load(locale()))`\n * does not wake itself. `getLocale()` and `getRoute()` stay plain, as a write reads them too: track\n * with `locale` and `currentRoute`.\n */\nexport class SolidI18n extends I18n {\n private readonly revision: Accessor<number>\n private readonly localeSignal: Accessor<string>\n private readonly fallbackSignal: Accessor<string>\n private readonly routeSignal: Accessor<string>\n\n public readonly localeAccessor: Accessor<string> = () => this.locale\n public readonly routeAccessor: Accessor<string> = () => this.currentRoute\n\n constructor(options: SolidI18nOptions) {\n super(options)\n const [revision, setRevision] = createSignal(0)\n const [locale, setLocale] = createSignal(this.getLocale())\n const [fallback, setFallback] = createSignal(this.getFallbackLocale())\n const [route, setRoute] = createSignal(this.getRoute())\n this.revision = revision\n this.localeSignal = locale\n this.fallbackSignal = fallback\n this.routeSignal = route\n this.subscribe(() => {\n batch(() => {\n setLocale(this.getLocale())\n setFallback(this.getFallbackLocale())\n setRoute(this.getRoute())\n setRevision((n) => n + 1)\n })\n })\n }\n\n protected override touch(): void {\n this.revision()\n }\n\n override get locale(): string {\n return this.localeSignal()\n }\n\n override set locale(value: string) {\n super.locale = value\n }\n\n override get fallbackLocale(): string {\n return this.fallbackSignal()\n }\n\n override set fallbackLocale(value: string) {\n super.fallbackLocale = value\n }\n\n override get currentRoute(): string {\n return this.routeSignal()\n }\n}\n\nexport function createI18n(options: SolidI18nOptions): SolidI18n {\n return new SolidI18n(options)\n}\n"],"mappings":";;;;;;AAgBA,IAAagZ,IAAcC,EAAgC,GAE9CC,UAA8C;CACzD,IAAMC,IAAUC,EAAWJ,CAAW;CACtC,IAAI,CAACG,GACH,MAAU,MAAM,qEAAqE;CAEvF,OAAOA;AACT,GAEaE,UAAkCH,EAAoB,CAAC,CAAC,MAExDI,WAA6CF,EAAWJ,CAAW,CAAC,EAAE,SACtEO,UAAiDH,EAAWJ,CAAW,CAAC,EAAE,eAC1EQ,UAAuDJ,EAAWJ,CAAW,CAAC,EAAE,Q,8BClBhF7X,KAAwCL,MAAuB;CAC1E,IAAMM,IAAOf,EAAe,GACtB,CAACgB,GAAOC,KAAUlB,EAAWU,GAAO;EAAC;EAAU;EAAc;EAAS;CAAU,CAAC,GAEjFS,KAAaP,GAAaC,MAC9BG,EAAKI,GAAG,GAAGH,EAAMX,OAAM,GAAIM,KAAyBC,CAAM,GAEtDQ,IAAYvB,QAAiB;EAAC;EAAcmB,EAAMV;EAAYU,EAAMK;CAAK,CAAC,CAACC,OAAOC,OAAO,CAAC,CAACC,KAAK,GAAG,CAAC;CAE1G,cAAA;EAAA,IAAAC,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,GACDW,EAAQf,EAAYgB,UAAQ;EAAQL;EAAK,IAAAM,WAAA;GAAA,OAAGT,EAAMS;EAAQ;CAAA,CAAA;AAC5D,GC3BagK,IAAb,cAA+BC,EAAK;CAClC;CACA;CACA;CACA;CAEA,uBAAyD,KAAK;CAC9D,sBAAwD,KAAK;CAE7D,YAAY,GAA2B;EACrC,MAAM5H,CAAO;EACb,IAAM,CAAC6H,GAAUC,KAAe7E,EAAa,CAAC,GACxC,CAAC3C,GAAQyH,KAAa9E,EAAa,KAAK,UAAU,CAAC,GACnD,CAAC+E,GAAUC,KAAehF,EAAa,KAAK,kBAAkB,CAAC,GAC/D,CAACiF,GAAOC,KAAYlF,EAAa,KAAK,SAAS,CAAC;EAKtD,AAJA,KAAK,WAAW4E,GAChB,KAAK,eAAevH,GACpB,KAAK,iBAAiB0H,GACtB,KAAK,cAAcE,GACnB,KAAK,gBAAgB;GACnB,QAAY;IAIV,AAHAH,EAAU,KAAK,UAAU,CAAC,GAC1BE,EAAY,KAAK,kBAAkB,CAAC,GACpCE,EAAS,KAAK,SAAS,CAAC,GACxBL,GAAa,MAAMM,IAAI,CAAC;GAC1B,CAAC;EACH,CAAC;CACH;CAEA,QAAiC;EAC/B,KAAK,SAAS;CAChB;CAEA,IAAa,SAAiB;EAC5B,OAAO,KAAK,aAAa;CAC3B;CAEA,IAAa,OAAO,GAAe;EACjC,MAAM,SAASvH;CACjB;CAEA,IAAa,iBAAyB;EACpC,OAAO,KAAK,eAAe;CAC7B;CAEA,IAAa,eAAe,GAAe;EACzC,MAAM,iBAAiBA;CACzB;CAEA,IAAa,eAAuB;EAClC,OAAO,KAAK,YAAY;CAC1B;AACF;AAEA,SAAgBwH,GAAW,GAAsC;CAC/D,OAAO,IAAIV,EAAU3H,CAAO;AAC9B"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@i18n-micro/core"),t=require("solid-js/web"),n=require("@solidjs/router");var r=e=>(0,t.createComponent)(n.A,e);function i(t,n,i,a){let o=t.map(e=>e.code),s=()=>`${a.pathname}${a.search}${a.hash}`;return{linkComponent:r,getCurrentPath:s,push:e=>{i(e.path)},replace:e=>{i(e.path,{replace:!0})},resolvePath:(t,r)=>(0,e.localizedPath)(t,r,o,n),getRoute:()=>({fullPath:s(),query:(0,e.routeQuery)(a.search)})}}exports.createSolidRouterAdapter=i;
2
+ //# sourceMappingURL=router.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.cjs","names":["localizedPath","routeQuery","Locale","A","Location","useNavigate","ComponentProps","JSX","I18nRoutingStrategy","NavigateFunction","ReturnType","RouterLink","props","href","key","Element","_$createComponent","createSolidRouterAdapter","locales","defaultLocale","navigate","location","codes","map","locale","code","fullPath","pathname","search","hash","linkComponent","getCurrentPath","push","target","path","replace","resolvePath","to","getRoute","query","_$createComponent","A","localizedPath","routeQuery","_i18n_micro_core","solid_js_web","_solidjs_router","RouterLink","props","createSolidRouterAdapter","codes","locales","locale","fullPath","location","navigate","target","to","defaultLocale"],"sources":["../src/router/adapter.tsx"],"sourcesContent":["import { localizedPath, routeQuery } from '@i18n-micro/core'\nimport type { Locale } from '@i18n-micro/types'\nimport { A, type Location, type useNavigate } from '@solidjs/router'\nimport type { ComponentProps, JSX } from 'solid-js'\nimport type { I18nRoutingStrategy } from './types'\n\ntype NavigateFunction = ReturnType<typeof useNavigate>\n\nconst RouterLink = (props: { href: string; [key: string]: unknown }): JSX.Element => <A {...(props as ComponentProps<typeof A>)} />\n\n/**\n * Factory for Solid Router adapter\n *\n * `location` is the router's reactive object, so reading the path inside a memo or JSX follows\n * navigation without a signal of its own.\n *\n * @example\n * ```tsx\n * const RouterRoot: Component = () => {\n * const navigate = useNavigate()\n * const location = useLocation()\n * const routingStrategy = createSolidRouterAdapter(locales, defaultLocale, navigate, location)\n * // ...\n * }\n * ```\n *\n * @param locales - Array of locale configurations\n * @param defaultLocale - Default locale code\n * @param navigate - Navigation function from @solidjs/router's useNavigate hook\n * @param location - Location object from @solidjs/router's useLocation hook\n * @returns I18nRoutingStrategy\n */\nexport function createSolidRouterAdapter(\n locales: Locale[],\n defaultLocale: string,\n navigate: NavigateFunction,\n location: Location,\n): I18nRoutingStrategy {\n const codes = locales.map((locale) => locale.code)\n const fullPath = () => `${location.pathname}${location.search}${location.hash}`\n\n return {\n linkComponent: RouterLink,\n getCurrentPath: fullPath,\n push: (target) => {\n navigate(target.path)\n },\n replace: (target) => {\n navigate(target.path, { replace: true })\n },\n resolvePath: (to, locale) => localizedPath(to, locale, codes, defaultLocale),\n getRoute: () => ({ fullPath: fullPath(), query: routeQuery(location.search) }),\n }\n}\n"],"mappings":"A,4JAQA,IAAMW,EAAcC,IAAAA,EAA6DI,EAAAA,gBAAAA,CAAKb,EAAAA,EAAOS,CAAiC,EAwB9H,SAAgBK,EACdC,EACAC,EACAC,EACAC,EACqB,CACrB,IAAMC,EAAQJ,EAAQK,IAAKC,GAAWA,EAAOC,IAAI,EAC3CC,MAAiB,GAAGL,EAASM,WAAWN,EAASO,SAASP,EAASQ,OAEzE,MAAO,CACLC,cAAenB,EACfoB,eAAgBL,EAChBM,KAAOC,GAAW,CAChBb,EAASa,EAAOC,IAAI,CACtB,EACAC,QAAUF,GAAW,CACnBb,EAASa,EAAOC,KAAM,CAAEC,QAAS,EAAK,CAAC,CACzC,EACAC,aAAcC,EAAIb,KAAAA,EAAWxB,EAAAA,cAAAA,CAAcqC,EAAIb,EAAQF,EAAOH,CAAa,EAC3EmB,cAAiB,CAAEZ,SAAUA,EAAS,EAAGa,OAAAA,EAAOtC,EAAAA,WAAAA,CAAWoB,EAASO,MAAM,CAAE,EAC9E,CACF,C"}
@@ -0,0 +1,84 @@
1
+ import { Component } from 'solid-js';
2
+ import { JSX } from 'solid-js';
3
+ import { Locale } from '@i18n-micro/types';
4
+ import { Location as Location_2 } from '@solidjs/router';
5
+ import { useNavigate } from '@solidjs/router';
6
+
7
+ /**
8
+ * Factory for Solid Router adapter
9
+ *
10
+ * `location` is the router's reactive object, so reading the path inside a memo or JSX follows
11
+ * navigation without a signal of its own.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const RouterRoot: Component = () => {
16
+ * const navigate = useNavigate()
17
+ * const location = useLocation()
18
+ * const routingStrategy = createSolidRouterAdapter(locales, defaultLocale, navigate, location)
19
+ * // ...
20
+ * }
21
+ * ```
22
+ *
23
+ * @param locales - Array of locale configurations
24
+ * @param defaultLocale - Default locale code
25
+ * @param navigate - Navigation function from @solidjs/router's useNavigate hook
26
+ * @param location - Location object from @solidjs/router's useLocation hook
27
+ * @returns I18nRoutingStrategy
28
+ */
29
+ export declare function createSolidRouterAdapter(locales: Locale[], defaultLocale: string, navigate: NavigateFunction, location: Location_2): I18nRoutingStrategy;
30
+
31
+ /**
32
+ * Routing strategy interface for i18n
33
+ * Implement this interface to integrate with any router library
34
+ * Matches Vue package interface for consistency
35
+ */
36
+ export declare interface I18nRoutingStrategy {
37
+ /**
38
+ * Returns the current path with its query and hash, so a locale switch keeps them. Links compare
39
+ * it by page. Read a signal or a reactive location here and links and the switcher follow it.
40
+ */
41
+ getCurrentPath: () => string;
42
+ /**
43
+ * Component to use for rendering links (e.g., RouterLink)
44
+ */
45
+ linkComponent?: string | Component<{
46
+ href: string;
47
+ children?: JSX.Element;
48
+ style?: JSX.CSSProperties | string;
49
+ class?: string;
50
+ [key: string]: unknown;
51
+ }>;
52
+ /**
53
+ * Function to navigate to another route/locale
54
+ */
55
+ push: (target: {
56
+ path: string;
57
+ }) => void;
58
+ /**
59
+ * Function to replace current route
60
+ */
61
+ replace: (target: {
62
+ path: string;
63
+ }) => void;
64
+ /**
65
+ * Generate path for specific locale
66
+ */
67
+ resolvePath?: (to: RouteTarget, locale: string) => RouteTarget;
68
+ /**
69
+ * (Optional) Get current route object for SEO/Meta tags
70
+ */
71
+ getRoute?: () => {
72
+ fullPath: string;
73
+ query: Record<string, unknown>;
74
+ };
75
+ }
76
+
77
+ declare type NavigateFunction = ReturnType<typeof useNavigate>;
78
+
79
+ /** Where a link or a switch goes. */
80
+ declare type RouteTarget = string | {
81
+ path?: string;
82
+ };
83
+
84
+ export { }
@@ -0,0 +1,84 @@
1
+ import { Component } from 'solid-js';
2
+ import { JSX } from 'solid-js';
3
+ import { Locale } from '@i18n-micro/types';
4
+ import { Location as Location_2 } from '@solidjs/router';
5
+ import { useNavigate } from '@solidjs/router';
6
+
7
+ /**
8
+ * Factory for Solid Router adapter
9
+ *
10
+ * `location` is the router's reactive object, so reading the path inside a memo or JSX follows
11
+ * navigation without a signal of its own.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const RouterRoot: Component = () => {
16
+ * const navigate = useNavigate()
17
+ * const location = useLocation()
18
+ * const routingStrategy = createSolidRouterAdapter(locales, defaultLocale, navigate, location)
19
+ * // ...
20
+ * }
21
+ * ```
22
+ *
23
+ * @param locales - Array of locale configurations
24
+ * @param defaultLocale - Default locale code
25
+ * @param navigate - Navigation function from @solidjs/router's useNavigate hook
26
+ * @param location - Location object from @solidjs/router's useLocation hook
27
+ * @returns I18nRoutingStrategy
28
+ */
29
+ export declare function createSolidRouterAdapter(locales: Locale[], defaultLocale: string, navigate: NavigateFunction, location: Location_2): I18nRoutingStrategy;
30
+
31
+ /**
32
+ * Routing strategy interface for i18n
33
+ * Implement this interface to integrate with any router library
34
+ * Matches Vue package interface for consistency
35
+ */
36
+ export declare interface I18nRoutingStrategy {
37
+ /**
38
+ * Returns the current path with its query and hash, so a locale switch keeps them. Links compare
39
+ * it by page. Read a signal or a reactive location here and links and the switcher follow it.
40
+ */
41
+ getCurrentPath: () => string;
42
+ /**
43
+ * Component to use for rendering links (e.g., RouterLink)
44
+ */
45
+ linkComponent?: string | Component<{
46
+ href: string;
47
+ children?: JSX.Element;
48
+ style?: JSX.CSSProperties | string;
49
+ class?: string;
50
+ [key: string]: unknown;
51
+ }>;
52
+ /**
53
+ * Function to navigate to another route/locale
54
+ */
55
+ push: (target: {
56
+ path: string;
57
+ }) => void;
58
+ /**
59
+ * Function to replace current route
60
+ */
61
+ replace: (target: {
62
+ path: string;
63
+ }) => void;
64
+ /**
65
+ * Generate path for specific locale
66
+ */
67
+ resolvePath?: (to: RouteTarget, locale: string) => RouteTarget;
68
+ /**
69
+ * (Optional) Get current route object for SEO/Meta tags
70
+ */
71
+ getRoute?: () => {
72
+ fullPath: string;
73
+ query: Record<string, unknown>;
74
+ };
75
+ }
76
+
77
+ declare type NavigateFunction = ReturnType<typeof useNavigate>;
78
+
79
+ /** Where a link or a switch goes. */
80
+ declare type RouteTarget = string | {
81
+ path?: string;
82
+ };
83
+
84
+ export { }
@@ -0,0 +1,26 @@
1
+ import { localizedPath as e, routeQuery as t } from "@i18n-micro/core";
2
+ import { createComponent as n } from "solid-js/web";
3
+ import { A as r } from "@solidjs/router";
4
+ // src/router/adapter.tsx
5
+ var i = (e) => n(r, e);
6
+ function a(n, r, a, o) {
7
+ let s = n.map((e) => e.code), c = () => `${o.pathname}${o.search}${o.hash}`;
8
+ return {
9
+ linkComponent: i,
10
+ getCurrentPath: c,
11
+ push: (e) => {
12
+ a(e.path);
13
+ },
14
+ replace: (e) => {
15
+ a(e.path, { replace: !0 });
16
+ },
17
+ resolvePath: (t, n) => e(t, n, s, r),
18
+ getRoute: () => ({
19
+ fullPath: c(),
20
+ query: t(o.search)
21
+ })
22
+ };
23
+ }
24
+ export { a as createSolidRouterAdapter };
25
+
26
+ //# sourceMappingURL=router.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.mjs","names":["localizedPath","routeQuery","Locale","A","Location","useNavigate","ComponentProps","JSX","I18nRoutingStrategy","NavigateFunction","ReturnType","RouterLink","props","href","key","Element","_$createComponent","createSolidRouterAdapter","locales","defaultLocale","navigate","location","codes","map","locale","code","fullPath","pathname","search","hash","linkComponent","getCurrentPath","push","target","path","replace","resolvePath","to","getRoute","query","_$createComponent","RouterLink","createComponent","A","props","createSolidRouterAdapter","codes","locales","locale","fullPath","location","target","localizedPath","to","defaultLocale","routeQuery"],"sources":["../src/router/adapter.tsx"],"sourcesContent":["import { localizedPath, routeQuery } from '@i18n-micro/core'\nimport type { Locale } from '@i18n-micro/types'\nimport { A, type Location, type useNavigate } from '@solidjs/router'\nimport type { ComponentProps, JSX } from 'solid-js'\nimport type { I18nRoutingStrategy } from './types'\n\ntype NavigateFunction = ReturnType<typeof useNavigate>\n\nconst RouterLink = (props: { href: string; [key: string]: unknown }): JSX.Element => <A {...(props as ComponentProps<typeof A>)} />\n\n/**\n * Factory for Solid Router adapter\n *\n * `location` is the router's reactive object, so reading the path inside a memo or JSX follows\n * navigation without a signal of its own.\n *\n * @example\n * ```tsx\n * const RouterRoot: Component = () => {\n * const navigate = useNavigate()\n * const location = useLocation()\n * const routingStrategy = createSolidRouterAdapter(locales, defaultLocale, navigate, location)\n * // ...\n * }\n * ```\n *\n * @param locales - Array of locale configurations\n * @param defaultLocale - Default locale code\n * @param navigate - Navigation function from @solidjs/router's useNavigate hook\n * @param location - Location object from @solidjs/router's useLocation hook\n * @returns I18nRoutingStrategy\n */\nexport function createSolidRouterAdapter(\n locales: Locale[],\n defaultLocale: string,\n navigate: NavigateFunction,\n location: Location,\n): I18nRoutingStrategy {\n const codes = locales.map((locale) => locale.code)\n const fullPath = () => `${location.pathname}${location.search}${location.hash}`\n\n return {\n linkComponent: RouterLink,\n getCurrentPath: fullPath,\n push: (target) => {\n navigate(target.path)\n },\n replace: (target) => {\n navigate(target.path, { replace: true })\n },\n resolvePath: (to, locale) => localizedPath(to, locale, codes, defaultLocale),\n getRoute: () => ({ fullPath: fullPath(), query: routeQuery(location.search) }),\n }\n}\n"],"mappings":";;;;AAQA,IAAMW,KAAcC,MAA6DI,EAAKb,GAAOS,CAAiC;AAwB9H,SAAgBK,EACdC,GACAC,GACAC,GACAC,GACqB;CACrB,IAAMC,IAAQJ,EAAQK,KAAKC,MAAWA,EAAOC,IAAI,GAC3CC,UAAiB,GAAGL,EAASM,WAAWN,EAASO,SAASP,EAASQ;CAEzE,OAAO;EACLC,eAAenB;EACfoB,gBAAgBL;EAChBM,OAAOC,MAAW;GAChBb,EAASa,EAAOC,IAAI;EACtB;EACAC,UAAUF,MAAW;GACnBb,EAASa,EAAOC,MAAM,EAAEC,SAAS,GAAK,CAAC;EACzC;EACAC,cAAcC,GAAIb,MAAWxB,EAAcqC,GAAIb,GAAQF,GAAOH,CAAa;EAC3EmB,iBAAiB;GAAEZ,UAAUA,EAAS;GAAGa,OAAOtC,EAAWoB,EAASO,MAAM;EAAE;CAC9E;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i18n-micro/solid",
3
- "version": "1.2.16",
3
+ "version": "2.0.0",
4
4
  "description": "SolidJS bindings for i18n-micro — primitives, context, and UI components.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -14,6 +14,11 @@
14
14
  "url": "https://github.com/s00d/nuxt-i18n-micro/issues"
15
15
  },
16
16
  "license": "MIT",
17
+ "author": {
18
+ "name": "s00d",
19
+ "email": "Virus191288@gmail.com",
20
+ "url": "https://s00d.github.io/"
21
+ },
17
22
  "repository": {
18
23
  "type": "git",
19
24
  "url": "git+https://github.com/s00d/nuxt-i18n-micro.git",
@@ -21,6 +26,7 @@
21
26
  },
22
27
  "files": [
23
28
  "dist",
29
+ "src",
24
30
  "README.md",
25
31
  "LICENSE"
26
32
  ],
@@ -30,6 +36,7 @@
30
36
  "types": "./dist/index.d.ts",
31
37
  "exports": {
32
38
  ".": {
39
+ "solid": "./src/index.ts",
33
40
  "import": {
34
41
  "types": "./dist/index.d.ts",
35
42
  "default": "./dist/index.mjs"
@@ -40,44 +47,55 @@
40
47
  },
41
48
  "default": "./dist/index.mjs"
42
49
  },
50
+ "./router": {
51
+ "solid": "./src/router/index.ts",
52
+ "import": {
53
+ "types": "./dist/router.d.ts",
54
+ "default": "./dist/router.mjs"
55
+ },
56
+ "require": {
57
+ "types": "./dist/router.d.cts",
58
+ "default": "./dist/router.cjs"
59
+ },
60
+ "default": "./dist/router.mjs"
61
+ },
43
62
  "./package.json": "./package.json"
44
63
  },
45
64
  "publishConfig": {
46
65
  "access": "public"
47
66
  },
48
67
  "dependencies": {
49
- "@i18n-micro/core": "^1.3.22",
50
- "@i18n-micro/types": "^1.2.18"
68
+ "@i18n-micro/core": "^2.0.0",
69
+ "@i18n-micro/types": "^2.0.0",
70
+ "@i18n-micro/runtime": "^2.0.0"
51
71
  },
52
72
  "devDependencies": {
53
- "jsdom": "^30.1.1",
54
- "publint": "^0.3.24",
55
- "solid-js": "^1.9.15",
56
- "vite": "^8.3.1",
57
- "vite-plugin-dts": "^5.1.1",
58
- "vite-plugin-solid": "^2.11.14",
59
- "vitest": "^5.0.2"
73
+ "jsdom": "^30.1.3",
74
+ "publint": "^0.3.25",
75
+ "solid-js": "^1.9.18",
76
+ "vite": "^8.3.5",
77
+ "vite-plugin-dts": "^5.1.2",
78
+ "vite-plugin-solid": "^2.11.15",
79
+ "vitest": "^5.1.0"
60
80
  },
61
81
  "peerDependencies": {
62
82
  "@solidjs/router": "^0.15.4 || ^1.0.0",
63
- "solid-js": "^1.9.15"
83
+ "solid-js": "^1.8.0"
64
84
  },
65
85
  "peerDependenciesMeta": {
66
- "solid-js": {
67
- "optional": false
68
- },
69
86
  "@solidjs/router": {
70
87
  "optional": true
71
88
  }
72
89
  },
73
90
  "engines": {
74
- "node": ">=18"
91
+ "node": ">=20"
75
92
  },
76
93
  "scripts": {
77
94
  "build": "vite build",
78
95
  "check:package": "publint",
79
96
  "dev": "cd playground && vite",
80
97
  "test": "vitest run",
98
+ "test:dist": "vitest run --config vitest.dist.config.ts",
81
99
  "typecheck": "tsc --noEmit"
82
100
  }
83
101
  }
@@ -0,0 +1,27 @@
1
+ import type { TranslationKey } from '@i18n-micro/types'
2
+ import { type Component, createMemo, type JSX, splitProps } from 'solid-js'
3
+ import { useI18nContext } from '../injection'
4
+
5
+ export interface I18nGroupProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'> {
6
+ prefix: string
7
+ groupClass?: string
8
+ children?:
9
+ | JSX.Element
10
+ | ((props: { prefix: string; t: (key: string, params?: Record<string, string | number | boolean>) => string }) => JSX.Element)
11
+ }
12
+
13
+ export const I18nGroup: Component<I18nGroupProps> = (props): JSX.Element => {
14
+ const i18n = useI18nContext()
15
+ const [local, others] = splitProps(props, ['prefix', 'groupClass', 'class', 'children'])
16
+
17
+ const translate = (key: string, params?: Record<string, string | number | boolean>): string =>
18
+ i18n.ts(`${local.prefix}.${key}` as TranslationKey, params)
19
+
20
+ const className = createMemo(() => ['i18n-group', local.groupClass, local.class].filter(Boolean).join(' '))
21
+
22
+ return (
23
+ <div class={className()} {...others}>
24
+ {typeof local.children === 'function' ? local.children({ prefix: local.prefix, t: translate }) : local.children}
25
+ </div>
26
+ )
27
+ }