hrm_ui_lib 2.0.0-alpha.10 → 2.0.0-alpha.12
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/components/FormContainer/FormContainer.js +7 -471
- package/components/FormContainer/index.js +3 -0
- package/i18n.d.ts +4 -0
- package/i18n.js +2676 -0
- package/index.d.ts +1 -0
- package/index.js +6 -5
- package/node-ponyfill-CCC52WRr.js +81701 -0
- package/package.json +1 -1
- package/helperComponents/IconDynamicComponent/IconDynamicComponent.d.ts +0 -9
- package/helperComponents/IconDynamicComponent/IconDynamicComponent.js +0 -12
- package/helperComponents/IconDynamicComponent/constants.d.ts +0 -3
- package/helperComponents/IconDynamicComponent/constants.js +0 -12
- package/helperComponents/IconDynamicComponent/index.d.ts +0 -1
- package/helperComponents/IconDynamicComponent/index.js +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/extends';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useMemo, useEffect } from 'react';
|
|
3
3
|
import { useForm } from 'react-hook-form';
|
|
4
4
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { FormContext } from '../../context/types.js';
|
|
7
7
|
import { B as Button } from '../../Alert--0rz5XL1.js';
|
|
8
|
+
import instance from '../../i18n.js';
|
|
8
9
|
import '../../utils/helpers.js';
|
|
9
10
|
import 'dayjs';
|
|
10
11
|
import '../Alert/consts.js';
|
|
@@ -54,471 +55,8 @@ import '../Progress/Progress.js';
|
|
|
54
55
|
import '../SVGIcons/IconArrowDownloadFilled.js';
|
|
55
56
|
import '../../helpers/download-file.js';
|
|
56
57
|
import '../Button/consts.js';
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const args = [msg, {
|
|
60
|
-
code,
|
|
61
|
-
...(rest || {})
|
|
62
|
-
}];
|
|
63
|
-
if (i18n?.services?.logger?.forward) {
|
|
64
|
-
return i18n.services.logger.forward(args, 'warn', 'react-i18next::', true);
|
|
65
|
-
}
|
|
66
|
-
if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`;
|
|
67
|
-
if (i18n?.services?.logger?.warn) {
|
|
68
|
-
i18n.services.logger.warn(...args);
|
|
69
|
-
} else if (console?.warn) {
|
|
70
|
-
console.warn(...args);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const alreadyWarned = {};
|
|
74
|
-
const warnOnce = (i18n, code, msg, rest) => {
|
|
75
|
-
if (isString(msg) && alreadyWarned[msg]) return;
|
|
76
|
-
if (isString(msg)) alreadyWarned[msg] = new Date();
|
|
77
|
-
warn(i18n, code, msg, rest);
|
|
78
|
-
};
|
|
79
|
-
const loadedClb = (i18n, cb) => () => {
|
|
80
|
-
if (i18n.isInitialized) {
|
|
81
|
-
cb();
|
|
82
|
-
} else {
|
|
83
|
-
const initialized = () => {
|
|
84
|
-
setTimeout(() => {
|
|
85
|
-
i18n.off('initialized', initialized);
|
|
86
|
-
}, 0);
|
|
87
|
-
cb();
|
|
88
|
-
};
|
|
89
|
-
i18n.on('initialized', initialized);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const loadNamespaces = (i18n, ns, cb) => {
|
|
93
|
-
i18n.loadNamespaces(ns, loadedClb(i18n, cb));
|
|
94
|
-
};
|
|
95
|
-
const loadLanguages = (i18n, lng, ns, cb) => {
|
|
96
|
-
if (isString(ns)) ns = [ns];
|
|
97
|
-
if (i18n.options.preload && i18n.options.preload.indexOf(lng) > -1) return loadNamespaces(i18n, ns, cb);
|
|
98
|
-
ns.forEach(n => {
|
|
99
|
-
if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
|
|
100
|
-
});
|
|
101
|
-
i18n.loadLanguages(lng, loadedClb(i18n, cb));
|
|
102
|
-
};
|
|
103
|
-
const hasLoadedNamespace = (ns, i18n, options = {}) => {
|
|
104
|
-
if (!i18n.languages || !i18n.languages.length) {
|
|
105
|
-
warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
|
|
106
|
-
languages: i18n.languages
|
|
107
|
-
});
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
return i18n.hasLoadedNamespace(ns, {
|
|
111
|
-
lng: options.lng,
|
|
112
|
-
precheck: (i18nInstance, loadNotPending) => {
|
|
113
|
-
if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
const isString = obj => typeof obj === 'string';
|
|
118
|
-
const isObject = obj => typeof obj === 'object' && obj !== null;
|
|
119
|
-
|
|
120
|
-
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
121
|
-
const htmlEntities = {
|
|
122
|
-
'&': '&',
|
|
123
|
-
'&': '&',
|
|
124
|
-
'<': '<',
|
|
125
|
-
'<': '<',
|
|
126
|
-
'>': '>',
|
|
127
|
-
'>': '>',
|
|
128
|
-
''': "'",
|
|
129
|
-
''': "'",
|
|
130
|
-
'"': '"',
|
|
131
|
-
'"': '"',
|
|
132
|
-
' ': ' ',
|
|
133
|
-
' ': ' ',
|
|
134
|
-
'©': '©',
|
|
135
|
-
'©': '©',
|
|
136
|
-
'®': '®',
|
|
137
|
-
'®': '®',
|
|
138
|
-
'…': '…',
|
|
139
|
-
'…': '…',
|
|
140
|
-
'/': '/',
|
|
141
|
-
'/': '/'
|
|
142
|
-
};
|
|
143
|
-
const unescapeHtmlEntity = m => htmlEntities[m];
|
|
144
|
-
const unescape = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
145
|
-
|
|
146
|
-
let defaultOptions = {
|
|
147
|
-
bindI18n: 'languageChanged',
|
|
148
|
-
bindI18nStore: '',
|
|
149
|
-
transEmptyNodeValue: '',
|
|
150
|
-
transSupportBasicHtmlNodes: true,
|
|
151
|
-
transWrapTextNodes: '',
|
|
152
|
-
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
153
|
-
useSuspense: true,
|
|
154
|
-
unescape
|
|
155
|
-
};
|
|
156
|
-
const getDefaults = () => defaultOptions;
|
|
157
|
-
|
|
158
|
-
let i18nInstance;
|
|
159
|
-
const getI18n = () => i18nInstance;
|
|
160
|
-
|
|
161
|
-
const I18nContext = createContext();
|
|
162
|
-
class ReportNamespaces {
|
|
163
|
-
constructor() {
|
|
164
|
-
this.usedNamespaces = {};
|
|
165
|
-
}
|
|
166
|
-
addUsedNamespaces(namespaces) {
|
|
167
|
-
namespaces.forEach(ns => {
|
|
168
|
-
if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
getUsedNamespaces() {
|
|
172
|
-
return Object.keys(this.usedNamespaces);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
var shim = {exports: {}};
|
|
177
|
-
|
|
178
|
-
var useSyncExternalStoreShim_production = {};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @license React
|
|
182
|
-
* use-sync-external-store-shim.production.js
|
|
183
|
-
*
|
|
184
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
185
|
-
*
|
|
186
|
-
* This source code is licensed under the MIT license found in the
|
|
187
|
-
* LICENSE file in the root directory of this source tree.
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
var hasRequiredUseSyncExternalStoreShim_production;
|
|
191
|
-
|
|
192
|
-
function requireUseSyncExternalStoreShim_production () {
|
|
193
|
-
if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
|
|
194
|
-
hasRequiredUseSyncExternalStoreShim_production = 1;
|
|
195
|
-
var React$1 = React;
|
|
196
|
-
function is(x, y) {
|
|
197
|
-
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
|
198
|
-
}
|
|
199
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
200
|
-
useState = React$1.useState,
|
|
201
|
-
useEffect = React$1.useEffect,
|
|
202
|
-
useLayoutEffect = React$1.useLayoutEffect,
|
|
203
|
-
useDebugValue = React$1.useDebugValue;
|
|
204
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
205
|
-
var value = getSnapshot(),
|
|
206
|
-
_useState = useState({ inst: { value: value, getSnapshot: getSnapshot } }),
|
|
207
|
-
inst = _useState[0].inst,
|
|
208
|
-
forceUpdate = _useState[1];
|
|
209
|
-
useLayoutEffect(
|
|
210
|
-
function () {
|
|
211
|
-
inst.value = value;
|
|
212
|
-
inst.getSnapshot = getSnapshot;
|
|
213
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
214
|
-
},
|
|
215
|
-
[subscribe, value, getSnapshot]
|
|
216
|
-
);
|
|
217
|
-
useEffect(
|
|
218
|
-
function () {
|
|
219
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
220
|
-
return subscribe(function () {
|
|
221
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
[subscribe]
|
|
225
|
-
);
|
|
226
|
-
useDebugValue(value);
|
|
227
|
-
return value;
|
|
228
|
-
}
|
|
229
|
-
function checkIfSnapshotChanged(inst) {
|
|
230
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
231
|
-
inst = inst.value;
|
|
232
|
-
try {
|
|
233
|
-
var nextValue = latestGetSnapshot();
|
|
234
|
-
return !objectIs(inst, nextValue);
|
|
235
|
-
} catch (error) {
|
|
236
|
-
return true;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
240
|
-
return getSnapshot();
|
|
241
|
-
}
|
|
242
|
-
var shim =
|
|
243
|
-
"undefined" === typeof window ||
|
|
244
|
-
"undefined" === typeof window.document ||
|
|
245
|
-
"undefined" === typeof window.document.createElement
|
|
246
|
-
? useSyncExternalStore$1
|
|
247
|
-
: useSyncExternalStore$2;
|
|
248
|
-
useSyncExternalStoreShim_production.useSyncExternalStore =
|
|
249
|
-
void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
|
|
250
|
-
return useSyncExternalStoreShim_production;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
var useSyncExternalStoreShim_development = {};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* @license React
|
|
257
|
-
* use-sync-external-store-shim.development.js
|
|
258
|
-
*
|
|
259
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
260
|
-
*
|
|
261
|
-
* This source code is licensed under the MIT license found in the
|
|
262
|
-
* LICENSE file in the root directory of this source tree.
|
|
263
|
-
*/
|
|
264
|
-
|
|
265
|
-
var hasRequiredUseSyncExternalStoreShim_development;
|
|
266
|
-
|
|
267
|
-
function requireUseSyncExternalStoreShim_development () {
|
|
268
|
-
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
269
|
-
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
270
|
-
"production" !== process.env.NODE_ENV &&
|
|
271
|
-
(function () {
|
|
272
|
-
function is(x, y) {
|
|
273
|
-
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
|
274
|
-
}
|
|
275
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
276
|
-
didWarnOld18Alpha ||
|
|
277
|
-
void 0 === React$1.startTransition ||
|
|
278
|
-
((didWarnOld18Alpha = true),
|
|
279
|
-
console.error(
|
|
280
|
-
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
281
|
-
));
|
|
282
|
-
var value = getSnapshot();
|
|
283
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
284
|
-
var cachedValue = getSnapshot();
|
|
285
|
-
objectIs(value, cachedValue) ||
|
|
286
|
-
(console.error(
|
|
287
|
-
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
288
|
-
),
|
|
289
|
-
(didWarnUncachedGetSnapshot = true));
|
|
290
|
-
}
|
|
291
|
-
cachedValue = useState({
|
|
292
|
-
inst: { value: value, getSnapshot: getSnapshot }
|
|
293
|
-
});
|
|
294
|
-
var inst = cachedValue[0].inst,
|
|
295
|
-
forceUpdate = cachedValue[1];
|
|
296
|
-
useLayoutEffect(
|
|
297
|
-
function () {
|
|
298
|
-
inst.value = value;
|
|
299
|
-
inst.getSnapshot = getSnapshot;
|
|
300
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
301
|
-
},
|
|
302
|
-
[subscribe, value, getSnapshot]
|
|
303
|
-
);
|
|
304
|
-
useEffect(
|
|
305
|
-
function () {
|
|
306
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
307
|
-
return subscribe(function () {
|
|
308
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
309
|
-
});
|
|
310
|
-
},
|
|
311
|
-
[subscribe]
|
|
312
|
-
);
|
|
313
|
-
useDebugValue(value);
|
|
314
|
-
return value;
|
|
315
|
-
}
|
|
316
|
-
function checkIfSnapshotChanged(inst) {
|
|
317
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
318
|
-
inst = inst.value;
|
|
319
|
-
try {
|
|
320
|
-
var nextValue = latestGetSnapshot();
|
|
321
|
-
return !objectIs(inst, nextValue);
|
|
322
|
-
} catch (error) {
|
|
323
|
-
return true;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
327
|
-
return getSnapshot();
|
|
328
|
-
}
|
|
329
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
330
|
-
"function" ===
|
|
331
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
|
|
332
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
333
|
-
var React$1 = React,
|
|
334
|
-
objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
335
|
-
useState = React$1.useState,
|
|
336
|
-
useEffect = React$1.useEffect,
|
|
337
|
-
useLayoutEffect = React$1.useLayoutEffect,
|
|
338
|
-
useDebugValue = React$1.useDebugValue,
|
|
339
|
-
didWarnOld18Alpha = false,
|
|
340
|
-
didWarnUncachedGetSnapshot = false,
|
|
341
|
-
shim =
|
|
342
|
-
"undefined" === typeof window ||
|
|
343
|
-
"undefined" === typeof window.document ||
|
|
344
|
-
"undefined" === typeof window.document.createElement
|
|
345
|
-
? useSyncExternalStore$1
|
|
346
|
-
: useSyncExternalStore$2;
|
|
347
|
-
useSyncExternalStoreShim_development.useSyncExternalStore =
|
|
348
|
-
void 0 !== React$1.useSyncExternalStore ? React$1.useSyncExternalStore : shim;
|
|
349
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
350
|
-
"function" ===
|
|
351
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
|
352
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
353
|
-
})();
|
|
354
|
-
return useSyncExternalStoreShim_development;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
var hasRequiredShim;
|
|
358
|
-
|
|
359
|
-
function requireShim () {
|
|
360
|
-
if (hasRequiredShim) return shim.exports;
|
|
361
|
-
hasRequiredShim = 1;
|
|
362
|
-
|
|
363
|
-
if (process.env.NODE_ENV === 'production') {
|
|
364
|
-
shim.exports = requireUseSyncExternalStoreShim_production();
|
|
365
|
-
} else {
|
|
366
|
-
shim.exports = requireUseSyncExternalStoreShim_development();
|
|
367
|
-
}
|
|
368
|
-
return shim.exports;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
var shimExports = requireShim();
|
|
372
|
-
|
|
373
|
-
const notReadyT = (k, optsOrDefaultValue) => {
|
|
374
|
-
if (isString(optsOrDefaultValue)) return optsOrDefaultValue;
|
|
375
|
-
if (isObject(optsOrDefaultValue) && isString(optsOrDefaultValue.defaultValue)) return optsOrDefaultValue.defaultValue;
|
|
376
|
-
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
377
|
-
};
|
|
378
|
-
const notReadySnapshot = {
|
|
379
|
-
t: notReadyT,
|
|
380
|
-
ready: false
|
|
381
|
-
};
|
|
382
|
-
const dummySubscribe = () => () => {};
|
|
383
|
-
const useTranslation = (ns, props = {}) => {
|
|
384
|
-
const {
|
|
385
|
-
i18n: i18nFromProps
|
|
386
|
-
} = props;
|
|
387
|
-
const {
|
|
388
|
-
i18n: i18nFromContext,
|
|
389
|
-
defaultNS: defaultNSFromContext
|
|
390
|
-
} = useContext(I18nContext) || {};
|
|
391
|
-
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
392
|
-
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
|
|
393
|
-
if (!i18n) {
|
|
394
|
-
warnOnce(i18n, 'NO_I18NEXT_INSTANCE', 'useTranslation: You will need to pass in an i18next instance by using initReactI18next');
|
|
395
|
-
}
|
|
396
|
-
const i18nOptions = useMemo(() => ({
|
|
397
|
-
...getDefaults(),
|
|
398
|
-
...i18n?.options?.react,
|
|
399
|
-
...props
|
|
400
|
-
}), [i18n, props]);
|
|
401
|
-
const {
|
|
402
|
-
useSuspense,
|
|
403
|
-
keyPrefix
|
|
404
|
-
} = i18nOptions;
|
|
405
|
-
const namespaces = useMemo(() => {
|
|
406
|
-
const nsOrContext = defaultNSFromContext || i18n?.options?.defaultNS;
|
|
407
|
-
return isString(nsOrContext) ? [nsOrContext] : nsOrContext || ['translation'];
|
|
408
|
-
}, [ns, defaultNSFromContext, i18n]);
|
|
409
|
-
i18n?.reportNamespaces?.addUsedNamespaces?.(namespaces);
|
|
410
|
-
const revisionRef = useRef(0);
|
|
411
|
-
const subscribe = useCallback(callback => {
|
|
412
|
-
if (!i18n) return dummySubscribe;
|
|
413
|
-
const {
|
|
414
|
-
bindI18n,
|
|
415
|
-
bindI18nStore
|
|
416
|
-
} = i18nOptions;
|
|
417
|
-
const wrappedCallback = () => {
|
|
418
|
-
revisionRef.current += 1;
|
|
419
|
-
callback();
|
|
420
|
-
};
|
|
421
|
-
if (bindI18n) i18n.on(bindI18n, wrappedCallback);
|
|
422
|
-
if (bindI18nStore) i18n.store.on(bindI18nStore, wrappedCallback);
|
|
423
|
-
return () => {
|
|
424
|
-
if (bindI18n) bindI18n.split(' ').forEach(e => i18n.off(e, wrappedCallback));
|
|
425
|
-
if (bindI18nStore) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, wrappedCallback));
|
|
426
|
-
};
|
|
427
|
-
}, [i18n, i18nOptions]);
|
|
428
|
-
const snapshotRef = useRef();
|
|
429
|
-
const getSnapshot = useCallback(() => {
|
|
430
|
-
if (!i18n) {
|
|
431
|
-
return notReadySnapshot;
|
|
432
|
-
}
|
|
433
|
-
const calculatedReady = !!(i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
|
|
434
|
-
const currentLng = props.lng || i18n.language;
|
|
435
|
-
const currentRevision = revisionRef.current;
|
|
436
|
-
const lastSnapshot = snapshotRef.current;
|
|
437
|
-
if (lastSnapshot && lastSnapshot.ready === calculatedReady && lastSnapshot.lng === currentLng && lastSnapshot.keyPrefix === keyPrefix && lastSnapshot.revision === currentRevision) {
|
|
438
|
-
return lastSnapshot;
|
|
439
|
-
}
|
|
440
|
-
const calculatedT = i18n.getFixedT(currentLng, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
|
|
441
|
-
const newSnapshot = {
|
|
442
|
-
t: calculatedT,
|
|
443
|
-
ready: calculatedReady,
|
|
444
|
-
lng: currentLng,
|
|
445
|
-
keyPrefix,
|
|
446
|
-
revision: currentRevision
|
|
447
|
-
};
|
|
448
|
-
snapshotRef.current = newSnapshot;
|
|
449
|
-
return newSnapshot;
|
|
450
|
-
}, [i18n, namespaces, keyPrefix, i18nOptions, props.lng]);
|
|
451
|
-
const [loadCount, setLoadCount] = useState(0);
|
|
452
|
-
const {
|
|
453
|
-
t,
|
|
454
|
-
ready
|
|
455
|
-
} = shimExports.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
456
|
-
useEffect(() => {
|
|
457
|
-
if (i18n && !ready && !useSuspense) {
|
|
458
|
-
const onLoaded = () => setLoadCount(c => c + 1);
|
|
459
|
-
if (props.lng) {
|
|
460
|
-
loadLanguages(i18n, props.lng, namespaces, onLoaded);
|
|
461
|
-
} else {
|
|
462
|
-
loadNamespaces(i18n, namespaces, onLoaded);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}, [i18n, props.lng, namespaces, ready, useSuspense, loadCount]);
|
|
466
|
-
const finalI18n = i18n || {};
|
|
467
|
-
const wrapperRef = useRef(null);
|
|
468
|
-
const wrapperLangRef = useRef();
|
|
469
|
-
const createI18nWrapper = original => {
|
|
470
|
-
const descriptors = Object.getOwnPropertyDescriptors(original);
|
|
471
|
-
if (descriptors.__original) delete descriptors.__original;
|
|
472
|
-
const wrapper = Object.create(Object.getPrototypeOf(original), descriptors);
|
|
473
|
-
if (!Object.prototype.hasOwnProperty.call(wrapper, '__original')) {
|
|
474
|
-
try {
|
|
475
|
-
Object.defineProperty(wrapper, '__original', {
|
|
476
|
-
value: original,
|
|
477
|
-
writable: false,
|
|
478
|
-
enumerable: false,
|
|
479
|
-
configurable: false
|
|
480
|
-
});
|
|
481
|
-
} catch (_) {}
|
|
482
|
-
}
|
|
483
|
-
return wrapper;
|
|
484
|
-
};
|
|
485
|
-
const ret = useMemo(() => {
|
|
486
|
-
const original = finalI18n;
|
|
487
|
-
const lang = original?.language;
|
|
488
|
-
let i18nWrapper = original;
|
|
489
|
-
if (original) {
|
|
490
|
-
if (wrapperRef.current && wrapperRef.current.__original === original) {
|
|
491
|
-
if (wrapperLangRef.current !== lang) {
|
|
492
|
-
i18nWrapper = createI18nWrapper(original);
|
|
493
|
-
wrapperRef.current = i18nWrapper;
|
|
494
|
-
wrapperLangRef.current = lang;
|
|
495
|
-
} else {
|
|
496
|
-
i18nWrapper = wrapperRef.current;
|
|
497
|
-
}
|
|
498
|
-
} else {
|
|
499
|
-
i18nWrapper = createI18nWrapper(original);
|
|
500
|
-
wrapperRef.current = i18nWrapper;
|
|
501
|
-
wrapperLangRef.current = lang;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
const arr = [t, i18nWrapper, ready];
|
|
505
|
-
arr.t = t;
|
|
506
|
-
arr.i18n = i18nWrapper;
|
|
507
|
-
arr.ready = ready;
|
|
508
|
-
return arr;
|
|
509
|
-
}, [t, finalI18n, ready, finalI18n.resolvedLanguage, finalI18n.language, finalI18n.languages]);
|
|
510
|
-
if (i18n && useSuspense && !ready) {
|
|
511
|
-
throw new Promise(resolve => {
|
|
512
|
-
const onLoaded = () => resolve();
|
|
513
|
-
if (props.lng) {
|
|
514
|
-
loadLanguages(i18n, props.lng, namespaces, onLoaded);
|
|
515
|
-
} else {
|
|
516
|
-
loadNamespaces(i18n, namespaces, onLoaded);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
return ret;
|
|
521
|
-
};
|
|
58
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
|
59
|
+
import '@babel/runtime/regenerator';
|
|
522
60
|
|
|
523
61
|
var FormContainer = function FormContainer(props) {
|
|
524
62
|
var children = props.children,
|
|
@@ -534,15 +72,12 @@ var FormContainer = function FormContainer(props) {
|
|
|
534
72
|
buttonConfigs = props.buttonConfigs,
|
|
535
73
|
formId = props.formId,
|
|
536
74
|
onSubmit = props.onSubmit;
|
|
537
|
-
var _useTranslation = useTranslation(),
|
|
538
|
-
i18n = _useTranslation.i18n;
|
|
539
75
|
var schema = useMemo(function () {
|
|
540
76
|
return validationScheme;
|
|
541
|
-
}, [
|
|
77
|
+
}, [instance.language, validationScheme]);
|
|
542
78
|
var resolver = useMemo(function () {
|
|
543
79
|
return yupResolver(schema);
|
|
544
80
|
}, [schema]);
|
|
545
|
-
"form-".concat(i18n.language);
|
|
546
81
|
var _useForm = useForm({
|
|
547
82
|
mode: mode,
|
|
548
83
|
resolver: resolver,
|
|
@@ -574,8 +109,9 @@ var FormContainer = function FormContainer(props) {
|
|
|
574
109
|
}
|
|
575
110
|
};
|
|
576
111
|
useEffect(function () {
|
|
112
|
+
console.log('Language changed, updating validation messages', instance.language);
|
|
577
113
|
trigger(); // re-run validation with new messages
|
|
578
|
-
}, [
|
|
114
|
+
}, [instance.language]);
|
|
579
115
|
return /*#__PURE__*/React.createElement("form", {
|
|
580
116
|
onSubmit: handleSubmit(customSubmit),
|
|
581
117
|
id: formId,
|
|
@@ -55,3 +55,6 @@ import '../Progress/Progress.js';
|
|
|
55
55
|
import '../SVGIcons/IconArrowDownloadFilled.js';
|
|
56
56
|
import '../../helpers/download-file.js';
|
|
57
57
|
import '../Button/consts.js';
|
|
58
|
+
import '../../i18n.js';
|
|
59
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
|
60
|
+
import '@babel/runtime/regenerator';
|
package/i18n.d.ts
ADDED