preact-intlayer 6.1.6 → 7.0.0-canary.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/IntlayerNode.cjs +15 -45
- package/dist/cjs/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/UI/ContentSelector.cjs +98 -130
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/client/IntlayerProvider.cjs +67 -95
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/format/index.cjs +17 -50
- package/dist/cjs/client/format/useCompact.cjs +29 -39
- package/dist/cjs/client/format/useCompact.cjs.map +1 -1
- package/dist/cjs/client/format/useCurrency.cjs +43 -39
- package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/client/format/useDate.cjs +45 -36
- package/dist/cjs/client/format/useDate.cjs.map +1 -1
- package/dist/cjs/client/format/useList.cjs +40 -39
- package/dist/cjs/client/format/useList.cjs.map +1 -1
- package/dist/cjs/client/format/useNumber.cjs +41 -39
- package/dist/cjs/client/format/useNumber.cjs.map +1 -1
- package/dist/cjs/client/format/usePercentage.cjs +37 -39
- package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/client/format/useRelativeTime.cjs +37 -39
- package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/client/format/useUnit.cjs +36 -39
- package/dist/cjs/client/format/useUnit.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +29 -69
- package/dist/cjs/client/t.cjs +21 -34
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useContent.cjs +16 -36
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +26 -36
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +23 -52
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +22 -42
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +26 -36
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +21 -50
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +36 -67
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleBase.cjs +25 -53
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +60 -0
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
- package/dist/cjs/client/useTraduction.cjs +34 -35
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/editor/CommunicatorContext.cjs +40 -62
- package/dist/cjs/editor/CommunicatorContext.cjs.map +1 -1
- package/dist/cjs/editor/ConfigurationContext.cjs +26 -47
- package/dist/cjs/editor/ConfigurationContext.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +58 -94
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/DictionariesRecordContext.cjs +47 -73
- package/dist/cjs/editor/DictionariesRecordContext.cjs.map +1 -1
- package/dist/cjs/editor/EditedContentContext.cjs +160 -211
- package/dist/cjs/editor/EditedContentContext.cjs.map +1 -1
- package/dist/cjs/editor/EditorEnabledContext.cjs +34 -59
- package/dist/cjs/editor/EditorEnabledContext.cjs.map +1 -1
- package/dist/cjs/editor/EditorProvider.cjs +62 -66
- package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/FocusDictionaryContext.cjs +51 -75
- package/dist/cjs/editor/FocusDictionaryContext.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +45 -94
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +3 -23
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +73 -50
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameState.cjs +106 -73
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs +67 -66
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +27 -59
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +24 -47
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +15 -40
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +15 -36
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +30 -62
- package/dist/cjs/markdown/MarkdownProvider.cjs +19 -39
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +39 -80
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +7 -25
- package/dist/cjs/plugins.cjs +97 -119
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/preactElement/renderPreactElement.cjs +34 -59
- package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs +13 -25
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/UI/ContentSelector.mjs +94 -105
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +51 -54
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/format/index.mjs +2 -11
- package/dist/esm/client/format/useCompact.mjs +24 -13
- package/dist/esm/client/format/useCompact.mjs.map +1 -1
- package/dist/esm/client/format/useCurrency.mjs +38 -13
- package/dist/esm/client/format/useCurrency.mjs.map +1 -1
- package/dist/esm/client/format/useDate.mjs +40 -10
- package/dist/esm/client/format/useDate.mjs.map +1 -1
- package/dist/esm/client/format/useList.mjs +35 -13
- package/dist/esm/client/format/useList.mjs.map +1 -1
- package/dist/esm/client/format/useNumber.mjs +36 -13
- package/dist/esm/client/format/useNumber.mjs.map +1 -1
- package/dist/esm/client/format/usePercentage.mjs +32 -13
- package/dist/esm/client/format/usePercentage.mjs.map +1 -1
- package/dist/esm/client/format/useRelativeTime.mjs +32 -13
- package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/client/format/useUnit.mjs +31 -13
- package/dist/esm/client/format/useUnit.mjs.map +1 -1
- package/dist/esm/client/index.mjs +5 -32
- package/dist/esm/client/t.mjs +16 -8
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useContent.mjs +14 -10
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +23 -11
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +18 -16
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +17 -15
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +23 -11
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +20 -26
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +31 -31
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.mjs +19 -16
- package/dist/esm/client/useLocaleBase.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +52 -0
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
- package/dist/esm/client/useTraduction.mjs +29 -9
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/editor/CommunicatorContext.mjs +28 -24
- package/dist/esm/editor/CommunicatorContext.mjs.map +1 -1
- package/dist/esm/editor/ConfigurationContext.mjs +20 -24
- package/dist/esm/editor/ConfigurationContext.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +50 -70
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/DictionariesRecordContext.mjs +37 -47
- package/dist/esm/editor/DictionariesRecordContext.mjs.map +1 -1
- package/dist/esm/editor/EditedContentContext.mjs +146 -187
- package/dist/esm/editor/EditedContentContext.mjs.map +1 -1
- package/dist/esm/editor/EditorEnabledContext.mjs +23 -33
- package/dist/esm/editor/EditorEnabledContext.mjs.map +1 -1
- package/dist/esm/editor/EditorProvider.mjs +57 -54
- package/dist/esm/editor/EditorProvider.mjs.map +1 -1
- package/dist/esm/editor/FocusDictionaryContext.mjs +42 -49
- package/dist/esm/editor/FocusDictionaryContext.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +37 -55
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +3 -2
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +68 -24
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameState.mjs +102 -47
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/editor/useCrossURLPathState.mjs +60 -40
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +23 -33
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/editor/useIframeClickInterceptor.mjs +18 -20
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +13 -22
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +13 -18
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +13 -39
- package/dist/esm/markdown/MarkdownProvider.mjs +14 -16
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +34 -57
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +4 -3
- package/dist/esm/plugins.mjs +86 -92
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/preactElement/renderPreactElement.mjs +31 -34
- package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +19 -12
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts +12 -9
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +22 -16
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/format/index.d.ts +9 -9
- package/dist/types/client/format/useCompact.d.ts +8 -2
- package/dist/types/client/format/useCompact.d.ts.map +1 -1
- package/dist/types/client/format/useCurrency.d.ts +8 -2
- package/dist/types/client/format/useCurrency.d.ts.map +1 -1
- package/dist/types/client/format/useDate.d.ts +7 -2
- package/dist/types/client/format/useDate.d.ts.map +1 -1
- package/dist/types/client/format/useList.d.ts +8 -2
- package/dist/types/client/format/useList.d.ts.map +1 -1
- package/dist/types/client/format/useNumber.d.ts +8 -2
- package/dist/types/client/format/useNumber.d.ts.map +1 -1
- package/dist/types/client/format/usePercentage.d.ts +8 -2
- package/dist/types/client/format/usePercentage.d.ts.map +1 -1
- package/dist/types/client/format/useRelativeTime.d.ts +9 -3
- package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/client/format/useUnit.d.ts +8 -2
- package/dist/types/client/format/useUnit.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +11 -12
- package/dist/types/client/t.d.ts +7 -3
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +10 -5
- package/dist/types/client/useContent.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +9 -3
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +7 -3
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +8 -5
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts +4 -1
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +16 -8
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +10 -5
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +45 -0
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
- package/dist/types/client/useTraduction.d.ts +7 -2
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/CommunicatorContext.d.ts +15 -11
- package/dist/types/editor/CommunicatorContext.d.ts.map +1 -1
- package/dist/types/editor/ConfigurationContext.d.ts +12 -7
- package/dist/types/editor/ConfigurationContext.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts +8 -4
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/DictionariesRecordContext.d.ts +15 -12
- package/dist/types/editor/DictionariesRecordContext.d.ts.map +1 -1
- package/dist/types/editor/EditedContentContext.d.ts +32 -29
- package/dist/types/editor/EditedContentContext.d.ts.map +1 -1
- package/dist/types/editor/EditorEnabledContext.d.ts +14 -9
- package/dist/types/editor/EditorEnabledContext.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.d.ts +9 -5
- package/dist/types/editor/EditorProvider.d.ts.map +1 -1
- package/dist/types/editor/FocusDictionaryContext.d.ts +18 -15
- package/dist/types/editor/FocusDictionaryContext.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts +7 -3
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/editor/index.d.ts +2 -2
- package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
- package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
- package/dist/types/editor/useCrossFrameState.d.ts +11 -7
- package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
- package/dist/types/editor/useCrossURLPathState.d.ts +8 -3
- package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts +16 -10
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
- package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
- package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +8 -4
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +8 -4
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +18 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +8 -5
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +13 -11
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +3 -3
- package/dist/types/plugins.d.ts +33 -27
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/preactElement/renderPreactElement.d.ts +7 -3
- package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
- package/package.json +40 -46
- package/LICENSE +0 -202
- package/dist/cjs/client/format/index.cjs.map +0 -1
- package/dist/cjs/client/getBrowserLocale.cjs +0 -173
- package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
- package/dist/cjs/client/index.cjs.map +0 -1
- package/dist/cjs/client/useLocaleCookie.cjs +0 -60
- package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
- package/dist/cjs/editor/index.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/markdown/index.cjs.map +0 -1
- package/dist/esm/client/format/index.mjs.map +0 -1
- package/dist/esm/client/getBrowserLocale.mjs +0 -138
- package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
- package/dist/esm/client/index.mjs.map +0 -1
- package/dist/esm/client/useLocaleCookie.mjs +0 -24
- package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
- package/dist/esm/editor/index.mjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/markdown/index.mjs.map +0 -1
- package/dist/types/client/format/index.d.ts.map +0 -1
- package/dist/types/client/getBrowserLocale.d.ts +0 -25
- package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/useLocaleCookie.d.ts +0 -17
- package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
- package/dist/types/editor/index.d.ts.map +0 -1
- package/dist/types/markdown/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\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.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/usePercentage.ts"],"sourcesContent":["'use client';\n\nimport { percentage } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\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,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,yCACS,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
6
|
+
let __intlayer_core = require("@intlayer/core");
|
|
7
|
+
__intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
|
|
8
|
+
let preact_hooks = require("preact/hooks");
|
|
9
|
+
preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
|
|
10
|
+
|
|
11
|
+
//#region src/client/format/useRelativeTime.ts
|
|
12
|
+
/**
|
|
13
|
+
* Client-side React hook for accessing a localized relative time formatter.
|
|
14
|
+
*
|
|
15
|
+
* This hook:
|
|
16
|
+
* - Reads the current locale from {@link useLocaleBase}.
|
|
17
|
+
* - Creates a new relative time formatter with {@link createRelativeTime}.
|
|
18
|
+
* - Returns a function that can format time differences into localized strings.
|
|
19
|
+
*
|
|
20
|
+
* Example:
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const relativeTime = useRelativeTime();
|
|
23
|
+
* const formatted = relativeTime(new Date("2024-08-01"), new Date());
|
|
24
|
+
* // e.g., "2 weeks ago"
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
|
|
28
|
+
* bound to the current client locale.
|
|
29
|
+
*/
|
|
28
30
|
const useRelativeTime = () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}),
|
|
35
|
-
[locale]
|
|
36
|
-
);
|
|
31
|
+
const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
|
|
32
|
+
return (0, preact_hooks.useCallback)((...args) => (0, __intlayer_core.relativeTime)(args[0], args[1], {
|
|
33
|
+
...args[2],
|
|
34
|
+
locale: args[2]?.locale ?? locale
|
|
35
|
+
}), [locale]);
|
|
37
36
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.useRelativeTime = useRelativeTime;
|
|
42
40
|
//# sourceMappingURL=useRelativeTime.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\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.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useRelativeTime.ts"],"sourcesContent":["'use client';\n\nimport { relativeTime } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\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,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,2CACW,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1,42 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
const require_client_IntlayerProvider = require('../IntlayerProvider.cjs');
|
|
6
|
+
let __intlayer_core = require("@intlayer/core");
|
|
7
|
+
__intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
|
|
8
|
+
let preact_hooks = require("preact/hooks");
|
|
9
|
+
preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
|
|
10
|
+
|
|
11
|
+
//#region src/client/format/useUnit.ts
|
|
12
|
+
/**
|
|
13
|
+
* React hook that provides a unit formatting function
|
|
14
|
+
* based on the current locale from {@link useLocaleBase}.
|
|
15
|
+
*
|
|
16
|
+
* This hook wraps {@link createUnit} to return a formatter
|
|
17
|
+
* that can convert values into human-readable localized units
|
|
18
|
+
* (e.g., "10 km", "5 lbs").
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const formatUnit = useUnit();
|
|
23
|
+
* const distance = formatUnit(10, { unit: "kilometer" });
|
|
24
|
+
* // "10 km" (depending on locale)
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
|
|
28
|
+
*/
|
|
28
29
|
const useUnit = () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}),
|
|
35
|
-
[locale]
|
|
36
|
-
);
|
|
30
|
+
const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
|
|
31
|
+
return (0, preact_hooks.useCallback)((...args) => (0, __intlayer_core.units)(args[0], {
|
|
32
|
+
...args[1],
|
|
33
|
+
locale: args[1]?.locale ?? locale
|
|
34
|
+
}), [locale]);
|
|
37
35
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.useUnit = useUnit;
|
|
42
39
|
//# sourceMappingURL=useUnit.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\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.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useUnit.ts"],"sourcesContent":["'use client';\n\nimport { units } from '@intlayer/core';\nimport { useCallback, useContext } from 'preact/hooks';\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,wCAAsBA,sDAAsB;AAEpD,uCACG,GAAG,oCACI,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
|
|
@@ -1,69 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
useDictionaryDynamic: () => import_useDictionaryDynamic.useDictionaryDynamic,
|
|
31
|
-
useIntlayer: () => import_useIntlayer.useIntlayer,
|
|
32
|
-
useIntlayerContext: () => import_IntlayerProvider.useIntlayerContext,
|
|
33
|
-
useLoadDynamic: () => import_useLoadDynamic.useLoadDynamic,
|
|
34
|
-
useLocale: () => import_useLocale.useLocale,
|
|
35
|
-
useLocaleBase: () => import_useLocaleBase.useLocaleBase,
|
|
36
|
-
useLocaleCookie: () => import_useLocaleCookie.useLocaleCookie
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(client_exports);
|
|
39
|
-
var import_getBrowserLocale = require('./getBrowserLocale.cjs');
|
|
40
|
-
var import_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
41
|
-
var import_t = require('./t.cjs');
|
|
42
|
-
var import_useDictionary = require('./useDictionary.cjs');
|
|
43
|
-
var import_useDictionaryAsync = require('./useDictionaryAsync.cjs');
|
|
44
|
-
var import_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
45
|
-
var import_useIntlayer = require('./useIntlayer.cjs');
|
|
46
|
-
var import_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
47
|
-
var import_useLocale = require('./useLocale.cjs');
|
|
48
|
-
var import_useLocaleBase = require('./useLocaleBase.cjs');
|
|
49
|
-
var import_useLocaleCookie = require('./useLocaleCookie.cjs');
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
IntlayerClientContext,
|
|
53
|
-
IntlayerProvider,
|
|
54
|
-
IntlayerProviderContent,
|
|
55
|
-
getBrowserLocale,
|
|
56
|
-
localeCookie,
|
|
57
|
-
setLocaleCookie,
|
|
58
|
-
t,
|
|
59
|
-
useDictionary,
|
|
60
|
-
useDictionaryAsync,
|
|
61
|
-
useDictionaryDynamic,
|
|
62
|
-
useIntlayer,
|
|
63
|
-
useIntlayerContext,
|
|
64
|
-
useLoadDynamic,
|
|
65
|
-
useLocale,
|
|
66
|
-
useLocaleBase,
|
|
67
|
-
useLocaleCookie
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
2
|
+
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
3
|
+
const require_client_t = require('./t.cjs');
|
|
4
|
+
const require_client_useDictionary = require('./useDictionary.cjs');
|
|
5
|
+
const require_client_useDictionaryAsync = require('./useDictionaryAsync.cjs');
|
|
6
|
+
const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
7
|
+
const require_client_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
8
|
+
const require_client_useIntlayer = require('./useIntlayer.cjs');
|
|
9
|
+
const require_client_useLocale = require('./useLocale.cjs');
|
|
10
|
+
const require_client_useLocaleBase = require('./useLocaleBase.cjs');
|
|
11
|
+
|
|
12
|
+
exports.IntlayerClientContext = require_client_IntlayerProvider.IntlayerClientContext;
|
|
13
|
+
exports.IntlayerProvider = require_client_IntlayerProvider.IntlayerProvider;
|
|
14
|
+
exports.IntlayerProviderContent = require_client_IntlayerProvider.IntlayerProviderContent;
|
|
15
|
+
exports.localeCookie = require_client_useLocaleStorage.localeCookie;
|
|
16
|
+
exports.localeInStorage = require_client_useLocaleStorage.localeInStorage;
|
|
17
|
+
exports.setLocaleCookie = require_client_useLocaleStorage.setLocaleCookie;
|
|
18
|
+
exports.setLocaleInStorage = require_client_useLocaleStorage.setLocaleInStorage;
|
|
19
|
+
exports.t = require_client_t.t;
|
|
20
|
+
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
21
|
+
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
22
|
+
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
|
23
|
+
exports.useIntlayer = require_client_useIntlayer.useIntlayer;
|
|
24
|
+
exports.useIntlayerContext = require_client_IntlayerProvider.useIntlayerContext;
|
|
25
|
+
exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
|
|
26
|
+
exports.useLocale = require_client_useLocale.useLocale;
|
|
27
|
+
exports.useLocaleBase = require_client_useLocaleBase.useLocaleBase;
|
|
28
|
+
exports.useLocaleCookie = require_client_useLocaleStorage.useLocaleCookie;
|
|
29
|
+
exports.useLocaleStorage = require_client_useLocaleStorage.useLocaleStorage;
|
package/dist/cjs/client/t.cjs
CHANGED
|
@@ -1,37 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var t_exports = {};
|
|
21
|
-
__export(t_exports, {
|
|
22
|
-
t: () => t
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(t_exports);
|
|
25
|
-
var import_core = require("@intlayer/core");
|
|
26
|
-
var import_hooks = require("preact/hooks");
|
|
27
|
-
var import_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
6
|
+
let __intlayer_core = require("@intlayer/core");
|
|
7
|
+
__intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
|
|
8
|
+
let preact_hooks = require("preact/hooks");
|
|
9
|
+
preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
|
|
10
|
+
|
|
11
|
+
//#region src/client/t.ts
|
|
12
|
+
/**
|
|
13
|
+
* On the client side, this function returns the translation of the provided multilang content.
|
|
14
|
+
*
|
|
15
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
16
|
+
*/
|
|
28
17
|
const t = (multilangContent, locale) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return (0, import_core.getTranslation)(multilangContent, localeTarget);
|
|
18
|
+
const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
|
|
19
|
+
return (0, __intlayer_core.getTranslation)(multilangContent, locale ?? currentLocale);
|
|
32
20
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.t = t;
|
|
37
24
|
//# sourceMappingURL=t.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport
|
|
1
|
+
{"version":3,"file":"t.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport { getTranslation } from '@intlayer/core';\nimport type { Locale, StrictModeLocaleMap } from '@intlayer/types';\nimport { useContext } from 'preact/hooks';\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?: Locale\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,+CAA6BA,sDAAsB;AAGnE,4CAA+B,kBAFV,UAAU,cAE+B"}
|
|
@@ -1,39 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useContent_exports = {};
|
|
20
|
-
__export(useContent_exports, {
|
|
21
|
-
useContent: () => useContent
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useContent_exports);
|
|
24
|
-
var import_useLocaleBase = require('./useLocaleBase.cjs');
|
|
25
|
-
var import_useTraduction = require('./useTraduction.cjs');
|
|
1
|
+
const require_client_useLocaleBase = require('./useLocaleBase.cjs');
|
|
2
|
+
const require_client_useTraduction = require('./useTraduction.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/client/useContent.ts
|
|
5
|
+
/**
|
|
6
|
+
* On the client side, hook to get the translation content based on the locale
|
|
7
|
+
*/
|
|
26
8
|
const useContent = (languageContent) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
9
|
+
const { locale } = require_client_useLocaleBase.useLocaleBase();
|
|
10
|
+
return {
|
|
11
|
+
locale,
|
|
12
|
+
content: require_client_useTraduction.useTranslation(languageContent),
|
|
13
|
+
t: require_client_useTraduction.useTranslation
|
|
14
|
+
};
|
|
34
15
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.useContent = useContent;
|
|
39
19
|
//# sourceMappingURL=useContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"useContent.cjs","names":["useLocaleBase","useTranslation"],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAWA,4CAAe;AAIlC,QAAO;EACL;EACA,SAJcC,4CAAe,gBAAgB;EAK7C,GAAGA;EACJ"}
|
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var useDictionary_exports = {};
|
|
21
|
-
__export(useDictionary_exports, {
|
|
22
|
-
useDictionary: () => useDictionary
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(useDictionary_exports);
|
|
25
|
-
var import_hooks = require("preact/hooks");
|
|
26
|
-
var import_getDictionary = require('../getDictionary.cjs');
|
|
27
|
-
var import_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
6
|
+
const require_getDictionary = require('../getDictionary.cjs');
|
|
7
|
+
let preact_hooks = require("preact/hooks");
|
|
8
|
+
preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
|
|
9
|
+
|
|
10
|
+
//#region src/client/useDictionary.ts
|
|
11
|
+
/**
|
|
12
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
13
|
+
*
|
|
14
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
15
|
+
*/
|
|
28
16
|
const useDictionary = (dictionary, locale) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
|
|
18
|
+
return (0, preact_hooks.useMemo)(() => {
|
|
19
|
+
return require_getDictionary.getDictionary(dictionary, locale ?? currentLocale);
|
|
20
|
+
}, [
|
|
21
|
+
dictionary,
|
|
22
|
+
currentLocale,
|
|
23
|
+
locale
|
|
24
|
+
]);
|
|
34
25
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.useDictionary = useDictionary;
|
|
39
29
|
//# sourceMappingURL=useDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"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 'preact/hooks';\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,+CAA6BA,sDAAsB;AAEnE,wCAAqB;AAGnB,SAAOC,oCAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC;EAAY;EAAe;EAAO,CAAC"}
|
|
@@ -1,55 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var useDictionaryAsync_exports = {};
|
|
31
|
-
__export(useDictionaryAsync_exports, {
|
|
32
|
-
useDictionaryAsync: () => useDictionaryAsync
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(useDictionaryAsync_exports);
|
|
35
|
-
var import_built = __toESM(require("@intlayer/config/built"));
|
|
36
|
-
var import_hooks = require("preact/hooks");
|
|
37
|
-
var import_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
38
|
-
var import_useDictionary = require('./useDictionary.cjs');
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
5
|
+
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
6
|
+
const require_client_useDictionary = require('./useDictionary.cjs');
|
|
7
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
8
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
9
|
+
let preact_hooks = require("preact/hooks");
|
|
10
|
+
preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
|
|
11
|
+
|
|
12
|
+
//#region src/client/useDictionaryAsync.ts
|
|
13
|
+
/**
|
|
14
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
15
|
+
*
|
|
16
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
17
|
+
*/
|
|
39
18
|
const useDictionaryAsync = async (dictionaryPromise, locale) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
[currentLocale, locale]
|
|
44
|
-
);
|
|
45
|
-
const dictionary = await (0, import_hooks.useMemo)(
|
|
46
|
-
async () => await dictionaryPromise[localeTarget](),
|
|
47
|
-
[dictionaryPromise, localeTarget]
|
|
48
|
-
);
|
|
49
|
-
return (0, import_useDictionary.useDictionary)(dictionary, localeTarget);
|
|
19
|
+
const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
|
|
20
|
+
const localeTarget = (0, preact_hooks.useMemo)(() => locale ?? currentLocale ?? __intlayer_config_built.default?.internationalization.defaultLocale, [currentLocale, locale]);
|
|
21
|
+
return require_client_useDictionary.useDictionary(await (0, preact_hooks.useMemo)(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
|
|
50
22
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.useDictionaryAsync = useDictionaryAsync;
|
|
55
26
|
//# sourceMappingURL=useDictionaryAsync.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\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 <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\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(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB;CAEnE,MAAM,+CAEF,UACA,iBACAC,iCAAe,qBAAqB,eACtC,CAAC,eAAe,OAAO,CACxB;AAUD,QAAOC,2CARY,gCACjB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
|