@zag-js/i18n-utils
Advanced tools
Comparing version 0.21.0 to 0.22.0
@@ -14,11 +14,11 @@ type Direction = "rtl" | "ltr"; | ||
declare function isRTL(locale: string): boolean; | ||
declare function getLocaleDir(locale: string): "rtl" | "ltr"; | ||
interface LocaleOptions { | ||
locale?: string; | ||
getRootNode?: () => ShadowRoot | Document; | ||
getRootNode?: () => ShadowRoot | Document | Node; | ||
onLocaleChange?: (locale: Locale) => void; | ||
immediate?: boolean; | ||
} | ||
declare function trackLocale(options?: LocaleOptions): () => void; | ||
export { Locale, LocaleOptions, getDefaultLocale, isRTL, trackLocale }; | ||
export { Locale, LocaleOptions, getDefaultLocale, getLocaleDir, isRTL, trackLocale }; |
@@ -24,2 +24,3 @@ "use strict"; | ||
getDefaultLocale: () => getDefaultLocale, | ||
getLocaleDir: () => getLocaleDir, | ||
isRTL: () => isRTL, | ||
@@ -95,11 +96,4 @@ trackLocale: () => trackLocale | ||
function trackLocale(options = {}) { | ||
const { locale: localeStr = "en-US", getRootNode, onLocaleChange, immediate } = options; | ||
const fallbackLocale = { | ||
locale: localeStr, | ||
dir: getLocaleDir(localeStr) | ||
}; | ||
if (immediate) { | ||
const locale = !(0, import_dom_query.isDom)() ? fallbackLocale : getDefaultLocale(); | ||
onLocaleChange?.(locale); | ||
} | ||
const { getRootNode, onLocaleChange } = options; | ||
onLocaleChange?.(getDefaultLocale()); | ||
const handleLocaleChange = () => { | ||
@@ -117,2 +111,3 @@ onLocaleChange?.(getDefaultLocale()); | ||
getDefaultLocale, | ||
getLocaleDir, | ||
isRTL, | ||
@@ -119,0 +114,0 @@ trackLocale |
{ | ||
"name": "@zag-js/i18n-utils", | ||
"version": "0.21.0", | ||
"version": "0.22.0", | ||
"description": "Interationalization utilities for Zag.js", | ||
@@ -27,3 +27,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@zag-js/dom-query": "0.21.0" | ||
"@zag-js/dom-query": "0.22.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15585
208
+ Added@zag-js/dom-query@0.22.0(transitive)
- Removed@zag-js/dom-query@0.21.0(transitive)
Updated@zag-js/dom-query@0.22.0