@team-monolith/cds 1.129.2-alpha.2 → 1.129.3-alpha

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.
Files changed (128) hide show
  1. package/dist/CdsProvider.js +180 -180
  2. package/dist/components/AlertDialog/AlertDialogTitle.js +15 -15
  3. package/dist/components/Banner.js +28 -28
  4. package/dist/components/FileTypeAlertDialog.js +16 -16
  5. package/dist/components/Pagination.js +22 -22
  6. package/dist/emotion.d.ts +185 -0
  7. package/dist/i18n/i18n.js +14 -14
  8. package/dist/index.d.ts +8 -1
  9. package/dist/node_modules/.pnpm/html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js +78 -0
  10. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/I18nextProvider.js +12 -0
  11. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/Trans.js +26 -0
  12. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/TransWithoutContext.js +174 -0
  13. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/context.js +20 -0
  14. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/defaults.js +24 -0
  15. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/i18nInstance.js +6 -0
  16. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/initReactI18next.js +11 -0
  17. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/unescape.js +25 -0
  18. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/useTranslation.js +69 -0
  19. package/dist/node_modules/.pnpm/react-i18next@15.7.3_i18next@25.5.2_typescript@5.5.4__react-dom@18.2.0_react@18.2.0__react@18.2.0_typescript@5.5.4/node_modules/react-i18next/dist/es/utils.js +35 -0
  20. package/dist/patterns/LexicalEditor/Plugins.js +64 -64
  21. package/dist/patterns/LexicalEditor/components/FileSelectInput.js +19 -19
  22. package/dist/patterns/LexicalEditor/components/InsertImageDialog/ImagePreview.js +6 -6
  23. package/dist/patterns/LexicalEditor/components/InsertImageDialog/InsertImageDialog.js +34 -34
  24. package/dist/patterns/LexicalEditor/components/UploadFileDialog/UploadFileDialog.js +14 -14
  25. package/dist/patterns/LexicalEditor/nodes/FileNode/FileDownloadButton.js +17 -17
  26. package/dist/patterns/LexicalEditor/nodes/ImageNode/ImageComponent.js +62 -62
  27. package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.js +25 -25
  28. package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SettingForm/FormPlaceholder.js +7 -7
  29. package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SettingForm/FormSolution.js +24 -23
  30. package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SettingForm/SettingForm.js +48 -47
  31. package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SettingForm/TextTypeDropdown.js +11 -11
  32. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxView.js +15 -15
  33. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.js +28 -28
  34. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/FormSelection.js +30 -30
  35. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/SettingForm.js +35 -35
  36. package/dist/patterns/LexicalEditor/nodes/SelfEvaluationNode/EvaluationComponent/Evaluation/SettingForm/FormIconAndLabel/FormIconAndLabel.js +21 -21
  37. package/dist/patterns/LexicalEditor/nodes/SelfEvaluationNode/EvaluationComponent/Evaluation/SettingForm/FormIconAndLabel/FormLabel.js +15 -15
  38. package/dist/patterns/LexicalEditor/nodes/SelfEvaluationNode/EvaluationComponent/Evaluation/SettingForm/FormQuestion.js +17 -17
  39. package/dist/patterns/LexicalEditor/nodes/SelfEvaluationNode/EvaluationComponent/Evaluation/SettingForm/SettingForm.js +30 -30
  40. package/dist/patterns/LexicalEditor/nodes/SelfEvaluationNode/EvaluationComponent/EvaluationComponent.js +20 -20
  41. package/dist/patterns/LexicalEditor/nodes/SheetInputNode/InputComponent.js +24 -24
  42. package/dist/patterns/LexicalEditor/nodes/SheetInputNode/SettingForm.js +28 -28
  43. package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/SelectBoxView.js +11 -11
  44. package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectComponent.js +26 -26
  45. package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/FormAllowMultipleAnswers.js +8 -8
  46. package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/FormSelection.js +27 -27
  47. package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/SettingForm.js +33 -33
  48. package/dist/patterns/LexicalEditor/nodes/VideoNode/VideoComponent.js +21 -21
  49. package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/ComponentAdderPlugin.js +99 -99
  50. package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/useContextMenuOptions.js +50 -50
  51. package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js +85 -85
  52. package/dist/patterns/LexicalEditor/plugins/DragDropPastePlugin/index.js +13 -13
  53. package/dist/patterns/LexicalEditor/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +48 -48
  54. package/dist/patterns/LexicalEditor/plugins/ImagesPlugin/useImageNodeTransform.js +16 -16
  55. package/dist/patterns/ToggleButtonGroup/ToggleButton.js +17 -17
  56. package/package.json +15 -18
  57. package/@types/emotion.d.ts +0 -197
  58. package/node_modules/react-i18next/.eslintrc.json +0 -74
  59. package/node_modules/react-i18next/.husky/pre-commit +0 -1
  60. package/node_modules/react-i18next/.prettierignore +0 -4
  61. package/node_modules/react-i18next/CHANGELOG.md +0 -1433
  62. package/node_modules/react-i18next/LICENSE +0 -22
  63. package/node_modules/react-i18next/README.md +0 -181
  64. package/node_modules/react-i18next/TransWithoutContext.d.mts +0 -1
  65. package/node_modules/react-i18next/TransWithoutContext.d.ts +0 -129
  66. package/node_modules/react-i18next/dist/amd/react-i18next.js +0 -867
  67. package/node_modules/react-i18next/dist/amd/react-i18next.min.js +0 -1
  68. package/node_modules/react-i18next/dist/commonjs/I18nextProvider.js +0 -21
  69. package/node_modules/react-i18next/dist/commonjs/Trans.js +0 -54
  70. package/node_modules/react-i18next/dist/commonjs/TransWithoutContext.js +0 -330
  71. package/node_modules/react-i18next/dist/commonjs/Translation.js +0 -19
  72. package/node_modules/react-i18next/dist/commonjs/context.js +0 -81
  73. package/node_modules/react-i18next/dist/commonjs/defaults.js +0 -26
  74. package/node_modules/react-i18next/dist/commonjs/i18nInstance.js +0 -13
  75. package/node_modules/react-i18next/dist/commonjs/index.js +0 -128
  76. package/node_modules/react-i18next/dist/commonjs/initReactI18next.js +0 -15
  77. package/node_modules/react-i18next/dist/commonjs/unescape.js +0 -32
  78. package/node_modules/react-i18next/dist/commonjs/useSSR.js +0 -34
  79. package/node_modules/react-i18next/dist/commonjs/useTranslation.js +0 -114
  80. package/node_modules/react-i18next/dist/commonjs/utils.js +0 -76
  81. package/node_modules/react-i18next/dist/commonjs/withSSR.js +0 -27
  82. package/node_modules/react-i18next/dist/commonjs/withTranslation.js +0 -39
  83. package/node_modules/react-i18next/dist/es/I18nextProvider.js +0 -15
  84. package/node_modules/react-i18next/dist/es/Trans.js +0 -43
  85. package/node_modules/react-i18next/dist/es/TransWithoutContext.js +0 -321
  86. package/node_modules/react-i18next/dist/es/Translation.js +0 -12
  87. package/node_modules/react-i18next/dist/es/context.js +0 -42
  88. package/node_modules/react-i18next/dist/es/defaults.js +0 -18
  89. package/node_modules/react-i18next/dist/es/i18nInstance.js +0 -5
  90. package/node_modules/react-i18next/dist/es/index.js +0 -18
  91. package/node_modules/react-i18next/dist/es/initReactI18next.js +0 -9
  92. package/node_modules/react-i18next/dist/es/package.json +0 -1
  93. package/node_modules/react-i18next/dist/es/unescape.js +0 -25
  94. package/node_modules/react-i18next/dist/es/useSSR.js +0 -27
  95. package/node_modules/react-i18next/dist/es/useTranslation.js +0 -107
  96. package/node_modules/react-i18next/dist/es/utils.js +0 -62
  97. package/node_modules/react-i18next/dist/es/withSSR.js +0 -20
  98. package/node_modules/react-i18next/dist/es/withTranslation.js +0 -32
  99. package/node_modules/react-i18next/dist/umd/react-i18next.js +0 -871
  100. package/node_modules/react-i18next/dist/umd/react-i18next.min.js +0 -1
  101. package/node_modules/react-i18next/helpers.d.ts +0 -3
  102. package/node_modules/react-i18next/icu.macro.d.mts +0 -1
  103. package/node_modules/react-i18next/icu.macro.d.ts +0 -103
  104. package/node_modules/react-i18next/icu.macro.js +0 -729
  105. package/node_modules/react-i18next/index.d.mts +0 -1
  106. package/node_modules/react-i18next/index.d.ts +0 -209
  107. package/node_modules/react-i18next/initReactI18next.d.mts +0 -1
  108. package/node_modules/react-i18next/initReactI18next.d.ts +0 -3
  109. package/node_modules/react-i18next/lint-staged.config.mjs +0 -4
  110. package/node_modules/react-i18next/package.json +0 -167
  111. package/node_modules/react-i18next/react-i18next.js +0 -871
  112. package/node_modules/react-i18next/react-i18next.min.js +0 -1
  113. package/node_modules/react-i18next/src/I18nextProvider.js +0 -7
  114. package/node_modules/react-i18next/src/Trans.js +0 -45
  115. package/node_modules/react-i18next/src/TransWithoutContext.js +0 -479
  116. package/node_modules/react-i18next/src/Translation.js +0 -14
  117. package/node_modules/react-i18next/src/context.js +0 -54
  118. package/node_modules/react-i18next/src/defaults.js +0 -20
  119. package/node_modules/react-i18next/src/i18nInstance.js +0 -7
  120. package/node_modules/react-i18next/src/index.js +0 -22
  121. package/node_modules/react-i18next/src/initReactI18next.js +0 -11
  122. package/node_modules/react-i18next/src/unescape.js +0 -31
  123. package/node_modules/react-i18next/src/useSSR.js +0 -33
  124. package/node_modules/react-i18next/src/useTranslation.js +0 -171
  125. package/node_modules/react-i18next/src/utils.js +0 -93
  126. package/node_modules/react-i18next/src/withSSR.js +0 -21
  127. package/node_modules/react-i18next/src/withTranslation.js +0 -35
  128. package/node_modules/react-i18next/vitest.workspace.typescript.mts +0 -52
@@ -1,22 +0,0 @@
1
- export { Trans } from './Trans.js';
2
- export { Trans as TransWithoutContext } from './TransWithoutContext.js';
3
- export { useTranslation } from './useTranslation.js';
4
- export { withTranslation } from './withTranslation.js';
5
- export { Translation } from './Translation.js';
6
- export { I18nextProvider } from './I18nextProvider.js';
7
- export { withSSR } from './withSSR.js';
8
- export { useSSR } from './useSSR.js';
9
- export { initReactI18next } from './initReactI18next.js';
10
- export { setDefaults, getDefaults } from './defaults.js';
11
- export { setI18n, getI18n } from './i18nInstance.js';
12
-
13
- export { I18nContext, composeInitialProps, getInitialProps } from './context.js';
14
-
15
- // dummy functions for icu.macro support
16
-
17
- export const date = () => '';
18
- export const time = () => '';
19
- export const number = () => '';
20
- export const select = () => '';
21
- export const plural = () => '';
22
- export const selectOrdinal = () => '';
@@ -1,11 +0,0 @@
1
- import { setDefaults } from './defaults.js';
2
- import { setI18n } from './i18nInstance.js';
3
-
4
- export const initReactI18next = {
5
- type: '3rdParty',
6
-
7
- init(instance) {
8
- setDefaults(instance.options.react);
9
- setI18n(instance);
10
- },
11
- };
@@ -1,31 +0,0 @@
1
- // unescape common html entities
2
-
3
- const matchHtmlEntity =
4
- /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
5
-
6
- const htmlEntities = {
7
- '&': '&',
8
- '&': '&',
9
- '&lt;': '<',
10
- '&#60;': '<',
11
- '&gt;': '>',
12
- '&#62;': '>',
13
- '&apos;': "'",
14
- '&#39;': "'",
15
- '&quot;': '"',
16
- '&#34;': '"',
17
- '&nbsp;': ' ',
18
- '&#160;': ' ',
19
- '&copy;': '©',
20
- '&#169;': '©',
21
- '&reg;': '®',
22
- '&#174;': '®',
23
- '&hellip;': '…',
24
- '&#8230;': '…',
25
- '&#x2F;': '/',
26
- '&#47;': '/',
27
- };
28
-
29
- const unescapeHtmlEntity = (m) => htmlEntities[m];
30
-
31
- export const unescape = (text) => text.replace(matchHtmlEntity, unescapeHtmlEntity);
@@ -1,33 +0,0 @@
1
- import { useContext } from 'react';
2
- import { getI18n, I18nContext } from './context.js';
3
-
4
- export const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
5
- const { i18n: i18nFromProps } = props;
6
- const { i18n: i18nFromContext } = useContext(I18nContext) || {};
7
- const i18n = i18nFromProps || i18nFromContext || getI18n();
8
-
9
- // opt out if is a cloned instance, eg. created by i18next-http-middleware on request
10
- // -> do not set initial stuff on server side
11
- if (i18n.options?.isClone) return;
12
-
13
- // nextjs / SSR: getting data from next.js or other ssr stack
14
- if (initialI18nStore && !i18n.initializedStoreOnce) {
15
- i18n.services.resourceStore.data = initialI18nStore;
16
-
17
- // add namespaces to the config - so a languageChange call loads all namespaces needed
18
- i18n.options.ns = Object.values(initialI18nStore).reduce((mem, lngResources) => {
19
- Object.keys(lngResources).forEach((ns) => {
20
- if (mem.indexOf(ns) < 0) mem.push(ns);
21
- });
22
- return mem;
23
- }, i18n.options.ns);
24
-
25
- i18n.initializedStoreOnce = true;
26
- i18n.isInitialized = true;
27
- }
28
-
29
- if (initialLanguage && !i18n.initializedLanguageOnce) {
30
- i18n.changeLanguage(initialLanguage);
31
- i18n.initializedLanguageOnce = true;
32
- }
33
- };
@@ -1,171 +0,0 @@
1
- import { useState, useEffect, useContext, useRef, useCallback } from 'react';
2
- import { getI18n, getDefaults, ReportNamespaces, I18nContext } from './context.js';
3
- import {
4
- warnOnce,
5
- loadNamespaces,
6
- loadLanguages,
7
- hasLoadedNamespace,
8
- isString,
9
- isObject,
10
- } from './utils.js';
11
-
12
- const usePrevious = (value, ignore) => {
13
- const ref = useRef();
14
- useEffect(() => {
15
- ref.current = ignore ? ref.current : value;
16
- }, [value, ignore]);
17
- return ref.current;
18
- };
19
-
20
- const alwaysNewT = (i18n, language, namespace, keyPrefix) =>
21
- i18n.getFixedT(language, namespace, keyPrefix);
22
-
23
- const useMemoizedT = (i18n, language, namespace, keyPrefix) =>
24
- useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [
25
- i18n,
26
- language,
27
- namespace,
28
- keyPrefix,
29
- ]);
30
-
31
- export const useTranslation = (ns, props = {}) => {
32
- // assert we have the needed i18nInstance
33
- const { i18n: i18nFromProps } = props;
34
- const { i18n: i18nFromContext, defaultNS: defaultNSFromContext } = useContext(I18nContext) || {};
35
- const i18n = i18nFromProps || i18nFromContext || getI18n();
36
- if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
37
- if (!i18n) {
38
- warnOnce(
39
- i18n,
40
- 'NO_I18NEXT_INSTANCE',
41
- 'useTranslation: You will need to pass in an i18next instance by using initReactI18next',
42
- );
43
- const notReadyT = (k, optsOrDefaultValue) => {
44
- if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
45
- if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue))
46
- return optsOrDefaultValue.defaultValue;
47
- return Array.isArray(k) ? k[k.length - 1] : k;
48
- };
49
- const retNotReady = [notReadyT, {}, false];
50
- retNotReady.t = notReadyT;
51
- retNotReady.i18n = {};
52
- retNotReady.ready = false;
53
- return retNotReady;
54
- }
55
-
56
- if (i18n.options.react?.wait)
57
- warnOnce(
58
- i18n,
59
- 'DEPRECATED_OPTION',
60
- 'useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.',
61
- );
62
-
63
- const i18nOptions = { ...getDefaults(), ...i18n.options.react, ...props };
64
- const { useSuspense, keyPrefix } = i18nOptions;
65
-
66
- // prepare having a namespace
67
- let namespaces = ns || defaultNSFromContext || i18n.options?.defaultNS;
68
- namespaces = isString(namespaces) ? [namespaces] : namespaces || ['translation'];
69
-
70
- // report namespaces as used
71
- i18n.reportNamespaces.addUsedNamespaces?.(namespaces);
72
-
73
- // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)
74
- const ready =
75
- (i18n.isInitialized || i18n.initializedStoreOnce) &&
76
- namespaces.every((n) => hasLoadedNamespace(n, i18n, i18nOptions));
77
-
78
- // binding t function to namespace (acts also as rerender trigger *when* args have changed)
79
- const memoGetT = useMemoizedT(
80
- i18n,
81
- props.lng || null,
82
- i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0],
83
- keyPrefix,
84
- );
85
- // using useState with a function expects an initializer, not the function itself:
86
- const getT = () => memoGetT;
87
- const getNewT = () =>
88
- alwaysNewT(
89
- i18n,
90
- props.lng || null,
91
- i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0],
92
- keyPrefix,
93
- );
94
-
95
- const [t, setT] = useState(getT);
96
-
97
- let joinedNS = namespaces.join();
98
- if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
99
- const previousJoinedNS = usePrevious(joinedNS);
100
-
101
- const isMounted = useRef(true);
102
- useEffect(() => {
103
- const { bindI18n, bindI18nStore } = i18nOptions;
104
- isMounted.current = true;
105
-
106
- // if not ready and not using suspense load the namespaces
107
- // in side effect and do not call resetT if unmounted
108
- if (!ready && !useSuspense) {
109
- if (props.lng) {
110
- loadLanguages(i18n, props.lng, namespaces, () => {
111
- if (isMounted.current) setT(getNewT);
112
- });
113
- } else {
114
- loadNamespaces(i18n, namespaces, () => {
115
- if (isMounted.current) setT(getNewT);
116
- });
117
- }
118
- }
119
-
120
- if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
121
- setT(getNewT);
122
- }
123
-
124
- const boundReset = () => {
125
- if (isMounted.current) setT(getNewT);
126
- };
127
-
128
- // bind events to trigger change, like languageChanged
129
- if (bindI18n) i18n?.on(bindI18n, boundReset);
130
- if (bindI18nStore) i18n?.store.on(bindI18nStore, boundReset);
131
-
132
- // unbinding on unmount
133
- return () => {
134
- isMounted.current = false;
135
- if (i18n && bindI18n) bindI18n?.split(' ').forEach((e) => i18n.off(e, boundReset));
136
- if (bindI18nStore && i18n)
137
- bindI18nStore.split(' ').forEach((e) => i18n.store.off(e, boundReset));
138
- };
139
- }, [i18n, joinedNS]); // re-run effect whenever list of namespaces changes
140
-
141
- // t is correctly initialized by useState hook. We only need to update it after i18n
142
- // instance was replaced (for example in the provider).
143
- useEffect(() => {
144
- if (isMounted.current && ready) {
145
- // not getNewT: depend on dependency list of the useCallback call within
146
- // useMemoizedT to only provide a newly-bound t *iff* i18n instance was
147
- // replaced; see bug 1691 https://github.com/i18next/react-i18next/issues/1691
148
- setT(getT);
149
- }
150
- }, [i18n, keyPrefix, ready]); // re-run when i18n instance or keyPrefix were replaced
151
-
152
- const ret = [t, i18n, ready];
153
- ret.t = t;
154
- ret.i18n = i18n;
155
- ret.ready = ready;
156
-
157
- // return hook stuff if ready
158
- if (ready) return ret;
159
-
160
- // not yet loaded namespaces -> load them -> and return if useSuspense option set false
161
- if (!ready && !useSuspense) return ret;
162
-
163
- // not yet loaded namespaces -> load them -> and trigger suspense
164
- throw new Promise((resolve) => {
165
- if (props.lng) {
166
- loadLanguages(i18n, props.lng, namespaces, () => resolve());
167
- } else {
168
- loadNamespaces(i18n, namespaces, () => resolve());
169
- }
170
- });
171
- };
@@ -1,93 +0,0 @@
1
- /** @type {(i18n:any,code:import('../TransWithoutContext').ErrorCode,msg?:string, rest?:{[key:string]: any})=>void} */
2
- export const warn = (i18n, code, msg, rest) => {
3
- const args = [msg, { code, ...(rest || {}) }];
4
- if (i18n?.services?.logger?.forward) {
5
- return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
6
- }
7
- if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
8
- if (i18n?.services?.logger?.warn) {
9
- i18n.services.logger.warn(...args);
10
- } else if (console?.warn) {
11
- console.warn(...args);
12
- }
13
- };
14
- const alreadyWarned = {};
15
- /** @type {typeof warn} */
16
- export const warnOnce = (i18n, code, msg, rest) => {
17
- if (isString(msg) && alreadyWarned[msg]) return;
18
- if (isString(msg)) alreadyWarned[msg] = new Date();
19
- warn(i18n, code, msg, rest);
20
- };
21
-
22
- // not needed right now
23
- //
24
- // export const deprecated = (i18n, ...args) => {
25
- // if (process && process.env && (!process.env.NODE_ENV || process.env.NODE_ENV === 'development')) {
26
- // if (isString(args[0])) args[0] = `deprecation warning -> ${args[0]}`;
27
- // warnOnce(i18n, ...args);
28
- // }
29
- // }
30
-
31
- const loadedClb = (i18n, cb) => () => {
32
- // delay ready if not yet initialized i18n instance
33
- if (i18n.isInitialized) {
34
- cb();
35
- } else {
36
- const initialized = () => {
37
- // due to emitter removing issue in i18next we need to delay remove
38
- setTimeout(() => {
39
- i18n.off('initialized', initialized);
40
- }, 0);
41
- cb();
42
- };
43
- i18n.on('initialized', initialized);
44
- }
45
- };
46
-
47
- export const loadNamespaces = (i18n, ns, cb) => {
48
- i18n.loadNamespaces(ns, loadedClb(i18n, cb));
49
- };
50
-
51
- // should work with I18NEXT >= v22.5.0
52
- export const loadLanguages = (i18n, lng, ns, cb) => {
53
- // eslint-disable-next-line no-param-reassign
54
- if (isString(ns)) ns = [ns];
55
- if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1)
56
- return loadNamespaces(i18n, ns, cb);
57
- ns.forEach((n) => {
58
- if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
59
- });
60
- i18n.loadLanguages(lng, loadedClb(i18n, cb));
61
- };
62
-
63
- export const hasLoadedNamespace = (ns, i18n, options = {}) => {
64
- if (!i18n.languages || !i18n.languages.length) {
65
- warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
66
- languages: i18n.languages,
67
- });
68
- return true;
69
- }
70
-
71
- return i18n.hasLoadedNamespace(ns, {
72
- lng: options.lng,
73
- precheck: (i18nInstance, loadNotPending) => {
74
- if (
75
- options.bindI18n &&
76
- options.bindI18n.indexOf('languageChanging') > -1 &&
77
- i18nInstance.services.backendConnector.backend &&
78
- i18nInstance.isLanguageChangingTo &&
79
- !loadNotPending(i18nInstance.isLanguageChangingTo, ns)
80
- )
81
- return false;
82
- },
83
- });
84
- };
85
-
86
- export const getDisplayName = (Component) =>
87
- Component.displayName ||
88
- Component.name ||
89
- (isString(Component) && Component.length > 0 ? Component : 'Unknown');
90
-
91
- export const isString = (obj) => typeof obj === 'string';
92
-
93
- export const isObject = (obj) => typeof obj === 'object' && obj !== null;
@@ -1,21 +0,0 @@
1
- import { createElement } from 'react';
2
- import { useSSR } from './useSSR.js';
3
- import { composeInitialProps } from './context.js';
4
- import { getDisplayName } from './utils.js';
5
-
6
- export const withSSR = () =>
7
- function Extend(WrappedComponent) {
8
- function I18nextWithSSR({ initialI18nStore, initialLanguage, ...rest }) {
9
- useSSR(initialI18nStore, initialLanguage);
10
-
11
- return createElement(WrappedComponent, {
12
- ...rest,
13
- });
14
- }
15
-
16
- I18nextWithSSR.getInitialProps = composeInitialProps(WrappedComponent);
17
- I18nextWithSSR.displayName = `withI18nextSSR(${getDisplayName(WrappedComponent)})`;
18
- I18nextWithSSR.WrappedComponent = WrappedComponent;
19
-
20
- return I18nextWithSSR;
21
- };
@@ -1,35 +0,0 @@
1
- import { createElement, forwardRef as forwardRefReact } from 'react';
2
- import { useTranslation } from './useTranslation.js';
3
- import { getDisplayName } from './utils.js';
4
-
5
- export const withTranslation = (ns, options = {}) =>
6
- function Extend(WrappedComponent) {
7
- function I18nextWithTranslation({ forwardedRef, ...rest }) {
8
- const [t, i18n, ready] = useTranslation(ns, { ...rest, keyPrefix: options.keyPrefix });
9
-
10
- const passDownProps = {
11
- ...rest,
12
- t,
13
- i18n,
14
- tReady: ready,
15
- };
16
- if (options.withRef && forwardedRef) {
17
- passDownProps.ref = forwardedRef;
18
- } else if (!options.withRef && forwardedRef) {
19
- passDownProps.forwardedRef = forwardedRef;
20
- }
21
- return createElement(WrappedComponent, passDownProps);
22
- }
23
-
24
- I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(
25
- WrappedComponent,
26
- )})`;
27
-
28
- I18nextWithTranslation.WrappedComponent = WrappedComponent;
29
-
30
- const forwardRef = (props, ref) =>
31
- // eslint-disable-next-line prefer-object-spread
32
- createElement(I18nextWithTranslation, Object.assign({}, props, { forwardedRef: ref }));
33
-
34
- return options.withRef ? forwardRefReact(forwardRef) : I18nextWithTranslation;
35
- };
@@ -1,52 +0,0 @@
1
- import { readdirSync } from 'node:fs';
2
- import { defineWorkspace } from 'vitest/config';
3
- import type { UserProjectConfigExport } from 'vitest/config';
4
-
5
- export default defineWorkspace(
6
- /**
7
- * If you need to test multiple typescript configurations (like misc) simply create a file named tsconfig.{customName}.json
8
- * and this script will automatically create a new workspace named with the dirName followed by `customName`
9
- */
10
- readdirSync('./test/typescript', { withFileTypes: true })
11
- .filter((dir) => dir.isDirectory())
12
- .reduce<UserProjectConfigExport[]>((workspaces, dir) => {
13
- const dirPath = `test/typescript/${dir.name}` as const;
14
-
15
- const tsConfigFiles = readdirSync(dirPath).filter(
16
- // Do not include temporary vitest tsconfig files
17
- (it) => it.startsWith('tsconfig.') && it.endsWith('.json') && !it.includes('vitest-temp'),
18
- );
19
-
20
- tsConfigFiles.forEach((tsConfigFileName) => {
21
- const workspaceName =
22
- tsConfigFileName === 'tsconfig.json'
23
- ? `typescript-${dir.name}`
24
- : `${dir.name}-${tsConfigFileName.split('.')[1]}`;
25
-
26
- workspaces.push({
27
- test: {
28
- dir: `./${dirPath}`,
29
- name: workspaceName,
30
- alias: {
31
- /**
32
- * From `vitest` >= 2 imports are resolved even if we are running only typecheck tests.
33
- * This will result in:
34
- * ```text
35
- * Error: Failed to resolve entry for package "react-i18next". The package may have incorrect main/module/exports specified in its package.json.
36
- * ```
37
- * To avoid a useless build process before running these tests an empty alias to `react-i18next` is added.
38
- */
39
- 'react-i18next': '',
40
- },
41
- typecheck: {
42
- enabled: true,
43
- include: [`**/${dirPath}/*.test.{ts,tsx}`],
44
- tsconfig: `./${dirPath}/${tsConfigFileName}`,
45
- },
46
- },
47
- });
48
- });
49
-
50
- return workspaces;
51
- }, []),
52
- );