react-intlayer 8.1.2 → 8.1.3
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 +1 -17
- package/dist/cjs/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/UI/ContentSelector.cjs +1 -96
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/client/IntlayerProvider.cjs +1 -92
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/format/index.cjs +1 -20
- package/dist/cjs/client/format/useCompact.cjs +1 -29
- package/dist/cjs/client/format/useCompact.cjs.map +1 -1
- package/dist/cjs/client/format/useCurrency.cjs +1 -43
- package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/client/format/useDate.cjs +1 -45
- package/dist/cjs/client/format/useDate.cjs.map +1 -1
- package/dist/cjs/client/format/useIntl.cjs +1 -45
- package/dist/cjs/client/format/useIntl.cjs.map +1 -1
- package/dist/cjs/client/format/useList.cjs +1 -40
- package/dist/cjs/client/format/useList.cjs.map +1 -1
- package/dist/cjs/client/format/useNumber.cjs +1 -41
- package/dist/cjs/client/format/useNumber.cjs.map +1 -1
- package/dist/cjs/client/format/usePercentage.cjs +1 -37
- package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/client/format/useRelativeTime.cjs +1 -37
- package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/client/format/useUnit.cjs +1 -36
- package/dist/cjs/client/format/useUnit.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +1 -34
- package/dist/cjs/client/t.cjs +1 -40
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -27
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useI18n.cjs +1 -45
- package/dist/cjs/client/useI18n.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -42
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +1 -27
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -60
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleBase.cjs +1 -26
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -61
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/client/useRewriteURL.cjs +1 -42
- package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.cjs +1 -35
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -55
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -61
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +1 -4
- package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -40
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +1 -19
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -19
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/html/HTMLProvider.cjs +1 -18
- package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
- package/dist/cjs/html/HTMLRenderer.cjs +1 -59
- package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
- package/dist/cjs/html/HTMLRendererPlugin.cjs +1 -36
- package/dist/cjs/html/HTMLRendererPlugin.cjs.map +1 -1
- package/dist/cjs/html/index.cjs +1 -12
- package/dist/cjs/index.cjs +1 -52
- package/dist/cjs/markdown/MarkdownProvider.cjs +1 -77
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -199
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -33
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +1 -25
- package/dist/cjs/markdown/processor.cjs +1 -66
- package/dist/cjs/markdown/processor.cjs.map +1 -1
- package/dist/cjs/markdown/runtime.cjs +1 -43
- package/dist/cjs/markdown/runtime.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +1 -179
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/reactElement/renderReactElement.cjs +1 -52
- package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs +1 -34
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/format/index.cjs +1 -18
- package/dist/cjs/server/format/useCompact.cjs +1 -27
- package/dist/cjs/server/format/useCompact.cjs.map +1 -1
- package/dist/cjs/server/format/useCurrency.cjs +1 -38
- package/dist/cjs/server/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/server/format/useDate.cjs +1 -43
- package/dist/cjs/server/format/useDate.cjs.map +1 -1
- package/dist/cjs/server/format/useIntl.cjs +1 -44
- package/dist/cjs/server/format/useIntl.cjs.map +1 -1
- package/dist/cjs/server/format/useList.cjs +1 -35
- package/dist/cjs/server/format/useList.cjs.map +1 -1
- package/dist/cjs/server/format/useNumber.cjs +1 -39
- package/dist/cjs/server/format/useNumber.cjs.map +1 -1
- package/dist/cjs/server/format/usePercentage.cjs +1 -35
- package/dist/cjs/server/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/server/format/useRelativeTime.cjs +1 -35
- package/dist/cjs/server/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/server/format/useUnit.cjs +1 -34
- package/dist/cjs/server/format/useUnit.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +1 -24
- package/dist/cjs/server/serverContext.cjs +1 -58
- package/dist/cjs/server/serverContext.cjs.map +1 -1
- package/dist/cjs/server/t.cjs +1 -35
- package/dist/cjs/server/t.cjs.map +1 -1
- package/dist/cjs/server/useDictionary.cjs +1 -17
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryAsync.cjs +1 -21
- package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryDynamic.cjs +1 -22
- package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/server/useI18n.cjs +1 -38
- package/dist/cjs/server/useI18n.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.cjs +1 -17
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/cjs/server/useLoadDynamic.cjs +1 -14
- package/dist/cjs/server/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/server/useLocale.cjs +1 -24
- package/dist/cjs/server/useLocale.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs +1 -15
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/UI/ContentSelector.mjs +1 -94
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +1 -86
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/format/index.mjs +1 -11
- package/dist/esm/client/format/useCompact.mjs +1 -27
- package/dist/esm/client/format/useCompact.mjs.map +1 -1
- package/dist/esm/client/format/useCurrency.mjs +1 -41
- package/dist/esm/client/format/useCurrency.mjs.map +1 -1
- package/dist/esm/client/format/useDate.mjs +1 -43
- package/dist/esm/client/format/useDate.mjs.map +1 -1
- package/dist/esm/client/format/useIntl.mjs +1 -43
- package/dist/esm/client/format/useIntl.mjs.map +1 -1
- package/dist/esm/client/format/useList.mjs +1 -38
- package/dist/esm/client/format/useList.mjs.map +1 -1
- package/dist/esm/client/format/useNumber.mjs +1 -39
- package/dist/esm/client/format/useNumber.mjs.map +1 -1
- package/dist/esm/client/format/usePercentage.mjs +1 -35
- package/dist/esm/client/format/usePercentage.mjs.map +1 -1
- package/dist/esm/client/format/useRelativeTime.mjs +1 -35
- package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/client/format/useUnit.mjs +1 -34
- package/dist/esm/client/format/useUnit.mjs.map +1 -1
- package/dist/esm/client/index.mjs +1 -14
- package/dist/esm/client/t.mjs +1 -38
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +1 -25
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +1 -21
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useI18n.mjs +1 -43
- package/dist/esm/client/useI18n.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -40
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +1 -25
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -57
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.mjs +1 -23
- package/dist/esm/client/useLocaleBase.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +1 -54
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/client/useRewriteURL.mjs +1 -39
- package/dist/esm/client/useRewriteURL.mjs.map +1 -1
- package/dist/esm/client/useTraduction.mjs +1 -33
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -53
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +1 -58
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +1 -3
- package/dist/esm/editor/useEditedContentRenderer.mjs +1 -37
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +1 -17
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +1 -17
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/html/HTMLProvider.mjs +1 -15
- package/dist/esm/html/HTMLProvider.mjs.map +1 -1
- package/dist/esm/html/HTMLRenderer.mjs +1 -54
- package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
- package/dist/esm/html/HTMLRendererPlugin.mjs +1 -34
- package/dist/esm/html/HTMLRendererPlugin.mjs.map +1 -1
- package/dist/esm/html/index.mjs +1 -5
- package/dist/esm/index.mjs +1 -21
- package/dist/esm/markdown/MarkdownProvider.mjs +1 -74
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +1 -195
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -30
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +1 -7
- package/dist/esm/markdown/processor.mjs +1 -58
- package/dist/esm/markdown/processor.mjs.map +1 -1
- package/dist/esm/markdown/runtime.mjs +1 -39
- package/dist/esm/markdown/runtime.mjs.map +1 -1
- package/dist/esm/plugins.mjs +1 -172
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/reactElement/renderReactElement.mjs +1 -50
- package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs +1 -28
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/format/index.mjs +1 -10
- package/dist/esm/server/format/useCompact.mjs +1 -25
- package/dist/esm/server/format/useCompact.mjs.map +1 -1
- package/dist/esm/server/format/useCurrency.mjs +1 -36
- package/dist/esm/server/format/useCurrency.mjs.map +1 -1
- package/dist/esm/server/format/useDate.mjs +1 -41
- package/dist/esm/server/format/useDate.mjs.map +1 -1
- package/dist/esm/server/format/useIntl.mjs +1 -41
- package/dist/esm/server/format/useIntl.mjs.map +1 -1
- package/dist/esm/server/format/useList.mjs +1 -33
- package/dist/esm/server/format/useList.mjs.map +1 -1
- package/dist/esm/server/format/useNumber.mjs +1 -37
- package/dist/esm/server/format/useNumber.mjs.map +1 -1
- package/dist/esm/server/format/usePercentage.mjs +1 -33
- package/dist/esm/server/format/usePercentage.mjs.map +1 -1
- package/dist/esm/server/format/useRelativeTime.mjs +1 -33
- package/dist/esm/server/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/server/format/useUnit.mjs +1 -32
- package/dist/esm/server/format/useUnit.mjs.map +1 -1
- package/dist/esm/server/index.mjs +1 -12
- package/dist/esm/server/serverContext.mjs +1 -54
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/t.mjs +1 -33
- package/dist/esm/server/t.mjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs +1 -16
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useDictionaryAsync.mjs +1 -18
- package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/server/useDictionaryDynamic.mjs +1 -19
- package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/server/useI18n.mjs +1 -37
- package/dist/esm/server/useI18n.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +1 -16
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/esm/server/useLoadDynamic.mjs +1 -11
- package/dist/esm/server/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/server/useLocale.mjs +1 -21
- package/dist/esm/server/useLocale.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +1 -1
- package/dist/types/client/format/useDate.d.ts +1 -1
- package/dist/types/client/useDictionary.d.ts +2 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useI18n.d.ts +3 -3
- package/dist/types/client/useI18n.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +2 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +1 -1
- package/dist/types/getIntlayer.d.ts +1 -1
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/html/HTMLComponentTypes.d.ts +1 -1
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/markdown/processor.d.ts +1 -1
- package/dist/types/markdown/runtime.d.ts +1 -1
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/server/format/useCompact.d.ts +1 -1
- package/dist/types/server/format/useCurrency.d.ts +1 -1
- package/dist/types/server/format/useDate.d.ts +1 -1
- package/dist/types/server/format/useList.d.ts +1 -1
- package/dist/types/server/format/useNumber.d.ts +1 -1
- package/dist/types/server/format/usePercentage.d.ts +1 -1
- package/dist/types/server/format/useRelativeTime.d.ts +1 -1
- package/dist/types/server/format/useUnit.d.ts +1 -1
- package/dist/types/server/useDictionary.d.ts +2 -2
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts +2 -2
- package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/server/useI18n.d.ts +3 -3
- package/dist/types/server/useI18n.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +2 -2
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('./serverContext.cjs');
|
|
4
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
7
|
-
|
|
8
|
-
//#region src/server/IntlayerServerProvider.tsx
|
|
9
|
-
const { defaultLocale } = _intlayer_config_built.default?.internationalization ?? {};
|
|
10
|
-
/**
|
|
11
|
-
* Context that store the current locale on the server side
|
|
12
|
-
*/
|
|
13
|
-
const IntlayerServerContext = require_server_serverContext.createServerContext(defaultLocale);
|
|
14
|
-
/**
|
|
15
|
-
* Hook that provides the current locale
|
|
16
|
-
*/
|
|
17
|
-
const useIntlayer = () => require_server_serverContext.getServerContext(IntlayerServerContext);
|
|
18
|
-
/**
|
|
19
|
-
* Get the current locale
|
|
20
|
-
*/
|
|
21
|
-
const locale = require_server_serverContext.getServerContext(IntlayerServerContext);
|
|
22
|
-
/**
|
|
23
|
-
* Provider that store the current locale on the server side
|
|
24
|
-
*/
|
|
25
|
-
const IntlayerServerProvider = ({ children, locale = defaultLocale }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerServerContext.Provider, {
|
|
26
|
-
value: locale,
|
|
27
|
-
children
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
exports.IntlayerServerContext = IntlayerServerContext;
|
|
32
|
-
exports.IntlayerServerProvider = IntlayerServerProvider;
|
|
33
|
-
exports.locale = locale;
|
|
34
|
-
exports.useIntlayer = useIntlayer;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./serverContext.cjs`);let n=require(`react/jsx-runtime`),r=require(`@intlayer/config/built`);r=e.__toESM(r);const{defaultLocale:i}=r.default?.internationalization??{},a=t.createServerContext(i),o=()=>t.getServerContext(a),s=t.getServerContext(a),c=({children:e,locale:t=i})=>(0,n.jsx)(a.Provider,{value:t,children:e});exports.IntlayerServerContext=a,exports.IntlayerServerProvider=c,exports.locale=s,exports.useIntlayer=o;
|
|
35
2
|
//# sourceMappingURL=IntlayerServerProvider.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerServerProvider.cjs","names":["configuration","createServerContext","getServerContext"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = configuration?.internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerServerProvider.cjs","names":["configuration","createServerContext","getServerContext"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = configuration?.internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":"+OAMA,KAAM,CAAE,iBAAkBA,EAAAA,SAAe,sBAAwB,EAAE,CAKtD,EACXC,EAAAA,oBAAmC,EAAc,CAKtC,MAAoBC,EAAAA,iBAAiB,EAAsB,CAK3D,EAASA,EAAAA,iBAAiB,EAAsB,CAShD,GAA2D,CACtE,WACA,SAAS,MAET,EAAA,EAAA,KAAC,EAAsB,SAAA,CAAS,MAAO,EACpC,YAC8B"}
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_server_format_useCompact = require('./useCompact.cjs');
|
|
3
|
-
const require_server_format_useCurrency = require('./useCurrency.cjs');
|
|
4
|
-
const require_server_format_useDate = require('./useDate.cjs');
|
|
5
|
-
const require_server_format_useList = require('./useList.cjs');
|
|
6
|
-
const require_server_format_useNumber = require('./useNumber.cjs');
|
|
7
|
-
const require_server_format_usePercentage = require('./usePercentage.cjs');
|
|
8
|
-
const require_server_format_useRelativeTime = require('./useRelativeTime.cjs');
|
|
9
|
-
const require_server_format_useUnit = require('./useUnit.cjs');
|
|
10
|
-
|
|
11
|
-
exports.useCompact = require_server_format_useCompact.useCompact;
|
|
12
|
-
exports.useCurrency = require_server_format_useCurrency.useCurrency;
|
|
13
|
-
exports.useDate = require_server_format_useDate.useDate;
|
|
14
|
-
exports.useList = require_server_format_useList.useList;
|
|
15
|
-
exports.useNumber = require_server_format_useNumber.useNumber;
|
|
16
|
-
exports.usePercentage = require_server_format_usePercentage.usePercentage;
|
|
17
|
-
exports.useRelativeTime = require_server_format_useRelativeTime.useRelativeTime;
|
|
18
|
-
exports.useUnit = require_server_format_useUnit.useUnit;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useCompact.cjs`),t=require(`./useCurrency.cjs`),n=require(`./useDate.cjs`),r=require(`./useList.cjs`),i=require(`./useNumber.cjs`),a=require(`./usePercentage.cjs`),o=require(`./useRelativeTime.cjs`),s=require(`./useUnit.cjs`);exports.useCompact=e.useCompact,exports.useCurrency=t.useCurrency,exports.useDate=n.useDate,exports.useList=r.useList,exports.useNumber=i.useNumber,exports.usePercentage=a.usePercentage,exports.useRelativeTime=o.useRelativeTime,exports.useUnit=s.useUnit;
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/useCompact.ts
|
|
8
|
-
/**
|
|
9
|
-
* React client hook that provides a compact number formatter
|
|
10
|
-
* bound to the current application locale.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* const formatCompact = useCompact();
|
|
15
|
-
* formatCompact(1500); // "1.5K"
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
const useCompact = () => {
|
|
19
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
20
|
-
return (...args) => (0, _intlayer_core.compact)(args[0], {
|
|
21
|
-
...args[1],
|
|
22
|
-
locale: args[1]?.locale ?? locale
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.useCompact = useCompact;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.compact)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useCompact=r;
|
|
28
2
|
//# sourceMappingURL=useCompact.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iPAeA,MAAa,MAAmB,CAC9B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,SACD,EAAK,GAAI,CACf,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,39 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/useCurrency.ts
|
|
8
|
-
/**
|
|
9
|
-
* React client hook that provides a currency formatter
|
|
10
|
-
* bound to the current application locale.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* const formatCurrency = useCurrency();
|
|
15
|
-
*
|
|
16
|
-
* formatCurrency(1500, { currency: "USD" });
|
|
17
|
-
* // "$1,500.00"
|
|
18
|
-
*
|
|
19
|
-
* formatCurrency(1500, { currency: "EUR", locale: "de-DE" });
|
|
20
|
-
* // "1.500,00 €"
|
|
21
|
-
*
|
|
22
|
-
* formatCurrency(9876543.21, {
|
|
23
|
-
* currency: "JPY",
|
|
24
|
-
* fractionDigits: 0,
|
|
25
|
-
* });
|
|
26
|
-
* // "¥9,876,543"
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
const useCurrency = () => {
|
|
30
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
31
|
-
return (...args) => (0, _intlayer_core.currency)(args[0], {
|
|
32
|
-
...args[1],
|
|
33
|
-
locale: args[1]?.locale ?? locale
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
exports.useCurrency = useCurrency;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.currency)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useCurrency=r;
|
|
39
2
|
//# sourceMappingURL=useCurrency.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iPA0BA,MAAa,MAAoB,CAC/B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,UACA,EAAK,GAAI,CAChB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/useDate.ts
|
|
8
|
-
/**
|
|
9
|
-
* React client hook that provides a localized date/time formatter
|
|
10
|
-
* bound to the current application locale.
|
|
11
|
-
*
|
|
12
|
-
* @returns {(date: Date | string | number, options?: DateProps) => string}
|
|
13
|
-
* A function to format dates or timestamps into localized date/time strings.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* const formatDate = useDate();
|
|
18
|
-
*
|
|
19
|
-
* formatDate(new Date("2025-01-01"));
|
|
20
|
-
* // "Jan 1, 2025"
|
|
21
|
-
*
|
|
22
|
-
* formatDate("2025-01-01T15:30:00Z", {
|
|
23
|
-
* dateStyle: "full",
|
|
24
|
-
* timeStyle: "short",
|
|
25
|
-
* });
|
|
26
|
-
* // "Wednesday, January 1, 2025 at 3:30 PM"
|
|
27
|
-
*
|
|
28
|
-
* formatDate(1735689600000, { locale: "fr-FR", dateStyle: "long" });
|
|
29
|
-
* // "1 janvier 2025"
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @see createDate
|
|
33
|
-
*/
|
|
34
|
-
const useDate = () => {
|
|
35
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
36
|
-
return (...args) => (0, _intlayer_core.date)(args[0], {
|
|
37
|
-
...args[1],
|
|
38
|
-
locale: args[1]?.locale ?? locale
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
exports.useDate = useDate;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.date)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useDate=r;
|
|
44
2
|
//# sourceMappingURL=useDate.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\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.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iPA+BA,MAAa,MAAgB,CAC3B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,MACJ,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
8
|
-
|
|
9
|
-
//#region src/server/format/useIntl.ts
|
|
10
|
-
/**
|
|
11
|
-
* React client hook that provides a locale-bound `Intl` object.
|
|
12
|
-
*
|
|
13
|
-
* It acts exactly like the native `Intl` object, but acts as a proxy to:
|
|
14
|
-
* 1. Inject the current locale automatically if none is provided.
|
|
15
|
-
* 2. Use the performance-optimized `CachedIntl` under the hood.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* const intl = useIntl(); // uses context locale
|
|
20
|
-
*
|
|
21
|
-
* // Standard API, but no need to pass 'en-US' as the first argument
|
|
22
|
-
* const formatted = new intl.NumberFormat({
|
|
23
|
-
* style: 'currency',
|
|
24
|
-
* currency: 'USD'
|
|
25
|
-
* }).format(123.45);
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```tsx
|
|
30
|
-
* const intl = useIntl();
|
|
31
|
-
*
|
|
32
|
-
* // You can still override the locale if needed
|
|
33
|
-
* const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());
|
|
34
|
-
* // or
|
|
35
|
-
* const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
const useIntl = (locale) => {
|
|
39
|
-
const currentLocale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
40
|
-
return (0, _intlayer_core.bindIntl)(locale ?? currentLocale ?? _intlayer_config_built.default?.internationalization?.defaultLocale);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
exports.useIntl = useIntl;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../serverContext.cjs`),n=require(`../IntlayerServerProvider.cjs`);let r=require(`@intlayer/config/built`);r=e.__toESM(r);let i=require(`@intlayer/core/formatters`);const a=e=>{let a=t.getServerContext(n.IntlayerServerContext);return(0,i.bindIntl)(e??a??r.default?.internationalization?.defaultLocale)};exports.useIntl=a;
|
|
45
2
|
//# sourceMappingURL=useIntl.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.cjs","names":["getServerContext","IntlayerServerContext","configuration"],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.cjs","names":["getServerContext","IntlayerServerContext","configuration"],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":"0SAkCA,MAAa,EAAW,GAA2B,CACjD,IAAM,EAAgBA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAE5E,OAAA,EAAA,EAAA,UACE,GACE,GACAC,EAAAA,SAAe,sBAAsB,cACxC"}
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/useList.ts
|
|
8
|
-
/**
|
|
9
|
-
* React server hook that provides a list formatter
|
|
10
|
-
* bound to the current application locale.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* const formatList = useList();
|
|
15
|
-
*
|
|
16
|
-
* formatList(['apple', 'banana', 'orange']);
|
|
17
|
-
* // "apple, banana, and orange"
|
|
18
|
-
*
|
|
19
|
-
* formatList(['red', 'green', 'blue'], { type: 'disjunction' });
|
|
20
|
-
* // "red, green, or blue"
|
|
21
|
-
*
|
|
22
|
-
* formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });
|
|
23
|
-
* // "1, 2 und 3"
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
const useList = () => {
|
|
27
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
28
|
-
return (...args) => (0, _intlayer_core.list)(args[0], {
|
|
29
|
-
...args[1],
|
|
30
|
-
locale: args[1]?.locale ?? locale
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
exports.useList = useList;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.list)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useList=r;
|
|
36
2
|
//# sourceMappingURL=useList.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React server hook that provides a list formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React server hook that provides a list formatter\n * bound to the current application locale.\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iPAuBA,MAAa,MAAgB,CAC3B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,MACJ,EAAK,GAAI,CACZ,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/useNumber.ts
|
|
8
|
-
/**
|
|
9
|
-
* React client hook that provides a localized number formatter.
|
|
10
|
-
*
|
|
11
|
-
* Uses the current locale from {@link useLocaleBase} and returns
|
|
12
|
-
* a function that can be used to format numbers consistently
|
|
13
|
-
* according to the user's locale.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* const formatNumber = useNumber();
|
|
18
|
-
*
|
|
19
|
-
* formatNumber(12345);
|
|
20
|
-
* // e.g. "12,345" (en-US)
|
|
21
|
-
* // e.g. "12 345" (fr-FR)
|
|
22
|
-
*
|
|
23
|
-
* formatNumber(0.75, { style: "percent" });
|
|
24
|
-
* // e.g. "75%"
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @returns {(value: string | number, options?: import("../createNumber").NumberProps) => string}
|
|
28
|
-
* A number formatting function bound to the active locale.
|
|
29
|
-
*/
|
|
30
|
-
const useNumber = () => {
|
|
31
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
32
|
-
return (...args) => (0, _intlayer_core.number)(args[0], {
|
|
33
|
-
...args[1],
|
|
34
|
-
locale: args[1]?.locale ?? locale
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
exports.useNumber = useNumber;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.number)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useNumber=r;
|
|
40
2
|
//# sourceMappingURL=useNumber.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iPA2BA,MAAa,MAAkB,CAC7B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,QACF,EAAK,GAAI,CACd,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/usePercentage.ts
|
|
8
|
-
/**
|
|
9
|
-
* React hook to provide a percentage formatter function
|
|
10
|
-
* based on the current application locale.
|
|
11
|
-
*
|
|
12
|
-
* This hook retrieves the active locale using {@link useLocaleBase}
|
|
13
|
-
* and memoizes a `createPercentage` instance for that locale.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* const formatPercentage = usePercentage();
|
|
18
|
-
*
|
|
19
|
-
* const result = formatPercentage(0.875, { maximumFractionDigits: 1 });
|
|
20
|
-
* // "87.5%" (depending on locale)
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @returns {(value: string | number, options?: Omit<PercentageOptions, "value">) => string}
|
|
24
|
-
* A function that formats numbers or numeric strings into localized percentages.
|
|
25
|
-
*/
|
|
26
|
-
const usePercentage = () => {
|
|
27
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
28
|
-
return (...args) => (0, _intlayer_core.percentage)(args[0], {
|
|
29
|
-
...args[1],
|
|
30
|
-
locale: args[1]?.locale ?? locale
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
exports.usePercentage = usePercentage;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.percentage)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.usePercentage=r;
|
|
36
2
|
//# sourceMappingURL=usePercentage.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iPAuBA,MAAa,MAAsB,CACjC,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,YACE,EAAK,GAAI,CAClB,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/useRelativeTime.ts
|
|
8
|
-
/**
|
|
9
|
-
* Client-side React hook for accessing a localized relative time formatter.
|
|
10
|
-
*
|
|
11
|
-
* This hook:
|
|
12
|
-
* - Reads the current locale from {@link useLocaleBase}.
|
|
13
|
-
* - Creates a new relative time formatter with {@link createRelativeTime}.
|
|
14
|
-
* - Returns a function that can format time differences into localized strings.
|
|
15
|
-
*
|
|
16
|
-
* Example:
|
|
17
|
-
* ```tsx
|
|
18
|
-
* const relativeTime = useRelativeTime();
|
|
19
|
-
* const formatted = relativeTime(new Date("2024-08-01"), new Date());
|
|
20
|
-
* // e.g., "2 weeks ago"
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
|
|
24
|
-
* bound to the current client locale.
|
|
25
|
-
*/
|
|
26
|
-
const useRelativeTime = () => {
|
|
27
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
28
|
-
return (...args) => (0, _intlayer_core.relativeTime)(args[0], args[1] ?? /* @__PURE__ */ new Date(), {
|
|
29
|
-
...args[2],
|
|
30
|
-
locale: args[2]?.locale ?? locale
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
exports.useRelativeTime = useRelativeTime;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.relativeTime)(e[0],e[1]??new Date,{...e[2],locale:e[2]?.locale??r})};exports.useRelativeTime=r;
|
|
36
2
|
//# sourceMappingURL=useRelativeTime.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1] ?? new Date(), {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1] ?? new Date(), {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":"iPAuBA,MAAa,MAAwB,CACnC,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,cACI,EAAK,GAAI,EAAK,IAAM,IAAI,KAAQ,CAC3C,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_server_serverContext = require('../serverContext.cjs');
|
|
4
|
-
const require_server_IntlayerServerProvider = require('../IntlayerServerProvider.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
|
|
7
|
-
//#region src/server/format/useUnit.ts
|
|
8
|
-
/**
|
|
9
|
-
* React hook that provides a unit formatting function
|
|
10
|
-
* based on the current locale from {@link useLocaleBase}.
|
|
11
|
-
*
|
|
12
|
-
* This hook wraps {@link createUnit} to return a formatter
|
|
13
|
-
* that can convert values into human-readable localized units
|
|
14
|
-
* (e.g., "10 km", "5 lbs").
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* const formatUnit = useUnit();
|
|
19
|
-
* const distance = formatUnit(10, { unit: "kilometer" });
|
|
20
|
-
* // "10 km" (depending on locale)
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
|
|
24
|
-
*/
|
|
25
|
-
const useUnit = () => {
|
|
26
|
-
const locale = require_server_serverContext.getServerContext(require_server_IntlayerServerProvider.IntlayerServerContext);
|
|
27
|
-
return (...args) => (0, _intlayer_core.units)(args[0], {
|
|
28
|
-
...args[1],
|
|
29
|
-
locale: args[1]?.locale ?? locale
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
exports.useUnit = useUnit;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../serverContext.cjs`),t=require(`../IntlayerServerProvider.cjs`);let n=require(`@intlayer/core/formatters`);const r=()=>{let r=e.getServerContext(t.IntlayerServerContext);return(...e)=>(0,n.units)(e[0],{...e[1],locale:e[1]?.locale??r})};exports.useUnit=r;
|
|
35
2
|
//# sourceMappingURL=useUnit.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../../src/server/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\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 = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":"iPAsBA,MAAa,MAAgB,CAC3B,IAAM,EAASA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAErE,OAAQ,GAAG,KAAA,EAAA,EAAA,OACH,EAAK,GAAI,CACb,GAAG,EAAK,GACR,OAAQ,EAAK,IAAI,QAAU,EAC5B,CAAC"}
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
3
|
-
const require_server_format_useIntl = require('./format/useIntl.cjs');
|
|
4
|
-
const require_server_t = require('./t.cjs');
|
|
5
|
-
const require_server_useDictionary = require('./useDictionary.cjs');
|
|
6
|
-
const require_server_useDictionaryAsync = require('./useDictionaryAsync.cjs');
|
|
7
|
-
const require_server_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
8
|
-
const require_server_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
9
|
-
const require_server_useI18n = require('./useI18n.cjs');
|
|
10
|
-
const require_server_useIntlayer = require('./useIntlayer.cjs');
|
|
11
|
-
const require_server_useLocale = require('./useLocale.cjs');
|
|
12
|
-
|
|
13
|
-
exports.IntlayerServer = require_server_IntlayerServerProvider.IntlayerServerContext;
|
|
14
|
-
exports.IntlayerServerProvider = require_server_IntlayerServerProvider.IntlayerServerProvider;
|
|
15
|
-
exports.locale = require_server_IntlayerServerProvider.locale;
|
|
16
|
-
exports.t = require_server_t.t;
|
|
17
|
-
exports.useDictionary = require_server_useDictionary.useDictionary;
|
|
18
|
-
exports.useDictionaryAsync = require_server_useDictionaryAsync.useDictionaryAsync;
|
|
19
|
-
exports.useDictionaryDynamic = require_server_useDictionaryDynamic.useDictionaryDynamic;
|
|
20
|
-
exports.useI18n = require_server_useI18n.useI18n;
|
|
21
|
-
exports.useIntl = require_server_format_useIntl.useIntl;
|
|
22
|
-
exports.useIntlayer = require_server_useIntlayer.useIntlayer;
|
|
23
|
-
exports.useLoadDynamic = require_server_useLoadDynamic.useLoadDynamic;
|
|
24
|
-
exports.useLocale = require_server_useLocale.useLocale;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./IntlayerServerProvider.cjs`),t=require(`./format/useIntl.cjs`),n=require(`./t.cjs`),r=require(`./useDictionary.cjs`),i=require(`./useDictionaryAsync.cjs`),a=require(`./useLoadDynamic.cjs`),o=require(`./useDictionaryDynamic.cjs`),s=require(`./useI18n.cjs`),c=require(`./useIntlayer.cjs`),l=require(`./useLocale.cjs`);exports.IntlayerServer=e.IntlayerServerContext,exports.IntlayerServerProvider=e.IntlayerServerProvider,exports.locale=e.locale,exports.t=n.t,exports.useDictionary=r.useDictionary,exports.useDictionaryAsync=i.useDictionaryAsync,exports.useDictionaryDynamic=o.useDictionaryDynamic,exports.useI18n=s.useI18n,exports.useIntl=t.useIntl,exports.useIntlayer=c.useIntlayer,exports.useLoadDynamic=a.useLoadDynamic,exports.useLocale=l.useLocale;
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let react = require("react");
|
|
4
|
-
react = require_runtime.__toESM(react);
|
|
5
|
-
|
|
6
|
-
//#region src/server/serverContext.tsx
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new datastore for a given server context.
|
|
9
|
-
* Attempts to closely mimic the `createContext` API.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* const IntlayerServer = createServerContext<string | null>(null);
|
|
13
|
-
*
|
|
14
|
-
* <IntlayerServer value={locale}>
|
|
15
|
-
* {children}
|
|
16
|
-
* </IntlayerServer>
|
|
17
|
-
*/
|
|
18
|
-
const cacheFallback = () => () => ({ value: void 0 });
|
|
19
|
-
const createServerContext = (defaultValue) => {
|
|
20
|
-
throwInClient();
|
|
21
|
-
const getCache = (react.default.cache ?? cacheFallback)(() => ({ value: void 0 }));
|
|
22
|
-
const Provider = ({ children, value }) => {
|
|
23
|
-
getCache().value = value;
|
|
24
|
-
return children;
|
|
25
|
-
};
|
|
26
|
-
const ServerContext = Provider;
|
|
27
|
-
ServerContext.Provider = Provider;
|
|
28
|
-
ServerContext.Consumer = (props) => {
|
|
29
|
-
const store = getCache();
|
|
30
|
-
return props.children(store ? store.value : defaultValue);
|
|
31
|
-
};
|
|
32
|
-
ServerContext._storage = getCache;
|
|
33
|
-
ServerContext._defaultValue = defaultValue;
|
|
34
|
-
return ServerContext;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Fetches a value present in a given server context.
|
|
38
|
-
* Attempts to closely mimic the `useContext` API.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* getServerContext(IntlayerServer);
|
|
42
|
-
*/
|
|
43
|
-
const getServerContext = ({ _storage, _defaultValue }) => {
|
|
44
|
-
const store = _storage();
|
|
45
|
-
if (!store) return _defaultValue;
|
|
46
|
-
return store.value;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Throws if called within a client component environment.
|
|
50
|
-
* Useful to help prevent mistakes.
|
|
51
|
-
*/
|
|
52
|
-
const throwInClient = () => {
|
|
53
|
-
if (typeof window !== "undefined") throw new Error(`createServerContext only works in Server Components`);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
|
-
exports.createServerContext = createServerContext;
|
|
58
|
-
exports.getServerContext = getServerContext;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`react`);t=e.__toESM(t);const n=()=>()=>({value:void 0}),r=e=>{a();let r=(t.default.cache??n)(()=>({value:void 0})),i=({children:e,value:t})=>(r().value=t,e),o=i;return o.Provider=i,o.Consumer=t=>{let n=r();return t.children(n?n.value:e)},o._storage=r,o._defaultValue=e,o},i=({_storage:e,_defaultValue:t})=>{let n=e();return n?n.value:t},a=()=>{if(typeof window<`u`)throw Error(`createServerContext only works in Server Components`)};exports.createServerContext=r,exports.getServerContext=i;
|
|
59
2
|
//# sourceMappingURL=serverContext.cjs.map
|