react-intlayer 7.2.1-canary.0 → 7.2.2
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.
- package/dist/cjs/UI/ContentSelector.cjs +0 -1
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/_virtual/rolldown_runtime.cjs +10 -6
- package/dist/cjs/client/IntlayerProvider.cjs +0 -1
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/format/useCompact.cjs +0 -1
- package/dist/cjs/client/format/useCompact.cjs.map +1 -1
- package/dist/cjs/client/format/useCurrency.cjs +0 -1
- package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/client/format/useDate.cjs +0 -1
- package/dist/cjs/client/format/useDate.cjs.map +1 -1
- package/dist/cjs/client/format/useList.cjs +0 -1
- package/dist/cjs/client/format/useList.cjs.map +1 -1
- package/dist/cjs/client/format/useNumber.cjs +0 -1
- package/dist/cjs/client/format/useNumber.cjs.map +1 -1
- package/dist/cjs/client/format/usePercentage.cjs +0 -1
- package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/client/format/useRelativeTime.cjs +0 -1
- package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/client/format/useUnit.cjs +0 -1
- package/dist/cjs/client/format/useUnit.cjs.map +1 -1
- package/dist/cjs/client/t.cjs +0 -1
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +0 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +0 -1
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +0 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useI18n.cjs +0 -1
- package/dist/cjs/client/useI18n.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +0 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +0 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleBase.cjs +0 -1
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +0 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +5 -4
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +0 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs +0 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +0 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.mjs +0 -1
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +0 -1
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/format/useCompact.mjs +0 -1
- package/dist/esm/client/format/useCompact.mjs.map +1 -1
- package/dist/esm/client/format/useCurrency.mjs +0 -1
- package/dist/esm/client/format/useCurrency.mjs.map +1 -1
- package/dist/esm/client/format/useDate.mjs +0 -1
- package/dist/esm/client/format/useDate.mjs.map +1 -1
- package/dist/esm/client/format/useList.mjs +0 -1
- package/dist/esm/client/format/useList.mjs.map +1 -1
- package/dist/esm/client/format/useNumber.mjs +0 -1
- package/dist/esm/client/format/useNumber.mjs.map +1 -1
- package/dist/esm/client/format/usePercentage.mjs +0 -1
- package/dist/esm/client/format/usePercentage.mjs.map +1 -1
- package/dist/esm/client/format/useRelativeTime.mjs +0 -1
- package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/client/format/useUnit.mjs +0 -1
- package/dist/esm/client/format/useUnit.mjs.map +1 -1
- package/dist/esm/client/t.mjs +0 -1
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +0 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +0 -1
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +0 -1
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useI18n.mjs +0 -1
- package/dist/esm/client/useI18n.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +0 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +0 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.mjs +0 -1
- package/dist/esm/client/useLocaleBase.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +0 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +5 -4
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +0 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs +0 -1
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +0 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/types/client/format/useCompact.d.ts +2 -2
- package/dist/types/client/format/useCompact.d.ts.map +1 -1
- package/dist/types/client/format/useCurrency.d.ts +2 -2
- package/dist/types/client/format/useCurrency.d.ts.map +1 -1
- package/dist/types/client/format/useNumber.d.ts +2 -2
- package/dist/types/client/format/useNumber.d.ts.map +1 -1
- package/dist/types/client/format/usePercentage.d.ts +2 -2
- package/dist/types/client/format/useRelativeTime.d.ts +2 -2
- package/dist/types/client/format/useUnit.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/reactElement/renderReactElement.d.ts +2 -2
- package/dist/types/server/IntlayerServerProvider.d.ts +2 -2
- package/dist/types/server/useDictionary.d.ts +2 -2
- package/dist/types/server/useDictionaryAsync.d.ts +2 -2
- package/dist/types/server/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/server/useIntlayer.d.ts +3 -3
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.mjs","names":["ContentSelector: FC<ContentSelectorProps>","handleOnClick: MouseEventHandler<HTMLDivElement>"],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContentSelector.mjs","names":["ContentSelector: FC<ContentSelectorProps>","handleOnClick: MouseEventHandler<HTMLDivElement>"],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onPress();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n onUnhover?.();\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;AAYA,MAAM,gCAAgC;AAWtC,MAAaA,mBAA6C,EACxD,UACA,SACA,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,SAAS,OAAuB,KAAK;CAC3C,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,gBAAgB;CACzE,MAAM,gBAAgB,OAA6C,KAAK;CACxE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;AAC9B,sBAAoB,KAAK;AACzB,WAAS;;CAGX,MAAM,wBAAwB;AAC5B,gBAAc,UAAU,iBAAiB;AACvC,sBAAmB;KAClB,cAAc;;CAGnB,MAAM,wBAAwB;AAC5B,MAAI,cAAc,SAAS;AACzB,gBAAa,cAAc,QAAQ;AACnC,iBAAc,UAAU;;;CAI5B,MAAM,wBAAwB;AAC5B,mBAAiB;AACjB,mBAAiB;;CAGnB,MAAM,yBAAyB;AAC7B,eAAa,KAAK;AAClB,aAAW;;CAGb,MAAM,sBAAsB;AAC1B,eAAa;AACb,eAAa,MAAM;AACnB,mBAAiB;;CAInB,MAAM,qBAAqB,aACxB,UAAsB;AACrB,MAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,OAAe,EAAE;AACpE,uBAAoB,MAAM;AAC1B,iBAAc;;IAGlB,CAAC,WAAW,CACb;AAED,iBAAgB;AAEd,WAAS,iBAAiB,aAAa,mBAAmB;AAE1D,eAAa;AAEX,YAAS,oBAAoB,aAAa,mBAAmB;;IAG9D,CAAC,mBAAmB,CAAC;CAExB,MAAMC,iBAAoD,MAAM;AAC9D,MAAI,kBAAkB;AACpB,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;;CAIvB,MAAM,qBAAqB;AAEzB,sBAAoB,MAAM;;AAG5B,QACE,oBAAC;EACC,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;GACb;EACD,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;GACI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.mjs","names":["IntlayerProviderContent: FC<IntlayerProviderProps>","IntlayerProvider: FC<IntlayerProviderProps>"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core';\nimport { MessageKey, useCrossFrameState } from '@intlayer/editor-react';\nimport type { LocalesValues } from '@intlayer/types';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n disableEditor: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren<{\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\n );\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.mjs","names":["IntlayerProviderContent: FC<IntlayerProviderProps>","IntlayerProvider: FC<IntlayerProviderProps>"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { localeResolver } from '@intlayer/core';\nimport { MessageKey, useCrossFrameState } from '@intlayer/editor-react';\nimport type { LocalesValues } from '@intlayer/types';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useContext,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? configuration?.internationalization?.defaultLocale,\n setLocale: () => null,\n isCookieEnabled: true,\n disableEditor: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren<{\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { internationalization } = configuration ?? {};\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n MessageKey.INTLAYER_CURRENT_LOCALE,\n defaultLocale\n );\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n disableEditor,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,eAAe,sBAAsB;CAChE,iBAAiB;CACjB,iBAAiB;CACjB,eAAe;CAChB,CAAC;;;;AAKF,MAAa,2BAA2B,WAAW,sBAAsB;;;;AAazE,MAAaA,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,yBAAyB,iBAAiB,EAAE;CACpD,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnD,wBAAwB,EAAE;CAE5B,MAAM,gBACJ,cAAc,mBAAmB,qBAAqB;CAExD,MAAM,CAAC,eAAe,oBAAoB,mBACxC,WAAW,yBACX,cACD;CAED,MAAM,iBAAiB,cAA6B;AAClD,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AAEvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,mBAAiB,UAAU;AAC3B,uBAAmB,WAAW,gBAAgB;;CAGhD,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iBAAiB,eAAe,cAAc,cAAc;AAElE,QACE,oBAAC,sBAAsB;EACrB,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;GAC8B;;AAIrC,MAAaC,oBAA+C,UAC1D,oBAAC,oCACC,oBAAC,2BAAwB,GAAI,QAAS,GACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":["'use client';\n\nimport { compact } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":["'use client';\n\nimport { currency } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../../src/client/format/useDate.ts"],"sourcesContent":["'use client';\n\nimport { date } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,SAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../../src/client/format/useList.ts"],"sourcesContent":["'use client';\n\nimport { list } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"sourcesContent":["'use client';\n\nimport { number } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,WAAW,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,aAAa,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB;AAEpD,QAAO,aACJ,GAAG,SACF,MAAM,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
package/dist/esm/client/t.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"t.mjs","names":[],"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport { getTranslation } from '@intlayer/core';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"t.mjs","names":[],"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport { getTranslation } from '@intlayer/core';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;AAGnE,QAAO,eAAwB,kBAFV,UAAU,cAE+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary, currentLocale, locale]);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;AAEnE,QAAO,cAAc;AAGnB,SAAO,cAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC;EAAY;EAAe;EAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,qBAAqB,OAIhC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;CAEnE,MAAM,eAAe,cAEjB,UACA,iBACA,eAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAUD,QAAO,cARY,MAAM,QACvB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEsC,aAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;CACnE,MAAM,eAAe,cAEjB,UACA,iBACA,eAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.mjs","names":["dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>>","current: any"],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer, type ValidDotPathsFor } from '@intlayer/core';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * // For attributes like `aria-label`, use `.value` to get the plain string\n * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'\n * ```\n */\nexport const useI18n = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n namespace: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n // Get the dictionary content for the namespace\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>> =\n useMemo(\n () => getIntlayer<T, L>(namespace, localeTarget as L),\n [namespace, localeTarget]\n );\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useI18n.mjs","names":["dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>>","current: any"],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer, type ValidDotPathsFor } from '@intlayer/core';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * // For attributes like `aria-label`, use `.value` to get the plain string\n * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'\n * ```\n */\nexport const useI18n = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n namespace: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n // Get the dictionary content for the namespace\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>> =\n useMemo(\n () => getIntlayer<T, L>(namespace, localeTarget as L),\n [namespace, localeTarget]\n );\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,WAIX,WACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;CACnE,MAAM,eAAe,cACb,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;CAID,MAAMA,oBACJ,cACQ,YAAkB,WAAW,aAAkB,EACrD,CAAC,WAAW,aAAa,CAC1B;CAIH,MAAM,KACJ,SAEsE;AACtE,MAAI,CAAC,KAEH,QAAO;EAGT,MAAM,YAAa,KAAgB,MAAM,IAAI;EAC7C,IAAIC,UAAe;AAEnB,OAAK,MAAM,OAAO,WAAW;AAC3B,aAAU,UAAU;AACpB,OAAI,YAAY,OAEd,QAAO;;AAIX,SAAO;;AAGT,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n *\n * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n *\n * When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,eAIX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB;AAEnE,QAAO,cAAc;AAGnB,SAAO,YAAkB,KAFJ,UAAW,cAEW;IAC1C;EAAC;EAAK;EAAe;EAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.mjs","names":["locale"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext);\n\n const setLocale = useCallback(\n (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n onLocaleChange?.(locale);\n },\n [availableLocales, onLocaleChange, setLocaleState]\n );\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.mjs","names":["locale"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext);\n\n const setLocale = useCallback(\n (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n onLocaleChange?.(locale);\n },\n [availableLocales, onLocaleChange, setLocaleState]\n );\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;AAuBA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,eAAe,wBAAwB,EAAE;CAE3C,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB;AAmBrC,QAAO;EACL;EACA;EACA;EACA,WArBgB,aACf,aAA0B;AACzB,OAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAASA,SAAO,EAAE;AACnD,YAAQ,MAAM,UAAUA,SAAO,mBAAmB;AAClD;;AAGF,kBAAeA,SAAO;AACtB,sBACEA,UACA,mBAAmB,0BAA0B,KAC9C;AACD,oBAAiBA,SAAO;KAE1B;GAAC;GAAkB;GAAgB;GAAe,CACnD;EAOA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n configuration.internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n configuration.internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;AAMA,MAAM,EAAE,eAAe,SAAS,qBAC9B,cAAc;;;;AAKhB,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,cAAc,WAAW,sBAAsB;AAE/D,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.mjs","names":["ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps>","ContentSelectorRenderer: FC<ContentSelectorWrapperProps>"],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type NodeProps } from '@intlayer/core';\nimport {\n MessageKey,\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { NodeType } from '@intlayer/types';\nimport { type FC, type HTMLAttributes, useCallback, useMemo } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { postMessage, senderId } = useCommunicator();\n\n // Filter out translation nodes for more flexibility with the editor that can have different format\n const filteredKeyPath = useMemo(\n () => keyPath.filter((key) => key.type !== NodeType.Translation),\n [keyPath]\n );\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath: filteredKeyPath,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleHover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: {\n dictionaryKey,\n keyPath: filteredKeyPath,\n },\n senderId,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleUnhover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n }),\n [senderId]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false,\n [focusedContent, filteredKeyPath, dictionaryKey]\n );\n\n return (\n <ContentSelector\n onPress={handleSelect}\n onHover={handleHover}\n onUnhover={handleUnhover}\n isSelecting={isSelected}\n >\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContentSelectorWrapper.mjs","names":["ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps>","ContentSelectorRenderer: FC<ContentSelectorWrapperProps>"],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type NodeProps } from '@intlayer/core';\nimport {\n MessageKey,\n useCommunicator,\n useEditorEnabled,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { NodeType } from '@intlayer/types';\nimport { type FC, type HTMLAttributes, useCallback, useMemo } from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { postMessage, senderId } = useCommunicator();\n\n // Filter out translation nodes for more flexibility with the editor that can have different format\n const filteredKeyPath = useMemo(\n () => keyPath.filter((key) => key.type !== NodeType.Translation),\n [keyPath]\n );\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath: filteredKeyPath,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleHover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: {\n dictionaryKey,\n keyPath: filteredKeyPath,\n },\n senderId,\n }),\n [dictionaryKey, filteredKeyPath]\n );\n\n const handleUnhover = useCallback(\n () =>\n postMessage({\n type: `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n data: null,\n senderId,\n }),\n [senderId]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false,\n [focusedContent, filteredKeyPath, dictionaryKey]\n );\n\n return (\n <ContentSelector\n onPress={handleSelect}\n onHover={handleHover}\n onUnhover={handleUnhover}\n isSelecting={isSelected}\n >\n {children}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorRenderer: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":";;;;;;;;;;;AAiBA,MAAMA,iCAAkE,EACtE,UACA,eACA,cACI;CACJ,MAAM,EAAE,gBAAgB,sBAAsB,oBAAoB;CAClE,MAAM,EAAE,aAAa,aAAa,iBAAiB;CAGnD,MAAM,kBAAkB,cAChB,QAAQ,QAAQ,QAAQ,IAAI,SAAS,SAAS,YAAY,EAChE,CAAC,QAAQ,CACV;AA2CD,QACE,oBAAC;EACC,SA3CiB,kBAEjB,kBAAkB;GAChB;GACA,SAAS;GACV,CAAC,EACJ,CAAC,eAAe,gBAAgB,CACjC;EAqCG,SAnCgB,kBAEhB,YAAY;GACV,MAAM,GAAG,WAAW,iCAAiC;GACrD,MAAM;IACJ;IACA,SAAS;IACV;GACD;GACD,CAAC,EACJ,CAAC,eAAe,gBAAgB,CACjC;EAyBG,WAvBkB,kBAElB,YAAY;GACV,MAAM,GAAG,WAAW,iCAAiC;GACrD,MAAM;GACN;GACD,CAAC,EACJ,CAAC,SAAS,CACX;EAgBG,aAde,eAEd,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,EAAE,EAAE,gBAAgB,KAC/D,OACF;GAAC;GAAgB;GAAiB;GAAc,CACjD;EASI;GACe;;AAItB,MAAaC,2BAA4D,EACvE,UACA,GAAG,YACC;CACJ,MAAM,EAAE,YAAY,kBAAkB;CACtC,MAAM,EAAE,kBAAkB,oBAAoB;AAE9C,KAAI,WAAW,CAAC,cACd,QACE,oBAAC;EAA8B,GAAI;EAChC;GAC6B;AAIpC,QAAO"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import { useEffect } from "react";
|
|
5
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { EditorProvider, useCrossURLPathSetter, useDictionariesRecordActions, useEditorEnabled, useIframeClickInterceptor } from "@intlayer/editor-react";
|
|
7
6
|
import configuration from "@intlayer/config/built";
|
|
8
|
-
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
9
7
|
|
|
10
8
|
//#region src/editor/IntlayerEditorProvider.tsx
|
|
11
9
|
const IntlayerEditorHooksEnabled = () => {
|
|
@@ -22,8 +20,11 @@ const IntlayerEditorHooksEnabled = () => {
|
|
|
22
20
|
*/
|
|
23
21
|
const { setLocaleDictionaries } = useDictionariesRecordActions();
|
|
24
22
|
useEffect(() => {
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
import("@intlayer/unmerged-dictionaries-entry").then((mod) => {
|
|
24
|
+
const unmergedDictionaries = mod.getUnmergedDictionaries();
|
|
25
|
+
const dictionariesList = Object.fromEntries(Object.values(unmergedDictionaries).flat().map((dictionary) => [dictionary.localId, dictionary]));
|
|
26
|
+
setLocaleDictionaries?.(dictionariesList);
|
|
27
|
+
});
|
|
27
28
|
}, []);
|
|
28
29
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
29
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerEditorProvider.mjs","names":["IntlayerEditorHooksEnabled: FC","IntlayerEditorHook: FC","IntlayerEditorProvider: FC<PropsWithChildren>"],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useCrossURLPathSetter,\n useDictionariesRecordActions,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport
|
|
1
|
+
{"version":3,"file":"IntlayerEditorProvider.mjs","names":["IntlayerEditorHooksEnabled: FC","IntlayerEditorHook: FC","IntlayerEditorProvider: FC<PropsWithChildren>"],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useCrossURLPathSetter,\n useDictionariesRecordActions,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport type { FC, PropsWithChildren } from 'react';\nimport { useEffect } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n /**\n * Sent local dictionaries to editor\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n useEffect(() => {\n // Load dictionaries dynamically to do not impact the bundle, and send them to the editor\n import('@intlayer/unmerged-dictionaries-entry').then((mod) => {\n const unmergedDictionaries = mod.getUnmergedDictionaries();\n const dictionariesList = Object.fromEntries(\n Object.values(unmergedDictionaries)\n .flat()\n .map((dictionary) => [dictionary.localId, dictionary])\n );\n\n setLocaleDictionaries?.(dictionariesList);\n });\n }, []);\n\n return <></>;\n};\n\nconst { editor } = configuration ?? {};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n if (!editor) return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={\n [editor?.editorURL, editor?.cmsURL, editor?.applicationURL].filter(\n Boolean\n ) as string[]\n }\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";;;;;;;;AAaA,MAAMA,mCAAuC;;;;AAI3C,wBAAuB;;;;AAKvB,4BAA2B;;;;CAK3B,MAAM,EAAE,0BAA0B,8BAA8B;AAChE,iBAAgB;AAEd,SAAO,yCAAyC,MAAM,QAAQ;GAC5D,MAAM,uBAAuB,IAAI,yBAAyB;GAC1D,MAAM,mBAAmB,OAAO,YAC9B,OAAO,OAAO,qBAAqB,CAChC,MAAM,CACN,KAAK,eAAe,CAAC,WAAW,SAAS,WAAW,CAAC,CACzD;AAED,2BAAwB,iBAAiB;IACzC;IACD,EAAE,CAAC;AAEN,QAAO,iCAAK;;AAGd,MAAM,EAAE,WAAW,iBAAiB,EAAE;AAEtC,MAAMC,2BAA+B;CACnC,MAAM,EAAE,YAAY,kBAAkB;AAEtC,QAAO,UAAU,oBAAC,+BAA6B,GAAG,iCAAK;;AAGzD,MAAaC,0BAAiD,EAAE,eAAe;AAC7E,QACE,qBAAC;EACC,cAAc,SAAc;AAC1B,OAAI,OAAO,WAAW,YAAa;AACnC,OAAI,CAAC,OAAQ;AAGb,OAAI,EADe,OAAO,SAAS,OAAO,KACzB;AAEjB,OAAI,OAAO,eAAe,SAAS,EACjC,SAAQ,YACN,MAGA,OAAO,eACR;AAGH,OAAI,OAAO,UAAU,SAAS,EAC5B,QAAO,QAAQ,YACb,MAGA,OAAO,UACR;AAGH,OAAI,OAAO,OAAO,SAAS,EACzB,QAAO,QAAQ,YACb,MAGA,OAAO,OACR;;EAGL,gBACE;GAAC,QAAQ;GAAW,QAAQ;GAAQ,QAAQ;GAAe,CAAC,OAC1D,QACD;EAEH,MAAK;EACU;aAEf,oBAAC,uBAAqB,EACrB;GACc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditedContentRenderer.mjs","names":["EditedContentRenderer: FC<EditedContentRendererProps>"],"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { getContent } from '@intlayer/core';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { KeyPath, Locale } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { ContentSelectorRenderer } from './ContentSelectorWrapper';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n locale?: Locale;\n};\n\nexport const useEditedContentRenderer = ({\n dictionaryKey,\n keyPath,\n children,\n}: EditedContentRendererProps) => {\n const editedContentContext = useEditedContentActions();\n\n if (editedContentContext) {\n const editedValue = editedContentContext.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string;\n\n const value = editedValue ?? children;\n\n return value;\n }\n\n return children;\n};\n\nexport const EditedContentRenderer: FC<EditedContentRendererProps> = (\n props\n) => {\n const content = useEditedContentRenderer(props);\n\n if (typeof content === 'object') {\n const transformedEditedContent = getContent(content, props, props.locale);\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {props.children}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {transformedEditedContent}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {content}\n </ContentSelectorRenderer>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditedContentRenderer.mjs","names":["EditedContentRenderer: FC<EditedContentRendererProps>"],"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { getContent } from '@intlayer/core';\nimport { useEditedContentActions } from '@intlayer/editor-react';\nimport type { KeyPath, Locale } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { ContentSelectorRenderer } from './ContentSelectorWrapper';\n\ntype EditedContentRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n locale?: Locale;\n};\n\nexport const useEditedContentRenderer = ({\n dictionaryKey,\n keyPath,\n children,\n}: EditedContentRendererProps) => {\n const editedContentContext = useEditedContentActions();\n\n if (editedContentContext) {\n const editedValue = editedContentContext.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string;\n\n const value = editedValue ?? children;\n\n return value;\n }\n\n return children;\n};\n\nexport const EditedContentRenderer: FC<EditedContentRendererProps> = (\n props\n) => {\n const content = useEditedContentRenderer(props);\n\n if (typeof content === 'object') {\n const transformedEditedContent = getContent(content, props, props.locale);\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {props.children}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {transformedEditedContent}\n </ContentSelectorRenderer>\n );\n }\n\n return (\n <ContentSelectorRenderer {...props} key={props.children}>\n {content}\n </ContentSelectorRenderer>\n );\n};\n"],"mappings":";;;;;;;;AAeA,MAAa,4BAA4B,EACvC,eACA,SACA,eACgC;CAChC,MAAM,uBAAuB,yBAAyB;AAEtD,KAAI,qBAQF,QAPoB,qBAAqB,sBACvC,eACA,QACD,IAE4B;AAK/B,QAAO;;AAGT,MAAaA,yBACX,UACG;CACH,MAAM,UAAU,yBAAyB,MAAM;AAE/C,KAAI,OAAO,YAAY,UAAU;EAC/B,MAAM,2BAA2B,WAAW,SAAS,OAAO,MAAM,OAAO;AAEzE,MAAI,OAAO,6BAA6B,UAAU;AAChD,WAAQ,MACN,kDAAkD,OAAO,yBAAyB,2BAA2B,KAAK,UAAU,yBAAyB,GACtJ;AAED,UACE,8BAAC;IAAwB,GAAI;IAAO,KAAK,MAAM;MAC5C,MAAM,SACiB;;AAI9B,SACE,8BAAC;GAAwB,GAAI;GAAO,KAAK,MAAM;KAC5C,yBACuB;;AAI9B,QACE,8BAAC;EAAwB,GAAI;EAAO,KAAK,MAAM;IAC5C,QACuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownProvider.mjs","names":["MarkdownProvider: FC<MarkdownProviderProps>"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n} from 'react';\n\ntype MarkdownContextValue = {\n renderMarkdown: (markdown: string) => ReactNode;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<MarkdownContextValue>;\n\nconst MarkdownContext = createContext<MarkdownContextValue>({\n renderMarkdown: (markdown: string) => markdown,\n});\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n renderMarkdown,\n}) => (\n <MarkdownContext.Provider value={{ renderMarkdown }}>\n {children}\n </MarkdownContext.Provider>\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MarkdownProvider.mjs","names":["MarkdownProvider: FC<MarkdownProviderProps>"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n} from 'react';\n\ntype MarkdownContextValue = {\n renderMarkdown: (markdown: string) => ReactNode;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<MarkdownContextValue>;\n\nconst MarkdownContext = createContext<MarkdownContextValue>({\n renderMarkdown: (markdown: string) => markdown,\n});\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n renderMarkdown,\n}) => (\n <MarkdownContext.Provider value={{ renderMarkdown }}>\n {children}\n </MarkdownContext.Provider>\n);\n"],"mappings":";;;;;;AAgBA,MAAM,kBAAkB,cAAoC,EAC1D,iBAAiB,aAAqB,UACvC,CAAC;AAEF,MAAa,2BAA2B,WAAW,gBAAgB;AAEnE,MAAaA,oBAA+C,EAC1D,UACA,qBAEA,oBAAC,gBAAgB;CAAS,OAAO,EAAE,gBAAgB;CAChD;EACwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.mjs","names":["MarkdownRenderer: FC<MarkdownRendererProps>","MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps>"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport {\n getContent,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n} from '@intlayer/core';\nimport { useEditorLocale } from '@intlayer/editor-react';\nimport type { ContentNode, KeyPath, LocalesValues } from '@intlayer/types';\nimport type { FC, ReactNode } from 'react';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport { useMarkdownContext } from './MarkdownProvider';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n locale,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n if (typeof editedContentContext !== 'string') {\n const transformedEditedContent = getContent(\n editedContentContext,\n {\n dictionaryKey,\n keyPath,\n },\n locale\n );\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect Markdown content. Edited Markdown content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return renderMarkdown(children);\n }\n\n return renderMarkdown(transformedEditedContent);\n }\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const currentLocale = useEditorLocale();\n\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.mjs","names":["MarkdownRenderer: FC<MarkdownRendererProps>","MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps>"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport {\n getContent,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n} from '@intlayer/core';\nimport { useEditorLocale } from '@intlayer/editor-react';\nimport type { ContentNode, KeyPath, LocalesValues } from '@intlayer/types';\nimport type { FC, ReactNode } from 'react';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport { useMarkdownContext } from './MarkdownProvider';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n locale,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n if (typeof editedContentContext !== 'string') {\n const transformedEditedContent = getContent(\n editedContentContext,\n {\n dictionaryKey,\n keyPath,\n },\n locale\n );\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect Markdown content. Edited Markdown content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return renderMarkdown(children);\n }\n\n return renderMarkdown(transformedEditedContent);\n }\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const currentLocale = useEditorLocale();\n\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";;;;;;;;AAoBA,MAAaA,oBAA+C,EAC1D,eACA,SACA,UACA,aACe;CACf,MAAM,EAAE,mBAAmB,oBAAoB;CAC/C,MAAM,uBAAuB,yBAAyB;EACpD;EACA;EACA;EACD,CAAC;AAEF,KAAI,OAAO,yBAAyB,UAAU;EAC5C,MAAM,2BAA2B,WAC/B,sBACA;GACE;GACA;GACD,EACD,OACD;AAED,MAAI,OAAO,6BAA6B,UAAU;AAChD,WAAQ,MACN,6DAA6D,OAAO,yBAAyB,2BAA2B,KAAK,UAAU,yBAAyB,GACjK;AAED,UAAO,eAAe,SAAS;;AAGjC,SAAO,eAAe,yBAAyB;;AAGjD,QAAO,eAAe,qBAAqB;;AAO7C,MAAaC,4BAA+D,EAC1E,eACA,SACA,UACA,sBACe;CACf,MAAM,uBAAuB,yBAAyB;EACpD;EACA;EACA;EACD,CAAC;CACF,MAAM,gBAAgB,iBAAiB;AAUvC,QANmB,wBAFF,oBAAoB,qBAAqB,EAIxD,iBACA,cACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types8 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/client/format/useCompact.d.ts
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ import * as _intlayer_types12 from "@intlayer/types";
|
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
16
|
-
locale?:
|
|
16
|
+
locale?: _intlayer_types8.LocalesValues;
|
|
17
17
|
}) => string;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { useCompact };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;cAAa,qDAAU,IAAA,CAAA;WAAA,
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;;;;;;;cAAa,qDAAU,IAAA,CAAA;WAAA,gBAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types9 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/client/format/useCurrency.d.ts
|
|
4
4
|
|
|
@@ -27,7 +27,7 @@ import * as _intlayer_types13 from "@intlayer/types";
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
declare const useCurrency: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
30
|
-
locale?:
|
|
30
|
+
locale?: _intlayer_types9.LocalesValues;
|
|
31
31
|
}) => string;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { useCurrency };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":[],"mappings":";;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;cAAa,sDAAW,IAAA,CAAA;WAAA,
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"sourcesContent":[],"mappings":";;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;cAAa,sDAAW,IAAA,CAAA;WAAA,gBAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types11 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/client/format/useNumber.d.ts
|
|
4
4
|
|
|
@@ -25,7 +25,7 @@ import * as _intlayer_types9 from "@intlayer/types";
|
|
|
25
25
|
* A number formatting function bound to the active locale.
|
|
26
26
|
*/
|
|
27
27
|
declare const useNumber: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
28
|
-
locale?:
|
|
28
|
+
locale?: _intlayer_types11.LocalesValues;
|
|
29
29
|
}) => string;
|
|
30
30
|
//#endregion
|
|
31
31
|
export { useNumber };
|