@beinformed/ui 1.67.0 → 1.67.1
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/CHANGELOG.md +7 -0
- package/esm/hooks/useI18n.js +5 -1
- package/esm/hooks/useI18n.js.flow +14 -1
- package/esm/hooks/useI18n.js.map +1 -1
- package/lib/hooks/useI18n.js +6 -1
- package/lib/hooks/useI18n.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.67.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.67.0...v1.67.1) (2026-02-16)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **hooks:** add hook to retrieve Locales ([46a77c3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/46a77c3cd6272e9a1fa972f703dc135a453c35e9))
|
|
11
|
+
|
|
5
12
|
## [1.67.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.29...v1.67.0) (2026-02-14)
|
|
6
13
|
|
|
7
14
|
|
package/esm/hooks/useI18n.js
CHANGED
|
@@ -19,6 +19,10 @@ const useTranslate = () => useSelector(getMessage);
|
|
|
19
19
|
/**
|
|
20
20
|
*/
|
|
21
21
|
const useLocale = () => useSelector(getLocale);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*/
|
|
25
|
+
const useLocales = () => useSelector(getLocales);
|
|
22
26
|
const getLocaleCodes = createSelector(state => state.i18n.locales, locales => _mapInstanceProperty(locales).call(locales, locale => locale.code));
|
|
23
27
|
|
|
24
28
|
/**
|
|
@@ -37,5 +41,5 @@ const useUpdateLocale = () => {
|
|
|
37
41
|
dispatch(updateLocale(locale));
|
|
38
42
|
}, [dispatch]);
|
|
39
43
|
};
|
|
40
|
-
export { useTranslate, useMessage, useLocale, useLocaleCodes, useUpdateLocale };
|
|
44
|
+
export { useTranslate, useMessage, useLocale, useLocales, useLocaleCodes, useUpdateLocale };
|
|
41
45
|
//# sourceMappingURL=useI18n.js.map
|
|
@@ -8,6 +8,8 @@ import memoize from "lodash/memoize";
|
|
|
8
8
|
import { getLocales, getLocale } from "../redux/selectors/i18n";
|
|
9
9
|
import { updateLocale } from "../redux/_i18n/I18nActions";
|
|
10
10
|
|
|
11
|
+
import type Locales from "../i18n/Locales";
|
|
12
|
+
|
|
11
13
|
const getMessage = createSelector(
|
|
12
14
|
[getLocales, getLocale],
|
|
13
15
|
(locales, localeCode) =>
|
|
@@ -36,6 +38,10 @@ const useTranslate = (): ((...any) => any) => useSelector(getMessage);
|
|
|
36
38
|
*/
|
|
37
39
|
const useLocale = (): string => useSelector(getLocale);
|
|
38
40
|
|
|
41
|
+
/**
|
|
42
|
+
*/
|
|
43
|
+
const useLocales = (): Locales => useSelector(getLocales);
|
|
44
|
+
|
|
39
45
|
const getLocaleCodes = createSelector(
|
|
40
46
|
(state) => state.i18n.locales,
|
|
41
47
|
(locales) => locales.map((locale) => locale.code),
|
|
@@ -62,4 +68,11 @@ const useUpdateLocale = (): ((locale: string) => void) => {
|
|
|
62
68
|
);
|
|
63
69
|
};
|
|
64
70
|
|
|
65
|
-
export {
|
|
71
|
+
export {
|
|
72
|
+
useTranslate,
|
|
73
|
+
useMessage,
|
|
74
|
+
useLocale,
|
|
75
|
+
useLocales,
|
|
76
|
+
useLocaleCodes,
|
|
77
|
+
useUpdateLocale,
|
|
78
|
+
};
|
package/esm/hooks/useI18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.js","names":["useCallback","useDispatch","useSelector","createSelector","memoize","getLocales","getLocale","updateLocale","getMessage","locales","localeCode","id","defaultMessage","placeholders","args","_JSON$stringify","useMessage","useTranslate","useLocale","getLocaleCodes","state","i18n","_mapInstanceProperty","call","locale","code","useLocaleCodes","useUpdateLocale","dispatch"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useCallback } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\n\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\nimport { updateLocale } from \"../redux/_i18n/I18nActions\";\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args),\n ),\n);\n\n/**\n */\nconst useMessage = (\n id: string,\n defaultMessage?: string,\n placeholders?: Object | null,\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\n/**\n */\nconst useLocale = (): string => useSelector(getLocale);\n\nconst getLocaleCodes = createSelector(\n (state) => state.i18n.locales,\n (locales) => locales.map((locale) => locale.code),\n);\n\n/**\n * Retrieve all available locale codes\n */\nconst useLocaleCodes = (): Array<string> => useSelector(getLocaleCodes);\n\n/**\n * A hook that returns a memoized function to update the application locale.\n *\n * @returns {(locale: string) => void} A memoized function to update the locale.\n */\nconst useUpdateLocale = (): ((locale: string) => void) => {\n const dispatch = useDispatch();\n\n return useCallback(\n (locale: string) => {\n dispatch(updateLocale(locale));\n },\n [dispatch],\n );\n};\n\nexport {
|
|
1
|
+
{"version":3,"file":"useI18n.js","names":["useCallback","useDispatch","useSelector","createSelector","memoize","getLocales","getLocale","updateLocale","getMessage","locales","localeCode","id","defaultMessage","placeholders","args","_JSON$stringify","useMessage","useTranslate","useLocale","useLocales","getLocaleCodes","state","i18n","_mapInstanceProperty","call","locale","code","useLocaleCodes","useUpdateLocale","dispatch"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useCallback } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\n\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\nimport { updateLocale } from \"../redux/_i18n/I18nActions\";\n\nimport type Locales from \"../i18n/Locales\";\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args),\n ),\n);\n\n/**\n */\nconst useMessage = (\n id: string,\n defaultMessage?: string,\n placeholders?: Object | null,\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\n/**\n */\nconst useLocale = (): string => useSelector(getLocale);\n\n/**\n */\nconst useLocales = (): Locales => useSelector(getLocales);\n\nconst getLocaleCodes = createSelector(\n (state) => state.i18n.locales,\n (locales) => locales.map((locale) => locale.code),\n);\n\n/**\n * Retrieve all available locale codes\n */\nconst useLocaleCodes = (): Array<string> => useSelector(getLocaleCodes);\n\n/**\n * A hook that returns a memoized function to update the application locale.\n *\n * @returns {(locale: string) => void} A memoized function to update the locale.\n */\nconst useUpdateLocale = (): ((locale: string) => void) => {\n const dispatch = useDispatch();\n\n return useCallback(\n (locale: string) => {\n dispatch(updateLocale(locale));\n },\n [dispatch],\n );\n};\n\nexport {\n useTranslate,\n useMessage,\n useLocale,\n useLocales,\n useLocaleCodes,\n useUpdateLocale,\n};\n"],"mappings":";;AACA,SAASA,WAAW,QAAQ,OAAO;AACnC,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,cAAc,QAAQ,UAAU;AAEzC,OAAOC,OAAO,MAAM,gBAAgB;AAEpC,SAASC,UAAU,EAAEC,SAAS,QAAQ,yBAAyB;AAC/D,SAASC,YAAY,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AAC,EACD,CAACI,QAAQ,CACX,CAAC;AACH,CAAC;AAED,SACEZ,YAAY,EACZD,UAAU,EACVE,SAAS,EACTC,UAAU,EACVQ,cAAc,EACdC,eAAe","ignoreList":[]}
|
package/lib/hooks/useI18n.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useUpdateLocale = exports.useTranslate = exports.useMessage = exports.useLocaleCodes = exports.useLocale = void 0;
|
|
7
|
+
exports.useUpdateLocale = exports.useTranslate = exports.useMessage = exports.useLocales = exports.useLocaleCodes = exports.useLocale = void 0;
|
|
8
8
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
9
9
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
10
10
|
var _react = require("react");
|
|
@@ -28,7 +28,12 @@ const useTranslate = () => (0, _reactRedux.useSelector)(getMessage);
|
|
|
28
28
|
*/
|
|
29
29
|
exports.useTranslate = useTranslate;
|
|
30
30
|
const useLocale = () => (0, _reactRedux.useSelector)(_i18n.getLocale);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*/
|
|
31
34
|
exports.useLocale = useLocale;
|
|
35
|
+
const useLocales = () => (0, _reactRedux.useSelector)(_i18n.getLocales);
|
|
36
|
+
exports.useLocales = useLocales;
|
|
32
37
|
const getLocaleCodes = (0, _reselect.createSelector)(state => state.i18n.locales, locales => (0, _map.default)(locales).call(locales, locale => locale.code));
|
|
33
38
|
|
|
34
39
|
/**
|
package/lib/hooks/useI18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.js","names":["_react","require","_reactRedux","_reselect","_memoize","_interopRequireDefault","_i18n","_I18nActions","getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","_stringify","default","useMessage","useSelector","exports","useTranslate","useLocale","getLocaleCodes","state","i18n","_map","call","locale","code","useLocaleCodes","useUpdateLocale","dispatch","useDispatch","useCallback","updateLocale"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useCallback } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\n\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\nimport { updateLocale } from \"../redux/_i18n/I18nActions\";\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args),\n ),\n);\n\n/**\n */\nconst useMessage = (\n id: string,\n defaultMessage?: string,\n placeholders?: Object | null,\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\n/**\n */\nconst useLocale = (): string => useSelector(getLocale);\n\nconst getLocaleCodes = createSelector(\n (state) => state.i18n.locales,\n (locales) => locales.map((locale) => locale.code),\n);\n\n/**\n * Retrieve all available locale codes\n */\nconst useLocaleCodes = (): Array<string> => useSelector(getLocaleCodes);\n\n/**\n * A hook that returns a memoized function to update the application locale.\n *\n * @returns {(locale: string) => void} A memoized function to update the locale.\n */\nconst useUpdateLocale = (): ((locale: string) => void) => {\n const dispatch = useDispatch();\n\n return useCallback(\n (locale: string) => {\n dispatch(updateLocale(locale));\n },\n [dispatch],\n );\n};\n\nexport {
|
|
1
|
+
{"version":3,"file":"useI18n.js","names":["_react","require","_reactRedux","_reselect","_memoize","_interopRequireDefault","_i18n","_I18nActions","getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","_stringify","default","useMessage","useSelector","exports","useTranslate","useLocale","useLocales","getLocaleCodes","state","i18n","_map","call","locale","code","useLocaleCodes","useUpdateLocale","dispatch","useDispatch","useCallback","updateLocale"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useCallback } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\n\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\nimport { updateLocale } from \"../redux/_i18n/I18nActions\";\n\nimport type Locales from \"../i18n/Locales\";\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args),\n ),\n);\n\n/**\n */\nconst useMessage = (\n id: string,\n defaultMessage?: string,\n placeholders?: Object | null,\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\n/**\n */\nconst useLocale = (): string => useSelector(getLocale);\n\n/**\n */\nconst useLocales = (): Locales => useSelector(getLocales);\n\nconst getLocaleCodes = createSelector(\n (state) => state.i18n.locales,\n (locales) => locales.map((locale) => locale.code),\n);\n\n/**\n * Retrieve all available locale codes\n */\nconst useLocaleCodes = (): Array<string> => useSelector(getLocaleCodes);\n\n/**\n * A hook that returns a memoized function to update the application locale.\n *\n * @returns {(locale: string) => void} A memoized function to update the locale.\n */\nconst useUpdateLocale = (): ((locale: string) => void) => {\n const dispatch = useDispatch();\n\n return useCallback(\n (locale: string) => {\n dispatch(updateLocale(locale));\n },\n [dispatch],\n );\n};\n\nexport {\n useTranslate,\n useMessage,\n useLocale,\n useLocales,\n useLocaleCodes,\n useUpdateLocale,\n};\n"],"mappings":";;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,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