@beinformed/ui 1.67.0 → 1.67.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/CHANGELOG.md +15 -0
- package/esm/hooks/index.js +3 -0
- package/esm/hooks/index.js.flow +3 -0
- package/esm/hooks/index.js.map +1 -1
- 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/index.js +33 -0
- package/lib/hooks/index.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,21 @@
|
|
|
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.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.67.0...v1.67.2) (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
|
+
* **index:** export new hooks ([e7aa504](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/e7aa504757217be747620732d3b9d46197724b41))
|
|
12
|
+
|
|
13
|
+
## [1.67.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.67.0...v1.67.1) (2026-02-16)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **hooks:** add hook to retrieve Locales ([46a77c3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/46a77c3cd6272e9a1fa972f703dc135a453c35e9))
|
|
19
|
+
|
|
5
20
|
## [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
21
|
|
|
7
22
|
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./useAllFormsOnModel";
|
|
2
2
|
export * from "./useAuthentication";
|
|
3
3
|
export * from "./useContent";
|
|
4
|
+
export * from "./useDeepCompareEffect";
|
|
5
|
+
export * from "./useErrorHandler";
|
|
4
6
|
export * from "./useForm";
|
|
5
7
|
export * from "./useI18n";
|
|
6
8
|
export * from "./useList";
|
|
@@ -11,6 +13,7 @@ export * from "./useModels";
|
|
|
11
13
|
export * from "./useModelSelectors";
|
|
12
14
|
export * from "./useModularUI";
|
|
13
15
|
export * from "./useModularUIBasic";
|
|
16
|
+
export * from "./useModularUIKey";
|
|
14
17
|
export * from "./useModularUIModel";
|
|
15
18
|
export * from "./useModularUIRequest";
|
|
16
19
|
export * from "./useNotification";
|
package/esm/hooks/index.js.flow
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export * from "./useAllFormsOnModel";
|
|
3
3
|
export * from "./useAuthentication";
|
|
4
4
|
export * from "./useContent";
|
|
5
|
+
export * from "./useDeepCompareEffect";
|
|
6
|
+
export * from "./useErrorHandler";
|
|
5
7
|
export * from "./useForm";
|
|
6
8
|
export * from "./useI18n";
|
|
7
9
|
export * from "./useList";
|
|
@@ -12,6 +14,7 @@ export * from "./useModels";
|
|
|
12
14
|
export * from "./useModelSelectors";
|
|
13
15
|
export * from "./useModularUI";
|
|
14
16
|
export * from "./useModularUIBasic";
|
|
17
|
+
export * from "./useModularUIKey";
|
|
15
18
|
export * from "./useModularUIModel";
|
|
16
19
|
export * from "./useModularUIRequest";
|
|
17
20
|
export * from "./useNotification";
|
package/esm/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAllFormsOnModel\";\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useLookup\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModelSelectors\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useSearch\";\n"],"mappings":"AACA,cAAc,sBAAsB;AACpC,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,YAAY;AAC1B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,aAAa;AAC3B,cAAc,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAllFormsOnModel\";\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useDeepCompareEffect\";\nexport * from \"./useErrorHandler\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useLookup\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModelSelectors\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIKey\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useSearch\";\n"],"mappings":"AACA,cAAc,sBAAsB;AACpC,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,wBAAwB;AACtC,cAAc,mBAAmB;AACjC,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,qBAAqB;AACnC,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,YAAY;AAC1B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,aAAa;AAC3B,cAAc,aAAa","ignoreList":[]}
|
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,QAAQ,4BAA4B;AAIzD,MAAMC,UAAU,GAAGL,cAAc,CAC/B,CAACE,UAAU,EAAEC,SAAS,CAAC,EACvB,CAACG,OAAO,EAAEC,UAAU,KAClBN,OAAO,CACL,CAACO,EAAU,EAAEC,cAAu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|
@@ -37,6 +37,28 @@ _Object$keys(_useContent).forEach(function (key) {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
+
var _useDeepCompareEffect = require("./useDeepCompareEffect");
|
|
41
|
+
_Object$keys(_useDeepCompareEffect).forEach(function (key) {
|
|
42
|
+
if (key === "default" || key === "__esModule") return;
|
|
43
|
+
if (key in exports && exports[key] === _useDeepCompareEffect[key]) return;
|
|
44
|
+
Object.defineProperty(exports, key, {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _useDeepCompareEffect[key];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
var _useErrorHandler = require("./useErrorHandler");
|
|
52
|
+
_Object$keys(_useErrorHandler).forEach(function (key) {
|
|
53
|
+
if (key === "default" || key === "__esModule") return;
|
|
54
|
+
if (key in exports && exports[key] === _useErrorHandler[key]) return;
|
|
55
|
+
Object.defineProperty(exports, key, {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _useErrorHandler[key];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
40
62
|
var _useForm = require("./useForm");
|
|
41
63
|
_Object$keys(_useForm).forEach(function (key) {
|
|
42
64
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -147,6 +169,17 @@ _Object$keys(_useModularUIBasic).forEach(function (key) {
|
|
|
147
169
|
}
|
|
148
170
|
});
|
|
149
171
|
});
|
|
172
|
+
var _useModularUIKey = require("./useModularUIKey");
|
|
173
|
+
_Object$keys(_useModularUIKey).forEach(function (key) {
|
|
174
|
+
if (key === "default" || key === "__esModule") return;
|
|
175
|
+
if (key in exports && exports[key] === _useModularUIKey[key]) return;
|
|
176
|
+
Object.defineProperty(exports, key, {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function () {
|
|
179
|
+
return _useModularUIKey[key];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
150
183
|
var _useModularUIModel = require("./useModularUIModel");
|
|
151
184
|
_Object$keys(_useModularUIModel).forEach(function (key) {
|
|
152
185
|
if (key === "default" || key === "__esModule") return;
|
package/lib/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_useAllFormsOnModel","require","_Object$keys","forEach","key","exports","Object","defineProperty","enumerable","get","_useAuthentication","_useContent","_useForm","_useI18n","_useList","_useLookup","_useModal","_useModelCatalog","_useModels","_useModelSelectors","_useModularUI","_useModularUIBasic","_useModularUIModel","_useModularUIRequest","_useNotification","_usePanel","_usePreference","_useProgressIndicator","_useRouter","_useSearch"],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAllFormsOnModel\";\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useLookup\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModelSelectors\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useSearch\";\n"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AAAAC,YAAA,CAAAF,mBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAJ,mBAAA,CAAAI,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,mBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,kBAAA,GAAAT,OAAA;AAAAC,YAAA,CAAAQ,kBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,kBAAA,CAAAN,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,WAAA,GAAAV,OAAA;AAAAC,YAAA,CAAAS,WAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,WAAA,CAAAP,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,WAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_useAllFormsOnModel","require","_Object$keys","forEach","key","exports","Object","defineProperty","enumerable","get","_useAuthentication","_useContent","_useDeepCompareEffect","_useErrorHandler","_useForm","_useI18n","_useList","_useLookup","_useModal","_useModelCatalog","_useModels","_useModelSelectors","_useModularUI","_useModularUIBasic","_useModularUIKey","_useModularUIModel","_useModularUIRequest","_useNotification","_usePanel","_usePreference","_useProgressIndicator","_useRouter","_useSearch"],"sources":["../../src/hooks/index.js"],"sourcesContent":["// @flow\nexport * from \"./useAllFormsOnModel\";\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useDeepCompareEffect\";\nexport * from \"./useErrorHandler\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useList\";\nexport * from \"./useLookup\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModelSelectors\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIKey\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePanel\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useSearch\";\n"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AAAAC,YAAA,CAAAF,mBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAJ,mBAAA,CAAAI,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,mBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,kBAAA,GAAAT,OAAA;AAAAC,YAAA,CAAAQ,kBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,kBAAA,CAAAN,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,WAAA,GAAAV,OAAA;AAAAC,YAAA,CAAAS,WAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,WAAA,CAAAP,GAAA;EAAAE,MAAA,CA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AAD,GAAA,MAAA4B,UAAA,CAAA5B,GAAA;EAAAE,MAAA,CAAAC,cAAA,CAAAF,OAAA,EAAAD,GAAA;IAAAI,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAuB,UAAA,CAAA5B,GAAA;IAAA;EAAA;AAAA","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,WA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