preact-intlayer 9.7.0 → 9.7.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 +1 -2
- package/dist/cjs/UI/ContentSelector.cjs +1 -2
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/cjs/analytics/AnalyticsProvider.cjs +2 -3
- package/dist/cjs/analytics/exposureSink.cjs +1 -2
- package/dist/cjs/analytics/index.cjs +4 -4
- package/dist/cjs/analytics/useAnalytics.cjs +4 -5
- package/dist/cjs/analytics/useConversion.cjs +2 -3
- package/dist/cjs/analytics/useExperiment.cjs +2 -3
- package/dist/cjs/client/IntlayerProvider.cjs +7 -8
- package/dist/cjs/client/index.cjs +11 -11
- package/dist/cjs/client/t.cjs +3 -4
- package/dist/cjs/client/useContent.cjs +3 -4
- package/dist/cjs/client/useDictionary.cjs +3 -4
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +4 -5
- package/dist/cjs/client/useDictionaryDynamic.cjs +5 -6
- package/dist/cjs/client/useIntlayer.cjs +3 -4
- package/dist/cjs/client/useLoadDynamic.cjs +1 -2
- package/dist/cjs/client/useLocale.cjs +4 -5
- package/dist/cjs/client/useLocaleBase.cjs +3 -4
- package/dist/cjs/client/useLocaleStorage.cjs +1 -2
- package/dist/cjs/client/usePathname.cjs +1 -2
- package/dist/cjs/client/useTraduction.cjs +3 -4
- package/dist/cjs/editor/ContentSelector.cjs +2 -3
- package/dist/cjs/editor/EditorProvider.cjs +2 -3
- package/dist/cjs/editor/useEditor.cjs +3 -4
- package/dist/cjs/format/index.cjs +9 -9
- package/dist/cjs/format/useCompact.cjs +2 -3
- package/dist/cjs/format/useCurrency.cjs +2 -3
- package/dist/cjs/format/useDate.cjs +2 -3
- package/dist/cjs/format/useIntl.cjs +2 -3
- package/dist/cjs/format/useList.cjs +2 -3
- package/dist/cjs/format/useNumber.cjs +2 -3
- package/dist/cjs/format/usePercentage.cjs +2 -3
- package/dist/cjs/format/useRelativeTime.cjs +2 -3
- package/dist/cjs/format/useUnit.cjs +2 -3
- package/dist/cjs/getDictionary.cjs +2 -3
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +2 -3
- package/dist/cjs/html/HTMLProvider.cjs +2 -3
- package/dist/cjs/html/HTMLRenderer.cjs +3 -4
- package/dist/cjs/html/index.cjs +2 -2
- package/dist/cjs/index.cjs +17 -17
- package/dist/cjs/markdown/MarkdownProvider.cjs +3 -4
- package/dist/cjs/markdown/MarkdownRenderer.cjs +3 -4
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +4 -5
- package/dist/cjs/markdown/compiler.cjs +2 -3
- package/dist/cjs/markdown/index.cjs +3 -3
- package/dist/cjs/markdown/runtime.cjs +1 -2
- package/dist/cjs/plugins.cjs +10 -11
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/preactElement/renderPreactElement.cjs +1 -2
- package/dist/esm/IntlayerNode.mjs +1 -2
- package/dist/esm/UI/ContentSelector.mjs +1 -2
- package/dist/esm/analytics/AnalyticsProvider.mjs +1 -2
- package/dist/esm/analytics/exposureSink.mjs +1 -2
- package/dist/esm/analytics/index.mjs +1 -1
- package/dist/esm/analytics/useAnalytics.mjs +3 -4
- package/dist/esm/analytics/useConversion.mjs +2 -3
- package/dist/esm/analytics/useExperiment.mjs +2 -3
- package/dist/esm/client/IntlayerProvider.mjs +5 -6
- package/dist/esm/client/index.mjs +2 -2
- package/dist/esm/client/t.mjs +2 -3
- package/dist/esm/client/useContent.mjs +1 -2
- package/dist/esm/client/useDictionary.mjs +1 -2
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +2 -3
- package/dist/esm/client/useDictionaryDynamic.mjs +2 -3
- package/dist/esm/client/useIntlayer.mjs +1 -2
- package/dist/esm/client/useLoadDynamic.mjs +1 -2
- package/dist/esm/client/useLocale.mjs +3 -4
- package/dist/esm/client/useLocaleBase.mjs +2 -3
- package/dist/esm/client/useLocaleStorage.mjs +1 -2
- package/dist/esm/client/usePathname.mjs +1 -2
- package/dist/esm/client/useTraduction.mjs +2 -3
- package/dist/esm/editor/ContentSelector.mjs +2 -3
- package/dist/esm/editor/EditorProvider.mjs +1 -2
- package/dist/esm/editor/useEditor.mjs +2 -3
- package/dist/esm/format/index.mjs +5 -5
- package/dist/esm/format/useCompact.mjs +1 -2
- package/dist/esm/format/useCurrency.mjs +1 -2
- package/dist/esm/format/useDate.mjs +1 -2
- package/dist/esm/format/useIntl.mjs +1 -2
- package/dist/esm/format/useList.mjs +1 -2
- package/dist/esm/format/useNumber.mjs +1 -2
- package/dist/esm/format/usePercentage.mjs +1 -2
- package/dist/esm/format/useRelativeTime.mjs +1 -2
- package/dist/esm/format/useUnit.mjs +1 -2
- package/dist/esm/getDictionary.mjs +1 -2
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +1 -2
- package/dist/esm/html/HTMLProvider.mjs +2 -3
- package/dist/esm/html/HTMLRenderer.mjs +2 -3
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/markdown/MarkdownProvider.mjs +2 -3
- package/dist/esm/markdown/MarkdownRenderer.mjs +1 -2
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs +2 -3
- package/dist/esm/markdown/compiler.mjs +1 -2
- package/dist/esm/markdown/runtime.mjs +1 -2
- package/dist/esm/plugins.mjs +5 -6
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/preactElement/renderPreactElement.mjs +1 -2
- package/dist/types/IntlayerNode.d.ts +2 -3
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts +1 -2
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/analytics/AnalyticsProvider.d.ts +0 -2
- package/dist/types/analytics/AnalyticsProvider.d.ts.map +1 -1
- package/dist/types/analytics/exposureSink.d.ts +0 -2
- package/dist/types/analytics/exposureSink.d.ts.map +1 -1
- package/dist/types/analytics/useAnalytics.d.ts +0 -2
- package/dist/types/analytics/useAnalytics.d.ts.map +1 -1
- package/dist/types/analytics/useConversion.d.ts +0 -2
- package/dist/types/analytics/useConversion.d.ts.map +1 -1
- package/dist/types/analytics/useExperiment.d.ts +0 -2
- package/dist/types/analytics/useExperiment.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +1 -2
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/t.d.ts +0 -2
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +0 -2
- package/dist/types/client/useContent.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +0 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +0 -2
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +0 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +0 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts +0 -2
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +1 -2
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +0 -2
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +0 -2
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/client/usePathname.d.ts +0 -2
- package/dist/types/client/usePathname.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts +0 -2
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelector.d.ts +0 -2
- package/dist/types/editor/ContentSelector.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.d.ts +0 -2
- package/dist/types/editor/EditorProvider.d.ts.map +1 -1
- package/dist/types/editor/useEditor.d.ts +0 -2
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +0 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +0 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +0 -2
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useIntl.d.ts +0 -2
- package/dist/types/format/useIntl.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +0 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +0 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +0 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +0 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +0 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +0 -2
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +0 -2
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/html/HTMLProvider.d.ts +1 -2
- package/dist/types/html/HTMLProvider.d.ts.map +1 -1
- package/dist/types/html/HTMLRenderer.d.ts +0 -2
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
- package/dist/types/html/index.d.ts +1 -1
- package/dist/types/html/types.d.ts +1 -2
- package/dist/types/html/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +1 -2
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +0 -2
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts +1 -2
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts +3 -2
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/markdown/runtime.d.ts +3 -2
- package/dist/types/markdown/runtime.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +3 -5
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/preactElement/renderPreactElement.d.ts +0 -2
- package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
- package/package.json +50 -50
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useAnalytics } from "./useAnalytics.mjs";
|
|
2
2
|
import { Fragment, jsx } from "preact/jsx-runtime";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/analytics/AnalyticsProvider.tsx
|
|
5
5
|
/**
|
|
6
6
|
* Runs {@link useAnalytics} and renders its children unchanged. Mounted inside
|
|
7
7
|
* {@link IntlayerProvider} alongside `EditorProvider`.
|
|
@@ -11,6 +11,5 @@ const AnalyticsProvider = ({ children }) => {
|
|
|
11
11
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
14
|
export { AnalyticsProvider };
|
|
16
15
|
//# sourceMappingURL=AnalyticsProvider.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/analytics/exposureSink.ts
|
|
2
2
|
let sink = null;
|
|
3
3
|
/**
|
|
4
4
|
* Installs (or clears) the exposure sink. `useAnalytics` sets this once the
|
|
@@ -19,6 +19,5 @@ const reportExposure = (input) => {
|
|
|
19
19
|
sink?.(input);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
//#endregion
|
|
23
22
|
export { reportExposure, setExposureSink };
|
|
24
23
|
//# sourceMappingURL=exposureSink.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useAnalytics } from "./useAnalytics.mjs";
|
|
2
1
|
import { AnalyticsProvider } from "./AnalyticsProvider.mjs";
|
|
2
|
+
import { useAnalytics } from "./useAnalytics.mjs";
|
|
3
3
|
import { useConversion } from "./useConversion.mjs";
|
|
4
4
|
import { useExperiment } from "./useExperiment.mjs";
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { setExposureSink } from "./exposureSink.mjs";
|
|
2
1
|
import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { setExposureSink } from "./exposureSink.mjs";
|
|
4
3
|
import { isEnabled } from "@intlayer/analytics/isEnabled";
|
|
4
|
+
import { useContext, useEffect, useRef } from "preact/hooks";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/analytics/useAnalytics.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Initializes the Intlayer analytics client singleton when analytics is enabled
|
|
9
9
|
* and keeps it aware of the current locale.
|
|
@@ -46,6 +46,5 @@ const useAnalytics = () => {
|
|
|
46
46
|
}, [locale]);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
//#endregion
|
|
50
49
|
export { useAnalytics };
|
|
51
50
|
//# sourceMappingURL=useAnalytics.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useCallback } from "preact/hooks";
|
|
2
1
|
import { isEnabled } from "@intlayer/analytics/isEnabled";
|
|
2
|
+
import { useCallback } from "preact/hooks";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/analytics/useConversion.ts
|
|
5
5
|
/**
|
|
6
6
|
* Returns a stable `trackConversion` callback for content A/B testing. Safe to
|
|
7
7
|
* call from any component: it resolves to a no-op when analytics is disabled
|
|
@@ -24,6 +24,5 @@ const useConversion = () => {
|
|
|
24
24
|
}, []);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
//#endregion
|
|
28
27
|
export { useConversion };
|
|
29
28
|
//# sourceMappingURL=useConversion.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useEffect, useState } from "preact/hooks";
|
|
2
1
|
import { isEnabled } from "@intlayer/analytics/isEnabled";
|
|
2
|
+
import { useEffect, useState } from "preact/hooks";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/analytics/useExperiment.ts
|
|
5
5
|
/**
|
|
6
6
|
* Assigns this session to a variant of an A/B experiment and records the
|
|
7
7
|
* exposure, scoped to `experimentKey`, so the backend can compute per-variant
|
|
@@ -57,6 +57,5 @@ const useExperiment = (experimentKey, variants, weights) => {
|
|
|
57
57
|
return state;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
//#endregion
|
|
61
60
|
export { useExperiment };
|
|
62
61
|
//# sourceMappingURL=useExperiment.mjs.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { AnalyticsProvider } from "../analytics/AnalyticsProvider.mjs";
|
|
1
2
|
import { EditorProvider } from "../editor/EditorProvider.mjs";
|
|
2
3
|
import { getLocaleInStorage, setLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
3
|
-
import { AnalyticsProvider } from "../analytics/AnalyticsProvider.mjs";
|
|
4
|
-
import { internationalization } from "@intlayer/config/built";
|
|
5
|
-
import { createContext } from "preact";
|
|
6
4
|
import { useCallback, useContext, useEffect, useMemo, useState } from "preact/hooks";
|
|
7
|
-
import {
|
|
5
|
+
import { internationalization } from "@intlayer/config/built";
|
|
8
6
|
import { setIntlayerIdentifier } from "@intlayer/config/client";
|
|
9
7
|
import { localeResolver } from "@intlayer/core/localization";
|
|
8
|
+
import { createContext } from "preact";
|
|
9
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// src/client/IntlayerProvider.tsx
|
|
12
12
|
/**
|
|
13
13
|
* Context that store the current locale on the client side
|
|
14
14
|
*/
|
|
@@ -92,6 +92,5 @@ const IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ jsxs(Intlay
|
|
|
92
92
|
]
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
//#endregion
|
|
96
95
|
export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext };
|
|
97
96
|
//# sourceMappingURL=IntlayerProvider.mjs.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./useLocaleStorage.mjs";
|
|
2
1
|
import { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext } from "./IntlayerProvider.mjs";
|
|
3
2
|
import { t } from "./t.mjs";
|
|
4
3
|
import { useDictionary } from "./useDictionary.mjs";
|
|
5
4
|
import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
|
|
6
|
-
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
7
5
|
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
8
6
|
import { useIntlayer } from "./useIntlayer.mjs";
|
|
7
|
+
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
9
8
|
import { useLocale } from "./useLocale.mjs";
|
|
10
9
|
import { useLocaleBase } from "./useLocaleBase.mjs";
|
|
10
|
+
import { localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./useLocaleStorage.mjs";
|
|
11
11
|
import { usePathname } from "./usePathname.mjs";
|
|
12
12
|
|
|
13
13
|
export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useIntlayerContext, useLoadDynamic, useLocale, useLocaleBase, useLocaleCookie, useLocaleStorage, usePathname };
|
package/dist/esm/client/t.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
2
|
-
import { getTranslation } from "@intlayer/core/interpreter";
|
|
3
2
|
import { useContext } from "preact/hooks";
|
|
3
|
+
import { getTranslation } from "@intlayer/core/interpreter";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/client/t.ts
|
|
6
6
|
/**
|
|
7
7
|
* On the client side, this function returns the translation of the provided multilang content.
|
|
8
8
|
*
|
|
@@ -13,6 +13,5 @@ const t = (multilangContent, locale) => {
|
|
|
13
13
|
return getTranslation(multilangContent, locale ?? currentLocale);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
16
|
export { t };
|
|
18
17
|
//# sourceMappingURL=t.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useLocaleBase } from "./useLocaleBase.mjs";
|
|
2
2
|
import { useTranslation } from "./useTraduction.mjs";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/client/useContent.ts
|
|
5
5
|
/**
|
|
6
6
|
* On the client side, hook to get the translation content based on the locale
|
|
7
7
|
*/
|
|
@@ -14,6 +14,5 @@ const useContent = (languageContent) => {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
//#endregion
|
|
18
17
|
export { useContent };
|
|
19
18
|
//# sourceMappingURL=useContent.mjs.map
|
|
@@ -3,7 +3,7 @@ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
|
3
3
|
import { useContext, useMemo } from "preact/hooks";
|
|
4
4
|
import { getDictionarySelectorCacheKey, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/client/useDictionary.ts
|
|
7
7
|
/**
|
|
8
8
|
* Preact hook that transforms a dictionary (or qualified dictionary group) and
|
|
9
9
|
* returns the content.
|
|
@@ -23,6 +23,5 @@ const useDictionary = (dictionary, localeOrSelector) => {
|
|
|
23
23
|
return useMemo(() => getDictionary(dictionary, argument), [dictionary.key, argumentIdentity]);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
//#endregion
|
|
27
26
|
export { useDictionary };
|
|
28
27
|
//# sourceMappingURL=useDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Preact hook that transforms a dictionary (or qualified dictionary group) and\n * returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Preact hook that transforms a dictionary (or qualified dictionary group) and\n * returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelectorForGroup<T> =\n DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // This is the seam the build-time optimize transform lands on: it rewrites\n // `useIntlayer('key', selector)` into `useDictionary(dict, selector)`, so an\n // ambient variant has to be applied here to survive the rewrite.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof argument === 'object' &&\n argument !== null\n ? `${argument.locale ?? ''}|${getDictionarySelectorCacheKey(argument)}`\n : argument;\n\n return useMemo(\n () => getDictionary<T, A>(dictionary, argument as A),\n [dictionary.key, argumentIdentity]\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAa,iBAKX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,mBACtC,WAAW,qBAAqB,KAAK,CAAC;CAMxC,MAAM,WACJ,QAAQ,IAAI,iCAAiC,UACzC,0BAA0B;EACxB;EACA,eAAe;EACf;EACA,eAAe,WAAW;CAC5B,CAAC,IACA,oBAAoB;CAK3B,MAAM,mBACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,aAAa,YACpB,aAAa,OACT,GAAG,SAAS,UAAU,GAAG,GAAG,8BAA8B,QAAQ,MAClE;CAEN,OAAO,cACC,cAAoB,YAAY,QAAa,GACnD,CAAC,WAAW,KAAK,gBAAgB,CACnC;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
2
2
|
import { useDictionary } from "./useDictionary.mjs";
|
|
3
|
-
import { resolveInterpreterLocale } from "@intlayer/core/interpreter";
|
|
4
3
|
import { useContext, useMemo } from "preact/hooks";
|
|
4
|
+
import { resolveInterpreterLocale } from "@intlayer/core/interpreter";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/client/useDictionaryAsync.ts
|
|
7
7
|
/**
|
|
8
8
|
* On the server side, Hook that transform a dictionary and return the content
|
|
9
9
|
*
|
|
@@ -16,6 +16,5 @@ const useDictionaryAsync = async (dictionaryPromise, locale) => {
|
|
|
16
16
|
return useDictionary(dictionary, localeTarget);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
//#endregion
|
|
20
19
|
export { useDictionaryAsync };
|
|
21
20
|
//# sourceMappingURL=useDictionaryAsync.mjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getDictionary as getDictionary$1 } from "../getDictionary.mjs";
|
|
2
2
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
3
3
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
4
|
-
import { resolveInterpreterLocale } from "@intlayer/core/interpreter";
|
|
5
4
|
import { useContext } from "preact/hooks";
|
|
5
|
+
import { resolveInterpreterLocale } from "@intlayer/core/interpreter";
|
|
6
6
|
import { getPreloadedDictionary, isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveDictionaryArgument, resolveQualifiedDynamicContent } from "@intlayer/core/dictionaryManipulator";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/client/useDictionaryDynamic.ts
|
|
9
9
|
/**
|
|
10
10
|
* Preact hook that lazily loads a dictionary and returns its content.
|
|
11
11
|
*
|
|
@@ -44,6 +44,5 @@ const useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
|
|
|
44
44
|
return getDictionary$1(dictionary, localeTarget);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
//#endregion
|
|
48
47
|
export { useDictionaryDynamic };
|
|
49
48
|
//# sourceMappingURL=useDictionaryDynamic.mjs.map
|
|
@@ -3,7 +3,7 @@ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
|
3
3
|
import { useContext, useMemo } from "preact/hooks";
|
|
4
4
|
import { getDictionarySelectorCacheKey, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/client/useIntlayer.ts
|
|
7
7
|
/**
|
|
8
8
|
* Preact hook that picks one dictionary by its key and returns its content.
|
|
9
9
|
*
|
|
@@ -40,6 +40,5 @@ const useIntlayer = (key, localeOrSelector) => {
|
|
|
40
40
|
return useMemo(() => getIntlayer(key, argument), [key, argumentIdentity]);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
//#endregion
|
|
44
43
|
export { useIntlayer };
|
|
45
44
|
//# sourceMappingURL=useIntlayer.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/client/useLoadDynamic.ts
|
|
2
2
|
const createSuspender = (promise) => {
|
|
3
3
|
let status = "pending";
|
|
4
4
|
let result;
|
|
@@ -21,6 +21,5 @@ const useLoadDynamic = (key, promise) => {
|
|
|
21
21
|
return cache.get(key).read();
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
//#endregion
|
|
25
24
|
export { useLoadDynamic };
|
|
26
25
|
//# sourceMappingURL=useLoadDynamic.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { setLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
2
1
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { setLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
4
3
|
import { useContext } from "preact/hooks";
|
|
4
|
+
import { internationalization } from "@intlayer/config/built";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/client/useLocale.ts
|
|
7
7
|
const { defaultLocale, locales: availableLocales } = internationalization ?? {};
|
|
8
8
|
/**
|
|
9
9
|
* Preact hook to get the current locale and related locale management functions.
|
|
@@ -47,6 +47,5 @@ const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
//#endregion
|
|
51
50
|
export { useLocale };
|
|
52
51
|
//# sourceMappingURL=useLocale.mjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { useContext } from "preact/hooks";
|
|
3
|
+
import { internationalization } from "@intlayer/config/built";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/client/useLocaleBase.ts
|
|
6
6
|
const { defaultLocale, locales: availableLocales } = internationalization;
|
|
7
7
|
/**
|
|
8
8
|
* On the client side, hook to get the current locale and all related fields
|
|
@@ -17,6 +17,5 @@ const useLocaleBase = () => {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
//#endregion
|
|
21
20
|
export { useLocaleBase };
|
|
22
21
|
//# sourceMappingURL=useLocaleBase.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from "preact/hooks";
|
|
2
2
|
import { LocaleStorageClient, getCachedLocaleFromStorageClient, getLocaleFromStorageClient, localeStorageOptions, setLocaleInStorageClient } from "@intlayer/core/utils";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/client/useLocaleStorage.ts
|
|
5
5
|
/**
|
|
6
6
|
* Reads the locale persisted in the browser storage (cookie, localStorage…).
|
|
7
7
|
*
|
|
@@ -51,6 +51,5 @@ const useLocaleStorage = (isCookieEnabled) => useMemo(() => LocaleStorageClient(
|
|
|
51
51
|
*/
|
|
52
52
|
const useLocaleCookie = useLocaleStorage;
|
|
53
53
|
|
|
54
|
-
//#endregion
|
|
55
54
|
export { getLocaleInStorage, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage };
|
|
56
55
|
//# sourceMappingURL=useLocaleStorage.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
2
2
|
import { getPathWithoutLocale } from "@intlayer/core/localization";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/client/usePathname.ts
|
|
5
5
|
/**
|
|
6
6
|
* Preact hook that returns the current pathname with the locale segment removed.
|
|
7
7
|
*
|
|
@@ -32,6 +32,5 @@ const usePathname = () => {
|
|
|
32
32
|
return useMemo(() => getPathWithoutLocale(rawPathname), [rawPathname]);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { usePathname };
|
|
37
36
|
//# sourceMappingURL=usePathname.mjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
2
|
-
import { getTranslation } from "@intlayer/core/interpreter";
|
|
3
2
|
import { useContext, useMemo } from "preact/hooks";
|
|
3
|
+
import { getTranslation } from "@intlayer/core/interpreter";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/client/useTraduction.ts
|
|
6
6
|
/**
|
|
7
7
|
* On the client side, Hook that picking one dictionary by its id and return the content.
|
|
8
8
|
*
|
|
@@ -29,6 +29,5 @@ const useTranslation = (languageContent) => {
|
|
|
29
29
|
return useMemo(() => getTranslation(languageContent, locale), [languageContent, locale]);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
//#endregion
|
|
33
32
|
export { useTranslation };
|
|
34
33
|
//# sourceMappingURL=useTraduction.mjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
2
1
|
import { useEffect } from "preact/hooks";
|
|
2
|
+
import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
3
3
|
import { jsx } from "preact/jsx-runtime";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/editor/ContentSelector.tsx
|
|
6
6
|
const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !isEnabled || typeof window === "undefined") return;
|
|
@@ -18,6 +18,5 @@ const ContentSelector = ({ children, dictionaryKey, keyPath }) => {
|
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
//#endregion
|
|
22
21
|
export { ContentSelector };
|
|
23
22
|
//# sourceMappingURL=ContentSelector.mjs.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { useEditor } from "./useEditor.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/editor/EditorProvider.tsx
|
|
4
4
|
const EditorProvider = ({ children }) => {
|
|
5
5
|
useEditor();
|
|
6
6
|
return children;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
//#endregion
|
|
10
9
|
export { EditorProvider };
|
|
11
10
|
//# sourceMappingURL=EditorProvider.mjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
2
|
-
import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
3
2
|
import { useContext, useEffect, useRef } from "preact/hooks";
|
|
3
|
+
import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/editor/useEditor.tsx
|
|
6
6
|
/**
|
|
7
7
|
* Initialises the Intlayer editor client singleton when the editor is enabled.
|
|
8
8
|
* Syncs the current locale from the Intlayer context into the editor manager so
|
|
@@ -39,6 +39,5 @@ const useEditor = () => {
|
|
|
39
39
|
}, [locale]);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
//#endregion
|
|
43
42
|
export { useEditor };
|
|
44
43
|
//# sourceMappingURL=useEditor.mjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { usePercentage } from "./usePercentage.mjs";
|
|
2
|
-
import { useUnit } from "./useUnit.mjs";
|
|
3
1
|
import { useCompact } from "./useCompact.mjs";
|
|
4
|
-
import { useNumber } from "./useNumber.mjs";
|
|
5
|
-
import { useIntl } from "./useIntl.mjs";
|
|
6
|
-
import { useList } from "./useList.mjs";
|
|
7
2
|
import { useCurrency } from "./useCurrency.mjs";
|
|
8
3
|
import { useDate } from "./useDate.mjs";
|
|
4
|
+
import { useIntl } from "./useIntl.mjs";
|
|
5
|
+
import { useList } from "./useList.mjs";
|
|
6
|
+
import { useNumber } from "./useNumber.mjs";
|
|
7
|
+
import { usePercentage } from "./usePercentage.mjs";
|
|
9
8
|
import { useRelativeTime } from "./useRelativeTime.mjs";
|
|
9
|
+
import { useUnit } from "./useUnit.mjs";
|
|
10
10
|
|
|
11
11
|
export { useCompact, useCurrency, useDate, useIntl, useList, useNumber, usePercentage, useRelativeTime, useUnit };
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useCallback, useContext } from "preact/hooks";
|
|
3
3
|
import { compact } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useCompact.ts
|
|
6
6
|
/**
|
|
7
7
|
* React client hook that provides a compact number formatter
|
|
8
8
|
* bound to the current application locale.
|
|
@@ -21,6 +21,5 @@ const useCompact = () => {
|
|
|
21
21
|
}), [locale]);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
//#endregion
|
|
25
24
|
export { useCompact };
|
|
26
25
|
//# sourceMappingURL=useCompact.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useCallback, useContext } from "preact/hooks";
|
|
3
3
|
import { currency } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useCurrency.ts
|
|
6
6
|
/**
|
|
7
7
|
* React client hook that provides a currency formatter
|
|
8
8
|
* bound to the current application locale.
|
|
@@ -35,6 +35,5 @@ const useCurrency = () => {
|
|
|
35
35
|
}), [locale]);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
//#endregion
|
|
39
38
|
export { useCurrency };
|
|
40
39
|
//# sourceMappingURL=useCurrency.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useContext } from "preact/hooks";
|
|
3
3
|
import { date } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useDate.ts
|
|
6
6
|
/**
|
|
7
7
|
* React client hook that provides a localized date/time formatter
|
|
8
8
|
* bound to the current application locale.
|
|
@@ -37,6 +37,5 @@ const useDate = () => {
|
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
//#endregion
|
|
41
40
|
export { useDate };
|
|
42
41
|
//# sourceMappingURL=useDate.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useContext, useMemo } from "preact/hooks";
|
|
3
3
|
import { bindIntl } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useIntl.ts
|
|
6
6
|
/**
|
|
7
7
|
* Preact client hook that provides a locale-bound `Intl` object.
|
|
8
8
|
*
|
|
@@ -27,6 +27,5 @@ const useIntl = (locale) => {
|
|
|
27
27
|
return useMemo(() => bindIntl(currentLocale), [currentLocale]);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
//#endregion
|
|
31
30
|
export { useIntl };
|
|
32
31
|
//# sourceMappingURL=useIntl.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useCallback, useContext } from "preact/hooks";
|
|
3
3
|
import { list } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useList.ts
|
|
6
6
|
/**
|
|
7
7
|
* React client hook that provides a list formatter
|
|
8
8
|
* bound to the current application locale.
|
|
@@ -32,6 +32,5 @@ const useList = () => {
|
|
|
32
32
|
}), [locale]);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { useList };
|
|
37
36
|
//# sourceMappingURL=useList.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useCallback, useContext } from "preact/hooks";
|
|
3
3
|
import { number } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useNumber.ts
|
|
6
6
|
/**
|
|
7
7
|
* React client hook that provides a localized number formatter.
|
|
8
8
|
*
|
|
@@ -33,6 +33,5 @@ const useNumber = () => {
|
|
|
33
33
|
}), [locale]);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
//#endregion
|
|
37
36
|
export { useNumber };
|
|
38
37
|
//# sourceMappingURL=useNumber.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useCallback, useContext } from "preact/hooks";
|
|
3
3
|
import { percentage } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/usePercentage.ts
|
|
6
6
|
/**
|
|
7
7
|
* React hook to provide a percentage formatter function
|
|
8
8
|
* based on the current application locale.
|
|
@@ -29,6 +29,5 @@ const usePercentage = () => {
|
|
|
29
29
|
}), [locale]);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
//#endregion
|
|
33
32
|
export { usePercentage };
|
|
34
33
|
//# sourceMappingURL=usePercentage.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useCallback, useContext } from "preact/hooks";
|
|
3
3
|
import { relativeTime } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useRelativeTime.ts
|
|
6
6
|
/**
|
|
7
7
|
* Client-side React hook for accessing a localized relative time formatter.
|
|
8
8
|
*
|
|
@@ -29,6 +29,5 @@ const useRelativeTime = () => {
|
|
|
29
29
|
}), [locale]);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
//#endregion
|
|
33
32
|
export { useRelativeTime };
|
|
34
33
|
//# sourceMappingURL=useRelativeTime.mjs.map
|
|
@@ -2,7 +2,7 @@ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
|
|
|
2
2
|
import { useCallback, useContext } from "preact/hooks";
|
|
3
3
|
import { units } from "@intlayer/core/formatters";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/format/useUnit.ts
|
|
6
6
|
/**
|
|
7
7
|
* React hook that provides a unit formatting function
|
|
8
8
|
* based on the current locale from {@link useLocaleBase}.
|
|
@@ -28,6 +28,5 @@ const useUnit = () => {
|
|
|
28
28
|
}), [locale]);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
//#endregion
|
|
32
31
|
export { useUnit };
|
|
33
32
|
//# sourceMappingURL=useUnit.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getPlugins } from "./plugins.mjs";
|
|
2
2
|
import { getDictionary as getDictionary$1 } from "@intlayer/core/interpreter";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/getDictionary.ts
|
|
5
5
|
/**
|
|
6
6
|
* Transforms a dictionary (or qualified dictionary group) and returns its
|
|
7
7
|
* content for the given locale or selector (`{ item }`, `{ variant }`,
|
|
@@ -12,6 +12,5 @@ const getDictionary = (dictionary, localeOrSelector) => {
|
|
|
12
12
|
return getDictionary$1(dictionary, localeOrSelector, getPlugins(locale));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
//#endregion
|
|
16
15
|
export { getDictionary };
|
|
17
16
|
//# sourceMappingURL=getDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Transforms a dictionary (or qualified dictionary group) and returns its\n * content for the given locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends
|
|
1
|
+
{"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\n/**\n * Transforms a dictionary (or qualified dictionary group) and returns its\n * content for the given locale or selector (`{ item }`, `{ variant }`,\n * optionally combined with `locale`).\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelectorForGroup<T> =\n DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const locale = (\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector.locale\n : localeOrSelector\n ) as LocalesValues | undefined;\n\n return getDictionaryCore(\n dictionary,\n localeOrSelector,\n getPlugins(locale)\n ) as any;\n};\n"],"mappings":";;;;;;;;;AAmBA,MAAa,iBAKX,YACA,qBAIG;CACH,MAAM,SACJ,OAAO,qBAAqB,YAAY,qBAAqB,OACzD,iBAAiB,SACjB;CAGN,OAAOA,gBACL,YACA,kBACA,WAAW,MAAM,CACnB;AACF"}
|
package/dist/esm/getIntlayer.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getPlugins } from "./plugins.mjs";
|
|
2
2
|
import { getIntlayer as getIntlayer$1 } from "@intlayer/core/interpreter";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/getIntlayer.ts
|
|
5
5
|
/**
|
|
6
6
|
* Picks one dictionary by its key and returns its content for the given
|
|
7
7
|
* locale or selector (`{ item }`, `{ variant }`,
|
|
@@ -12,6 +12,5 @@ const getIntlayer = (key, localeOrSelector) => {
|
|
|
12
12
|
return getIntlayer$1(key, localeOrSelector, getPlugins(locale));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
//#endregion
|
|
16
15
|
export { getIntlayer };
|
|
17
16
|
//# sourceMappingURL=getIntlayer.mjs.map
|