@bigbinary/neeto-tags-frontend 0.0.49 → 0.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +557 -896
- package/dist/index.js.map +1 -1
- package/package.json +35 -44
package/dist/index.js
CHANGED
|
@@ -9,32 +9,30 @@ import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConst
|
|
|
9
9
|
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
10
10
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
11
11
|
import _toArray from '@babel/runtime/helpers/esm/toArray';
|
|
12
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
13
|
-
import _typeof$1 from '@babel/runtime/helpers/typeof';
|
|
14
12
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
15
|
-
import React, { createContext, useContext, createElement, isValidElement, cloneElement, useState, useRef, useEffect, useMemo } from 'react';
|
|
16
13
|
import _classCallCheck$1 from '@babel/runtime/helpers/classCallCheck';
|
|
17
14
|
import _createClass$1 from '@babel/runtime/helpers/createClass';
|
|
18
|
-
import
|
|
15
|
+
import React, { createElement, isValidElement, cloneElement, createContext, useContext, useState, useRef, useEffect, useMemo } from 'react';
|
|
19
16
|
import _extends from '@babel/runtime/helpers/extends';
|
|
17
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
20
18
|
import { Plus, MenuHorizontal, Merge as Merge$1 } from '@bigbinary/neeto-icons';
|
|
21
19
|
import { Typography, Tag, Select, Button, Dropdown, Toastr, Pane, PageLoader, NoData, Table, Alert, Input as Input$1, Modal } from '@bigbinary/neetoui';
|
|
22
20
|
import { useHistory, Switch, Route } from 'react-router-dom';
|
|
23
21
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
24
22
|
import * as yup from 'yup';
|
|
25
|
-
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
26
|
-
import _extends$1 from '@babel/runtime/helpers/esm/extends';
|
|
27
23
|
import ReactDOM from 'react-dom';
|
|
24
|
+
import _extends$1 from '@babel/runtime/helpers/esm/extends';
|
|
25
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
28
26
|
import axios from 'axios';
|
|
29
27
|
import { Container, Header, SubHeader, MenuBar } from '@bigbinary/neetoui/layouts';
|
|
30
28
|
import { Formik, Form } from 'formik';
|
|
31
29
|
import { Input, Textarea } from '@bigbinary/neetoui/formik';
|
|
32
30
|
import classames from 'classnames';
|
|
31
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
32
|
+
import _typeof$1 from '@babel/runtime/helpers/typeof';
|
|
33
33
|
|
|
34
|
-
function ownKeys$
|
|
35
|
-
|
|
36
|
-
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
37
|
-
|
|
34
|
+
function ownKeys$6$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
|
+
function _objectSpread$6$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
38
36
|
var consoleLogger = {
|
|
39
37
|
type: 'logger',
|
|
40
38
|
log: function log(args) {
|
|
@@ -50,16 +48,12 @@ var consoleLogger = {
|
|
|
50
48
|
if (console && console[type]) console[type].apply(console, args);
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
|
-
|
|
54
51
|
var Logger = function () {
|
|
55
52
|
function Logger(concreteLogger) {
|
|
56
53
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
57
|
-
|
|
58
54
|
_classCallCheck(this, Logger);
|
|
59
|
-
|
|
60
55
|
this.init(concreteLogger, options);
|
|
61
56
|
}
|
|
62
|
-
|
|
63
57
|
_createClass(Logger, [{
|
|
64
58
|
key: "init",
|
|
65
59
|
value: function init(concreteLogger) {
|
|
@@ -80,7 +74,6 @@ var Logger = function () {
|
|
|
80
74
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
81
75
|
args[_key] = arguments[_key];
|
|
82
76
|
}
|
|
83
|
-
|
|
84
77
|
return this.forward(args, 'log', '', true);
|
|
85
78
|
}
|
|
86
79
|
}, {
|
|
@@ -89,7 +82,6 @@ var Logger = function () {
|
|
|
89
82
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
90
83
|
args[_key2] = arguments[_key2];
|
|
91
84
|
}
|
|
92
|
-
|
|
93
85
|
return this.forward(args, 'warn', '', true);
|
|
94
86
|
}
|
|
95
87
|
}, {
|
|
@@ -98,7 +90,6 @@ var Logger = function () {
|
|
|
98
90
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
99
91
|
args[_key3] = arguments[_key3];
|
|
100
92
|
}
|
|
101
|
-
|
|
102
93
|
return this.forward(args, 'error', '');
|
|
103
94
|
}
|
|
104
95
|
}, {
|
|
@@ -107,7 +98,6 @@ var Logger = function () {
|
|
|
107
98
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
108
99
|
args[_key4] = arguments[_key4];
|
|
109
100
|
}
|
|
110
|
-
|
|
111
101
|
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
|
112
102
|
}
|
|
113
103
|
}, {
|
|
@@ -120,32 +110,33 @@ var Logger = function () {
|
|
|
120
110
|
}, {
|
|
121
111
|
key: "create",
|
|
122
112
|
value: function create(moduleName) {
|
|
123
|
-
return new Logger(this.logger, _objectSpread$
|
|
113
|
+
return new Logger(this.logger, _objectSpread$6$1(_objectSpread$6$1({}, {
|
|
124
114
|
prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
|
|
125
115
|
}), this.options));
|
|
126
116
|
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "clone",
|
|
119
|
+
value: function clone(options) {
|
|
120
|
+
options = options || this.options;
|
|
121
|
+
options.prefix = options.prefix || this.prefix;
|
|
122
|
+
return new Logger(this.logger, options);
|
|
123
|
+
}
|
|
127
124
|
}]);
|
|
128
|
-
|
|
129
125
|
return Logger;
|
|
130
126
|
}();
|
|
131
|
-
|
|
132
127
|
var baseLogger = new Logger();
|
|
133
128
|
|
|
134
129
|
var EventEmitter = function () {
|
|
135
130
|
function EventEmitter() {
|
|
136
131
|
_classCallCheck(this, EventEmitter);
|
|
137
|
-
|
|
138
132
|
this.observers = {};
|
|
139
133
|
}
|
|
140
|
-
|
|
141
134
|
_createClass(EventEmitter, [{
|
|
142
135
|
key: "on",
|
|
143
136
|
value: function on(events, listener) {
|
|
144
137
|
var _this = this;
|
|
145
|
-
|
|
146
138
|
events.split(' ').forEach(function (event) {
|
|
147
139
|
_this.observers[event] = _this.observers[event] || [];
|
|
148
|
-
|
|
149
140
|
_this.observers[event].push(listener);
|
|
150
141
|
});
|
|
151
142
|
return this;
|
|
@@ -154,12 +145,10 @@ var EventEmitter = function () {
|
|
|
154
145
|
key: "off",
|
|
155
146
|
value: function off(event, listener) {
|
|
156
147
|
if (!this.observers[event]) return;
|
|
157
|
-
|
|
158
148
|
if (!listener) {
|
|
159
149
|
delete this.observers[event];
|
|
160
150
|
return;
|
|
161
151
|
}
|
|
162
|
-
|
|
163
152
|
this.observers[event] = this.observers[event].filter(function (l) {
|
|
164
153
|
return l !== listener;
|
|
165
154
|
});
|
|
@@ -170,24 +159,20 @@ var EventEmitter = function () {
|
|
|
170
159
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
171
160
|
args[_key - 1] = arguments[_key];
|
|
172
161
|
}
|
|
173
|
-
|
|
174
162
|
if (this.observers[event]) {
|
|
175
163
|
var cloned = [].concat(this.observers[event]);
|
|
176
164
|
cloned.forEach(function (observer) {
|
|
177
165
|
observer.apply(void 0, args);
|
|
178
166
|
});
|
|
179
167
|
}
|
|
180
|
-
|
|
181
168
|
if (this.observers['*']) {
|
|
182
169
|
var _cloned = [].concat(this.observers['*']);
|
|
183
|
-
|
|
184
170
|
_cloned.forEach(function (observer) {
|
|
185
171
|
observer.apply(observer, [event].concat(args));
|
|
186
172
|
});
|
|
187
173
|
}
|
|
188
174
|
}
|
|
189
175
|
}]);
|
|
190
|
-
|
|
191
176
|
return EventEmitter;
|
|
192
177
|
}();
|
|
193
178
|
|
|
@@ -211,68 +196,56 @@ function copy(a, s, t) {
|
|
|
211
196
|
if (s[m]) t[m] = s[m];
|
|
212
197
|
});
|
|
213
198
|
}
|
|
214
|
-
|
|
215
199
|
function getLastOfPath(object, path, Empty) {
|
|
216
200
|
function cleanKey(key) {
|
|
217
201
|
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
|
|
218
202
|
}
|
|
219
|
-
|
|
220
203
|
function canNotTraverseDeeper() {
|
|
221
204
|
return !object || typeof object === 'string';
|
|
222
205
|
}
|
|
223
|
-
|
|
224
206
|
var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
|
|
225
|
-
|
|
226
207
|
while (stack.length > 1) {
|
|
227
208
|
if (canNotTraverseDeeper()) return {};
|
|
228
209
|
var key = cleanKey(stack.shift());
|
|
229
210
|
if (!object[key] && Empty) object[key] = new Empty();
|
|
230
|
-
|
|
231
211
|
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
232
212
|
object = object[key];
|
|
233
213
|
} else {
|
|
234
214
|
object = {};
|
|
235
215
|
}
|
|
236
216
|
}
|
|
237
|
-
|
|
238
217
|
if (canNotTraverseDeeper()) return {};
|
|
239
218
|
return {
|
|
240
219
|
obj: object,
|
|
241
220
|
k: cleanKey(stack.shift())
|
|
242
221
|
};
|
|
243
222
|
}
|
|
244
|
-
|
|
245
223
|
function setPath(object, path, newValue) {
|
|
246
224
|
var _getLastOfPath = getLastOfPath(object, path, Object),
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
225
|
+
obj = _getLastOfPath.obj,
|
|
226
|
+
k = _getLastOfPath.k;
|
|
250
227
|
obj[k] = newValue;
|
|
251
228
|
}
|
|
252
229
|
function pushPath(object, path, newValue, concat) {
|
|
253
230
|
var _getLastOfPath2 = getLastOfPath(object, path, Object),
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
231
|
+
obj = _getLastOfPath2.obj,
|
|
232
|
+
k = _getLastOfPath2.k;
|
|
257
233
|
obj[k] = obj[k] || [];
|
|
258
234
|
if (concat) obj[k] = obj[k].concat(newValue);
|
|
259
235
|
if (!concat) obj[k].push(newValue);
|
|
260
236
|
}
|
|
261
237
|
function getPath(object, path) {
|
|
262
238
|
var _getLastOfPath3 = getLastOfPath(object, path),
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
239
|
+
obj = _getLastOfPath3.obj,
|
|
240
|
+
k = _getLastOfPath3.k;
|
|
266
241
|
if (!obj) return undefined;
|
|
267
242
|
return obj[k];
|
|
268
243
|
}
|
|
269
244
|
function getPathWithDefaults(data, defaultData, key) {
|
|
270
245
|
var value = getPath(data, key);
|
|
271
|
-
|
|
272
246
|
if (value !== undefined) {
|
|
273
247
|
return value;
|
|
274
248
|
}
|
|
275
|
-
|
|
276
249
|
return getPath(defaultData, key);
|
|
277
250
|
}
|
|
278
251
|
function deepExtend(target, source, overwrite) {
|
|
@@ -289,7 +262,6 @@ function deepExtend(target, source, overwrite) {
|
|
|
289
262
|
}
|
|
290
263
|
}
|
|
291
264
|
}
|
|
292
|
-
|
|
293
265
|
return target;
|
|
294
266
|
}
|
|
295
267
|
function regexEscape(str) {
|
|
@@ -309,7 +281,6 @@ function escape(data) {
|
|
|
309
281
|
return _entityMap[s];
|
|
310
282
|
});
|
|
311
283
|
}
|
|
312
|
-
|
|
313
284
|
return data;
|
|
314
285
|
}
|
|
315
286
|
var isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
|
|
@@ -325,105 +296,77 @@ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
|
|
|
325
296
|
return c === '?' ? '\\?' : c;
|
|
326
297
|
}).join('|'), ")"));
|
|
327
298
|
var matched = !r.test(key);
|
|
328
|
-
|
|
329
299
|
if (!matched) {
|
|
330
300
|
var ki = key.indexOf(keySeparator);
|
|
331
|
-
|
|
332
301
|
if (ki > 0 && !r.test(key.substring(0, ki))) {
|
|
333
302
|
matched = true;
|
|
334
303
|
}
|
|
335
304
|
}
|
|
336
|
-
|
|
337
305
|
return matched;
|
|
338
306
|
}
|
|
339
307
|
|
|
340
|
-
function ownKeys$
|
|
341
|
-
|
|
342
|
-
function
|
|
343
|
-
|
|
344
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
345
|
-
|
|
346
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
347
|
-
|
|
308
|
+
function ownKeys$5$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
309
|
+
function _objectSpread$5$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
310
|
+
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
311
|
+
function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
348
312
|
function deepFind(obj, path) {
|
|
349
313
|
var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
350
314
|
if (!obj) return undefined;
|
|
351
315
|
if (obj[path]) return obj[path];
|
|
352
316
|
var paths = path.split(keySeparator);
|
|
353
317
|
var current = obj;
|
|
354
|
-
|
|
355
318
|
for (var i = 0; i < paths.length; ++i) {
|
|
356
319
|
if (!current) return undefined;
|
|
357
|
-
|
|
358
320
|
if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
|
|
359
321
|
return undefined;
|
|
360
322
|
}
|
|
361
|
-
|
|
362
323
|
if (current[paths[i]] === undefined) {
|
|
363
324
|
var j = 2;
|
|
364
325
|
var p = paths.slice(i, i + j).join(keySeparator);
|
|
365
326
|
var mix = current[p];
|
|
366
|
-
|
|
367
327
|
while (mix === undefined && paths.length > i + j) {
|
|
368
328
|
j++;
|
|
369
329
|
p = paths.slice(i, i + j).join(keySeparator);
|
|
370
330
|
mix = current[p];
|
|
371
331
|
}
|
|
372
|
-
|
|
373
332
|
if (mix === undefined) return undefined;
|
|
374
333
|
if (mix === null) return null;
|
|
375
|
-
|
|
376
334
|
if (path.endsWith(p)) {
|
|
377
335
|
if (typeof mix === 'string') return mix;
|
|
378
336
|
if (p && typeof mix[p] === 'string') return mix[p];
|
|
379
337
|
}
|
|
380
|
-
|
|
381
338
|
var joinedPath = paths.slice(i + j).join(keySeparator);
|
|
382
339
|
if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
|
|
383
340
|
return undefined;
|
|
384
341
|
}
|
|
385
|
-
|
|
386
342
|
current = current[paths[i]];
|
|
387
343
|
}
|
|
388
|
-
|
|
389
344
|
return current;
|
|
390
345
|
}
|
|
391
|
-
|
|
392
346
|
var ResourceStore = function (_EventEmitter) {
|
|
393
347
|
_inherits(ResourceStore, _EventEmitter);
|
|
394
|
-
|
|
395
|
-
var _super = _createSuper(ResourceStore);
|
|
396
|
-
|
|
348
|
+
var _super = _createSuper$3(ResourceStore);
|
|
397
349
|
function ResourceStore(data) {
|
|
398
350
|
var _this;
|
|
399
|
-
|
|
400
351
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
401
352
|
ns: ['translation'],
|
|
402
353
|
defaultNS: 'translation'
|
|
403
354
|
};
|
|
404
|
-
|
|
405
355
|
_classCallCheck(this, ResourceStore);
|
|
406
|
-
|
|
407
356
|
_this = _super.call(this);
|
|
408
|
-
|
|
409
357
|
if (isIE10) {
|
|
410
358
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
411
359
|
}
|
|
412
|
-
|
|
413
360
|
_this.data = data || {};
|
|
414
361
|
_this.options = options;
|
|
415
|
-
|
|
416
362
|
if (_this.options.keySeparator === undefined) {
|
|
417
363
|
_this.options.keySeparator = '.';
|
|
418
364
|
}
|
|
419
|
-
|
|
420
365
|
if (_this.options.ignoreJSONStructure === undefined) {
|
|
421
366
|
_this.options.ignoreJSONStructure = true;
|
|
422
367
|
}
|
|
423
|
-
|
|
424
368
|
return _this;
|
|
425
369
|
}
|
|
426
|
-
|
|
427
370
|
_createClass(ResourceStore, [{
|
|
428
371
|
key: "addNamespaces",
|
|
429
372
|
value: function addNamespaces(ns) {
|
|
@@ -435,7 +378,6 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
435
378
|
key: "removeNamespaces",
|
|
436
379
|
value: function removeNamespaces(ns) {
|
|
437
380
|
var index = this.options.ns.indexOf(ns);
|
|
438
|
-
|
|
439
381
|
if (index > -1) {
|
|
440
382
|
this.options.ns.splice(index, 1);
|
|
441
383
|
}
|
|
@@ -449,11 +391,9 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
449
391
|
var path = [lng, ns];
|
|
450
392
|
if (key && typeof key !== 'string') path = path.concat(key);
|
|
451
393
|
if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
452
|
-
|
|
453
394
|
if (lng.indexOf('.') > -1) {
|
|
454
395
|
path = lng.split('.');
|
|
455
396
|
}
|
|
456
|
-
|
|
457
397
|
var result = getPath(this.data, path);
|
|
458
398
|
if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
|
|
459
399
|
return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
|
|
@@ -468,13 +408,11 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
468
408
|
if (keySeparator === undefined) keySeparator = '.';
|
|
469
409
|
var path = [lng, ns];
|
|
470
410
|
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
471
|
-
|
|
472
411
|
if (lng.indexOf('.') > -1) {
|
|
473
412
|
path = lng.split('.');
|
|
474
413
|
value = ns;
|
|
475
414
|
ns = path[1];
|
|
476
415
|
}
|
|
477
|
-
|
|
478
416
|
this.addNamespaces(ns);
|
|
479
417
|
setPath(this.data, path, value);
|
|
480
418
|
if (!options.silent) this.emit('added', lng, ns, key, value);
|
|
@@ -485,13 +423,11 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
485
423
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
486
424
|
silent: false
|
|
487
425
|
};
|
|
488
|
-
|
|
489
426
|
for (var m in resources) {
|
|
490
427
|
if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
|
|
491
428
|
silent: true
|
|
492
429
|
});
|
|
493
430
|
}
|
|
494
|
-
|
|
495
431
|
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
496
432
|
}
|
|
497
433
|
}, {
|
|
@@ -501,23 +437,19 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
501
437
|
silent: false
|
|
502
438
|
};
|
|
503
439
|
var path = [lng, ns];
|
|
504
|
-
|
|
505
440
|
if (lng.indexOf('.') > -1) {
|
|
506
441
|
path = lng.split('.');
|
|
507
442
|
deep = resources;
|
|
508
443
|
resources = ns;
|
|
509
444
|
ns = path[1];
|
|
510
445
|
}
|
|
511
|
-
|
|
512
446
|
this.addNamespaces(ns);
|
|
513
447
|
var pack = getPath(this.data, path) || {};
|
|
514
|
-
|
|
515
448
|
if (deep) {
|
|
516
449
|
deepExtend(pack, resources, overwrite);
|
|
517
450
|
} else {
|
|
518
|
-
pack = _objectSpread$
|
|
451
|
+
pack = _objectSpread$5$1(_objectSpread$5$1({}, pack), resources);
|
|
519
452
|
}
|
|
520
|
-
|
|
521
453
|
setPath(this.data, path, pack);
|
|
522
454
|
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
523
455
|
}
|
|
@@ -527,7 +459,6 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
527
459
|
if (this.hasResourceBundle(lng, ns)) {
|
|
528
460
|
delete this.data[lng][ns];
|
|
529
461
|
}
|
|
530
|
-
|
|
531
462
|
this.removeNamespaces(ns);
|
|
532
463
|
this.emit('removed', lng, ns);
|
|
533
464
|
}
|
|
@@ -540,7 +471,7 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
540
471
|
key: "getResourceBundle",
|
|
541
472
|
value: function getResourceBundle(lng, ns) {
|
|
542
473
|
if (!ns) ns = this.options.defaultNS;
|
|
543
|
-
if (this.options.compatibilityAPI === 'v1') return _objectSpread$
|
|
474
|
+
if (this.options.compatibilityAPI === 'v1') return _objectSpread$5$1(_objectSpread$5$1({}, {}), this.getResource(lng, ns));
|
|
544
475
|
return this.getResource(lng, ns);
|
|
545
476
|
}
|
|
546
477
|
}, {
|
|
@@ -563,7 +494,6 @@ var ResourceStore = function (_EventEmitter) {
|
|
|
563
494
|
return this.data;
|
|
564
495
|
}
|
|
565
496
|
}]);
|
|
566
|
-
|
|
567
497
|
return ResourceStore;
|
|
568
498
|
}(EventEmitter);
|
|
569
499
|
|
|
@@ -574,7 +504,6 @@ var postProcessor = {
|
|
|
574
504
|
},
|
|
575
505
|
handle: function handle(processors, value, key, options, translator) {
|
|
576
506
|
var _this = this;
|
|
577
|
-
|
|
578
507
|
processors.forEach(function (processor) {
|
|
579
508
|
if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
|
|
580
509
|
});
|
|
@@ -582,44 +511,30 @@ var postProcessor = {
|
|
|
582
511
|
}
|
|
583
512
|
};
|
|
584
513
|
|
|
585
|
-
function ownKeys$
|
|
586
|
-
|
|
587
|
-
function
|
|
588
|
-
|
|
589
|
-
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
590
|
-
|
|
591
|
-
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
514
|
+
function ownKeys$4$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
515
|
+
function _objectSpread$4$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
516
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
517
|
+
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
592
518
|
var checkedLoadedFor = {};
|
|
593
|
-
|
|
594
519
|
var Translator = function (_EventEmitter) {
|
|
595
520
|
_inherits(Translator, _EventEmitter);
|
|
596
|
-
|
|
597
|
-
var _super = _createSuper$1(Translator);
|
|
598
|
-
|
|
521
|
+
var _super = _createSuper$2(Translator);
|
|
599
522
|
function Translator(services) {
|
|
600
523
|
var _this;
|
|
601
|
-
|
|
602
524
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
603
|
-
|
|
604
525
|
_classCallCheck(this, Translator);
|
|
605
|
-
|
|
606
526
|
_this = _super.call(this);
|
|
607
|
-
|
|
608
527
|
if (isIE10) {
|
|
609
528
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
610
529
|
}
|
|
611
|
-
|
|
612
530
|
copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
|
|
613
531
|
_this.options = options;
|
|
614
|
-
|
|
615
532
|
if (_this.options.keySeparator === undefined) {
|
|
616
533
|
_this.options.keySeparator = '.';
|
|
617
534
|
}
|
|
618
|
-
|
|
619
535
|
_this.logger = baseLogger.create('translator');
|
|
620
536
|
return _this;
|
|
621
537
|
}
|
|
622
|
-
|
|
623
538
|
_createClass(Translator, [{
|
|
624
539
|
key: "changeLanguage",
|
|
625
540
|
value: function changeLanguage(lng) {
|
|
@@ -631,11 +546,9 @@ var Translator = function (_EventEmitter) {
|
|
|
631
546
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
632
547
|
interpolation: {}
|
|
633
548
|
};
|
|
634
|
-
|
|
635
549
|
if (key === undefined || key === null) {
|
|
636
550
|
return false;
|
|
637
551
|
}
|
|
638
|
-
|
|
639
552
|
var resolved = this.resolve(key, options);
|
|
640
553
|
return resolved && resolved.res !== undefined;
|
|
641
554
|
}
|
|
@@ -648,22 +561,18 @@ var Translator = function (_EventEmitter) {
|
|
|
648
561
|
var namespaces = options.ns || this.options.defaultNS || [];
|
|
649
562
|
var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
|
650
563
|
var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
651
|
-
|
|
652
564
|
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
653
565
|
var m = key.match(this.interpolator.nestingRegexp);
|
|
654
|
-
|
|
655
566
|
if (m && m.length > 0) {
|
|
656
567
|
return {
|
|
657
568
|
key: key,
|
|
658
569
|
namespaces: namespaces
|
|
659
570
|
};
|
|
660
571
|
}
|
|
661
|
-
|
|
662
572
|
var parts = key.split(nsSeparator);
|
|
663
573
|
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
|
664
574
|
key = parts.join(keySeparator);
|
|
665
575
|
}
|
|
666
|
-
|
|
667
576
|
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
668
577
|
return {
|
|
669
578
|
key: key,
|
|
@@ -674,45 +583,35 @@ var Translator = function (_EventEmitter) {
|
|
|
674
583
|
key: "translate",
|
|
675
584
|
value: function translate(keys, options, lastKey) {
|
|
676
585
|
var _this2 = this;
|
|
677
|
-
|
|
678
586
|
if (_typeof(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
679
587
|
options = this.options.overloadTranslationOptionHandler(arguments);
|
|
680
588
|
}
|
|
681
|
-
|
|
682
589
|
if (!options) options = {};
|
|
683
590
|
if (keys === undefined || keys === null) return '';
|
|
684
591
|
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
685
592
|
var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
|
|
686
593
|
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
687
|
-
|
|
688
594
|
var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
595
|
+
key = _this$extractFromKey.key,
|
|
596
|
+
namespaces = _this$extractFromKey.namespaces;
|
|
692
597
|
var namespace = namespaces[namespaces.length - 1];
|
|
693
598
|
var lng = options.lng || this.language;
|
|
694
599
|
var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
695
|
-
|
|
696
600
|
if (lng && lng.toLowerCase() === 'cimode') {
|
|
697
601
|
if (appendNamespaceToCIMode) {
|
|
698
602
|
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
|
699
|
-
|
|
700
603
|
if (returnDetails) {
|
|
701
604
|
resolved.res = "".concat(namespace).concat(nsSeparator).concat(key);
|
|
702
605
|
return resolved;
|
|
703
606
|
}
|
|
704
|
-
|
|
705
607
|
return "".concat(namespace).concat(nsSeparator).concat(key);
|
|
706
608
|
}
|
|
707
|
-
|
|
708
609
|
if (returnDetails) {
|
|
709
610
|
resolved.res = key;
|
|
710
611
|
return resolved;
|
|
711
612
|
}
|
|
712
|
-
|
|
713
613
|
return key;
|
|
714
614
|
}
|
|
715
|
-
|
|
716
615
|
var resolved = this.resolve(keys, options);
|
|
717
616
|
var res = resolved && resolved.res;
|
|
718
617
|
var resUsedKey = resolved && resolved.usedKey || key;
|
|
@@ -722,41 +621,34 @@ var Translator = function (_EventEmitter) {
|
|
|
722
621
|
var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
|
|
723
622
|
var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
724
623
|
var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
|
|
725
|
-
|
|
726
624
|
if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
|
|
727
625
|
if (!options.returnObjects && !this.options.returnObjects) {
|
|
728
626
|
if (!this.options.returnedObjectHandler) {
|
|
729
627
|
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
730
628
|
}
|
|
731
|
-
|
|
732
|
-
var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$2$1(_objectSpread$2$1({}, options), {}, {
|
|
629
|
+
var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4$1(_objectSpread$4$1({}, options), {}, {
|
|
733
630
|
ns: namespaces
|
|
734
631
|
})) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
|
735
|
-
|
|
736
632
|
if (returnDetails) {
|
|
737
633
|
resolved.res = r;
|
|
738
634
|
return resolved;
|
|
739
635
|
}
|
|
740
|
-
|
|
741
636
|
return r;
|
|
742
637
|
}
|
|
743
|
-
|
|
744
638
|
if (keySeparator) {
|
|
745
639
|
var resTypeIsArray = resType === '[object Array]';
|
|
746
640
|
var copy = resTypeIsArray ? [] : {};
|
|
747
641
|
var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
748
|
-
|
|
749
642
|
for (var m in res) {
|
|
750
643
|
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
751
644
|
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
|
752
|
-
copy[m] = this.translate(deepKey, _objectSpread$
|
|
645
|
+
copy[m] = this.translate(deepKey, _objectSpread$4$1(_objectSpread$4$1({}, options), {
|
|
753
646
|
joinArrays: false,
|
|
754
647
|
ns: namespaces
|
|
755
648
|
}));
|
|
756
649
|
if (copy[m] === deepKey) copy[m] = res[m];
|
|
757
650
|
}
|
|
758
651
|
}
|
|
759
|
-
|
|
760
652
|
res = copy;
|
|
761
653
|
}
|
|
762
654
|
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
|
|
@@ -769,34 +661,27 @@ var Translator = function (_EventEmitter) {
|
|
|
769
661
|
var hasDefaultValue = Translator.hasDefaultValue(options);
|
|
770
662
|
var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
|
|
771
663
|
var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
|
|
772
|
-
|
|
773
664
|
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
774
665
|
usedDefault = true;
|
|
775
666
|
res = defaultValue;
|
|
776
667
|
}
|
|
777
|
-
|
|
778
668
|
if (!this.isValidLookup(res)) {
|
|
779
669
|
usedKey = true;
|
|
780
670
|
res = key;
|
|
781
671
|
}
|
|
782
|
-
|
|
783
672
|
var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
784
673
|
var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
785
674
|
var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
786
|
-
|
|
787
675
|
if (usedKey || usedDefault || updateMissing) {
|
|
788
676
|
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
789
|
-
|
|
790
677
|
if (keySeparator) {
|
|
791
|
-
var fk = this.resolve(key, _objectSpread$
|
|
678
|
+
var fk = this.resolve(key, _objectSpread$4$1(_objectSpread$4$1({}, options), {}, {
|
|
792
679
|
keySeparator: false
|
|
793
680
|
}));
|
|
794
681
|
if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
|
|
795
682
|
}
|
|
796
|
-
|
|
797
683
|
var lngs = [];
|
|
798
684
|
var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
|
|
799
|
-
|
|
800
685
|
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
|
801
686
|
for (var i = 0; i < fallbackLngs.length; i++) {
|
|
802
687
|
lngs.push(fallbackLngs[i]);
|
|
@@ -806,19 +691,15 @@ var Translator = function (_EventEmitter) {
|
|
|
806
691
|
} else {
|
|
807
692
|
lngs.push(options.lng || this.language);
|
|
808
693
|
}
|
|
809
|
-
|
|
810
694
|
var send = function send(l, k, specificDefaultValue) {
|
|
811
695
|
var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
812
|
-
|
|
813
696
|
if (_this2.options.missingKeyHandler) {
|
|
814
697
|
_this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
815
698
|
} else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
|
|
816
699
|
_this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
817
700
|
}
|
|
818
|
-
|
|
819
701
|
_this2.emit('missingKey', l, namespace, k, res);
|
|
820
702
|
};
|
|
821
|
-
|
|
822
703
|
if (this.options.saveMissing) {
|
|
823
704
|
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
824
705
|
lngs.forEach(function (language) {
|
|
@@ -831,10 +712,8 @@ var Translator = function (_EventEmitter) {
|
|
|
831
712
|
}
|
|
832
713
|
}
|
|
833
714
|
}
|
|
834
|
-
|
|
835
715
|
res = this.extendTranslation(res, keys, options, resolved, lastKey);
|
|
836
716
|
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
|
|
837
|
-
|
|
838
717
|
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
839
718
|
if (this.options.compatibilityAPI !== 'v1') {
|
|
840
719
|
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? "".concat(namespace, ":").concat(key) : key, usedDefault ? res : undefined);
|
|
@@ -843,77 +722,63 @@ var Translator = function (_EventEmitter) {
|
|
|
843
722
|
}
|
|
844
723
|
}
|
|
845
724
|
}
|
|
846
|
-
|
|
847
725
|
if (returnDetails) {
|
|
848
726
|
resolved.res = res;
|
|
849
727
|
return resolved;
|
|
850
728
|
}
|
|
851
|
-
|
|
852
729
|
return res;
|
|
853
730
|
}
|
|
854
731
|
}, {
|
|
855
732
|
key: "extendTranslation",
|
|
856
733
|
value: function extendTranslation(res, key, options, resolved, lastKey) {
|
|
857
734
|
var _this3 = this;
|
|
858
|
-
|
|
859
735
|
if (this.i18nFormat && this.i18nFormat.parse) {
|
|
860
|
-
res = this.i18nFormat.parse(res, _objectSpread$
|
|
736
|
+
res = this.i18nFormat.parse(res, _objectSpread$4$1(_objectSpread$4$1({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
861
737
|
resolved: resolved
|
|
862
738
|
});
|
|
863
739
|
} else if (!options.skipInterpolation) {
|
|
864
|
-
if (options.interpolation) this.interpolator.init(_objectSpread$
|
|
865
|
-
interpolation: _objectSpread$
|
|
740
|
+
if (options.interpolation) this.interpolator.init(_objectSpread$4$1(_objectSpread$4$1({}, options), {
|
|
741
|
+
interpolation: _objectSpread$4$1(_objectSpread$4$1({}, this.options.interpolation), options.interpolation)
|
|
866
742
|
}));
|
|
867
743
|
var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
868
744
|
var nestBef;
|
|
869
|
-
|
|
870
745
|
if (skipOnVariables) {
|
|
871
746
|
var nb = res.match(this.interpolator.nestingRegexp);
|
|
872
747
|
nestBef = nb && nb.length;
|
|
873
748
|
}
|
|
874
|
-
|
|
875
749
|
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
|
876
|
-
if (this.options.interpolation.defaultVariables) data = _objectSpread$
|
|
750
|
+
if (this.options.interpolation.defaultVariables) data = _objectSpread$4$1(_objectSpread$4$1({}, this.options.interpolation.defaultVariables), data);
|
|
877
751
|
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
|
|
878
|
-
|
|
879
752
|
if (skipOnVariables) {
|
|
880
753
|
var na = res.match(this.interpolator.nestingRegexp);
|
|
881
754
|
var nestAft = na && na.length;
|
|
882
755
|
if (nestBef < nestAft) options.nest = false;
|
|
883
756
|
}
|
|
884
|
-
|
|
885
757
|
if (options.nest !== false) res = this.interpolator.nest(res, function () {
|
|
886
758
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
887
759
|
args[_key] = arguments[_key];
|
|
888
760
|
}
|
|
889
|
-
|
|
890
761
|
if (lastKey && lastKey[0] === args[0] && !options.context) {
|
|
891
762
|
_this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
|
|
892
|
-
|
|
893
763
|
return null;
|
|
894
764
|
}
|
|
895
|
-
|
|
896
765
|
return _this3.translate.apply(_this3, args.concat([key]));
|
|
897
766
|
}, options);
|
|
898
767
|
if (options.interpolation) this.interpolator.reset();
|
|
899
768
|
}
|
|
900
|
-
|
|
901
769
|
var postProcess = options.postProcess || this.options.postProcess;
|
|
902
770
|
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
|
903
|
-
|
|
904
771
|
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
|
905
|
-
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$
|
|
772
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4$1({
|
|
906
773
|
i18nResolved: resolved
|
|
907
774
|
}, options) : options, this);
|
|
908
775
|
}
|
|
909
|
-
|
|
910
776
|
return res;
|
|
911
777
|
}
|
|
912
778
|
}, {
|
|
913
779
|
key: "resolve",
|
|
914
780
|
value: function resolve(keys) {
|
|
915
781
|
var _this4 = this;
|
|
916
|
-
|
|
917
782
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
918
783
|
var found;
|
|
919
784
|
var usedKey;
|
|
@@ -923,65 +788,50 @@ var Translator = function (_EventEmitter) {
|
|
|
923
788
|
if (typeof keys === 'string') keys = [keys];
|
|
924
789
|
keys.forEach(function (k) {
|
|
925
790
|
if (_this4.isValidLookup(found)) return;
|
|
926
|
-
|
|
927
791
|
var extracted = _this4.extractFromKey(k, options);
|
|
928
|
-
|
|
929
792
|
var key = extracted.key;
|
|
930
793
|
usedKey = key;
|
|
931
794
|
var namespaces = extracted.namespaces;
|
|
932
795
|
if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
|
|
933
796
|
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
934
|
-
|
|
935
797
|
var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
|
|
936
|
-
|
|
937
798
|
var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
|
|
938
799
|
var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
|
|
939
800
|
namespaces.forEach(function (ns) {
|
|
940
801
|
if (_this4.isValidLookup(found)) return;
|
|
941
802
|
usedNS = ns;
|
|
942
|
-
|
|
943
803
|
if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
|
|
944
804
|
checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
|
|
945
|
-
|
|
946
805
|
_this4.logger.warn("key \"".concat(usedKey, "\" for languages \"").concat(codes.join(', '), "\" won't get resolved as namespace \"").concat(usedNS, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
947
806
|
}
|
|
948
|
-
|
|
949
807
|
codes.forEach(function (code) {
|
|
950
808
|
if (_this4.isValidLookup(found)) return;
|
|
951
809
|
usedLng = code;
|
|
952
810
|
var finalKeys = [key];
|
|
953
|
-
|
|
954
811
|
if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
|
|
955
812
|
_this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
|
|
956
813
|
} else {
|
|
957
814
|
var pluralSuffix;
|
|
958
815
|
if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
|
|
959
816
|
var zeroSuffix = "".concat(_this4.options.pluralSeparator, "zero");
|
|
960
|
-
|
|
961
817
|
if (needsPluralHandling) {
|
|
962
818
|
finalKeys.push(key + pluralSuffix);
|
|
963
|
-
|
|
964
819
|
if (needsZeroSuffixLookup) {
|
|
965
820
|
finalKeys.push(key + zeroSuffix);
|
|
966
821
|
}
|
|
967
822
|
}
|
|
968
|
-
|
|
969
823
|
if (needsContextHandling) {
|
|
970
824
|
var contextKey = "".concat(key).concat(_this4.options.contextSeparator).concat(options.context);
|
|
971
825
|
finalKeys.push(contextKey);
|
|
972
|
-
|
|
973
826
|
if (needsPluralHandling) {
|
|
974
827
|
finalKeys.push(contextKey + pluralSuffix);
|
|
975
|
-
|
|
976
828
|
if (needsZeroSuffixLookup) {
|
|
977
829
|
finalKeys.push(contextKey + zeroSuffix);
|
|
978
830
|
}
|
|
979
831
|
}
|
|
980
832
|
}
|
|
981
833
|
}
|
|
982
|
-
|
|
983
834
|
var possibleKey;
|
|
984
|
-
|
|
985
835
|
while (possibleKey = finalKeys.pop()) {
|
|
986
836
|
if (!_this4.isValidLookup(found)) {
|
|
987
837
|
exactUsedKey = possibleKey;
|
|
@@ -1015,33 +865,27 @@ var Translator = function (_EventEmitter) {
|
|
|
1015
865
|
key: "hasDefaultValue",
|
|
1016
866
|
value: function hasDefaultValue(options) {
|
|
1017
867
|
var prefix = 'defaultValue';
|
|
1018
|
-
|
|
1019
868
|
for (var option in options) {
|
|
1020
869
|
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
|
1021
870
|
return true;
|
|
1022
871
|
}
|
|
1023
872
|
}
|
|
1024
|
-
|
|
1025
873
|
return false;
|
|
1026
874
|
}
|
|
1027
875
|
}]);
|
|
1028
|
-
|
|
1029
876
|
return Translator;
|
|
1030
877
|
}(EventEmitter);
|
|
1031
878
|
|
|
1032
879
|
function capitalize(string) {
|
|
1033
880
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
1034
881
|
}
|
|
1035
|
-
|
|
1036
882
|
var LanguageUtil = function () {
|
|
1037
883
|
function LanguageUtil(options) {
|
|
1038
884
|
_classCallCheck(this, LanguageUtil);
|
|
1039
|
-
|
|
1040
885
|
this.options = options;
|
|
1041
886
|
this.supportedLngs = this.options.supportedLngs || false;
|
|
1042
887
|
this.logger = baseLogger.create('languageUtils');
|
|
1043
888
|
}
|
|
1044
|
-
|
|
1045
889
|
_createClass(LanguageUtil, [{
|
|
1046
890
|
key: "getScriptPartFromCode",
|
|
1047
891
|
value: function getScriptPartFromCode(code) {
|
|
@@ -1065,7 +909,6 @@ var LanguageUtil = function () {
|
|
|
1065
909
|
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
1066
910
|
var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
|
|
1067
911
|
var p = code.split('-');
|
|
1068
|
-
|
|
1069
912
|
if (this.options.lowerCaseLng) {
|
|
1070
913
|
p = p.map(function (part) {
|
|
1071
914
|
return part.toLowerCase();
|
|
@@ -1081,10 +924,8 @@ var LanguageUtil = function () {
|
|
|
1081
924
|
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
1082
925
|
if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
|
|
1083
926
|
}
|
|
1084
|
-
|
|
1085
927
|
return p.join('-');
|
|
1086
928
|
}
|
|
1087
|
-
|
|
1088
929
|
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
1089
930
|
}
|
|
1090
931
|
}, {
|
|
@@ -1093,37 +934,29 @@ var LanguageUtil = function () {
|
|
|
1093
934
|
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
1094
935
|
code = this.getLanguagePartFromCode(code);
|
|
1095
936
|
}
|
|
1096
|
-
|
|
1097
937
|
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
|
1098
938
|
}
|
|
1099
939
|
}, {
|
|
1100
940
|
key: "getBestMatchFromCodes",
|
|
1101
941
|
value: function getBestMatchFromCodes(codes) {
|
|
1102
942
|
var _this = this;
|
|
1103
|
-
|
|
1104
943
|
if (!codes) return null;
|
|
1105
944
|
var found;
|
|
1106
945
|
codes.forEach(function (code) {
|
|
1107
946
|
if (found) return;
|
|
1108
|
-
|
|
1109
947
|
var cleanedLng = _this.formatLanguageCode(code);
|
|
1110
|
-
|
|
1111
948
|
if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
|
1112
949
|
});
|
|
1113
|
-
|
|
1114
950
|
if (!found && this.options.supportedLngs) {
|
|
1115
951
|
codes.forEach(function (code) {
|
|
1116
952
|
if (found) return;
|
|
1117
|
-
|
|
1118
953
|
var lngOnly = _this.getLanguagePartFromCode(code);
|
|
1119
|
-
|
|
1120
954
|
if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
1121
955
|
found = _this.options.supportedLngs.find(function (supportedLng) {
|
|
1122
956
|
if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
|
|
1123
957
|
});
|
|
1124
958
|
});
|
|
1125
959
|
}
|
|
1126
|
-
|
|
1127
960
|
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
|
1128
961
|
return found;
|
|
1129
962
|
}
|
|
@@ -1146,20 +979,16 @@ var LanguageUtil = function () {
|
|
|
1146
979
|
key: "toResolveHierarchy",
|
|
1147
980
|
value: function toResolveHierarchy(code, fallbackCode) {
|
|
1148
981
|
var _this2 = this;
|
|
1149
|
-
|
|
1150
982
|
var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
|
1151
983
|
var codes = [];
|
|
1152
|
-
|
|
1153
984
|
var addCode = function addCode(c) {
|
|
1154
985
|
if (!c) return;
|
|
1155
|
-
|
|
1156
986
|
if (_this2.isSupportedCode(c)) {
|
|
1157
987
|
codes.push(c);
|
|
1158
988
|
} else {
|
|
1159
989
|
_this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
|
|
1160
990
|
}
|
|
1161
991
|
};
|
|
1162
|
-
|
|
1163
992
|
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
1164
993
|
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
1165
994
|
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
@@ -1167,14 +996,12 @@ var LanguageUtil = function () {
|
|
|
1167
996
|
} else if (typeof code === 'string') {
|
|
1168
997
|
addCode(this.formatLanguageCode(code));
|
|
1169
998
|
}
|
|
1170
|
-
|
|
1171
999
|
fallbackCodes.forEach(function (fc) {
|
|
1172
1000
|
if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
|
|
1173
1001
|
});
|
|
1174
1002
|
return codes;
|
|
1175
1003
|
}
|
|
1176
1004
|
}]);
|
|
1177
|
-
|
|
1178
1005
|
return LanguageUtil;
|
|
1179
1006
|
}();
|
|
1180
1007
|
|
|
@@ -1348,7 +1175,6 @@ var suffixesOrder = {
|
|
|
1348
1175
|
many: 4,
|
|
1349
1176
|
other: 5
|
|
1350
1177
|
};
|
|
1351
|
-
|
|
1352
1178
|
function createRules() {
|
|
1353
1179
|
var rules = {};
|
|
1354
1180
|
sets.forEach(function (set) {
|
|
@@ -1361,25 +1187,19 @@ function createRules() {
|
|
|
1361
1187
|
});
|
|
1362
1188
|
return rules;
|
|
1363
1189
|
}
|
|
1364
|
-
|
|
1365
1190
|
var PluralResolver = function () {
|
|
1366
1191
|
function PluralResolver(languageUtils) {
|
|
1367
1192
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1368
|
-
|
|
1369
1193
|
_classCallCheck(this, PluralResolver);
|
|
1370
|
-
|
|
1371
1194
|
this.languageUtils = languageUtils;
|
|
1372
1195
|
this.options = options;
|
|
1373
1196
|
this.logger = baseLogger.create('pluralResolver');
|
|
1374
|
-
|
|
1375
1197
|
if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
|
|
1376
1198
|
this.options.compatibilityJSON = 'v3';
|
|
1377
1199
|
this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
|
|
1378
1200
|
}
|
|
1379
|
-
|
|
1380
1201
|
this.rules = createRules();
|
|
1381
1202
|
}
|
|
1382
|
-
|
|
1383
1203
|
_createClass(PluralResolver, [{
|
|
1384
1204
|
key: "addRule",
|
|
1385
1205
|
value: function addRule(lng, obj) {
|
|
@@ -1389,7 +1209,6 @@ var PluralResolver = function () {
|
|
|
1389
1209
|
key: "getRule",
|
|
1390
1210
|
value: function getRule(code) {
|
|
1391
1211
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1392
|
-
|
|
1393
1212
|
if (this.shouldUseIntlApi()) {
|
|
1394
1213
|
try {
|
|
1395
1214
|
return new Intl.PluralRules(code, {
|
|
@@ -1399,7 +1218,6 @@ var PluralResolver = function () {
|
|
|
1399
1218
|
return;
|
|
1400
1219
|
}
|
|
1401
1220
|
}
|
|
1402
|
-
|
|
1403
1221
|
return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
|
|
1404
1222
|
}
|
|
1405
1223
|
}, {
|
|
@@ -1407,11 +1225,9 @@ var PluralResolver = function () {
|
|
|
1407
1225
|
value: function needsPlural(code) {
|
|
1408
1226
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1409
1227
|
var rule = this.getRule(code, options);
|
|
1410
|
-
|
|
1411
1228
|
if (this.shouldUseIntlApi()) {
|
|
1412
1229
|
return rule && rule.resolvedOptions().pluralCategories.length > 1;
|
|
1413
1230
|
}
|
|
1414
|
-
|
|
1415
1231
|
return rule && rule.numbers.length > 1;
|
|
1416
1232
|
}
|
|
1417
1233
|
}, {
|
|
@@ -1426,14 +1242,11 @@ var PluralResolver = function () {
|
|
|
1426
1242
|
key: "getSuffixes",
|
|
1427
1243
|
value: function getSuffixes(code) {
|
|
1428
1244
|
var _this = this;
|
|
1429
|
-
|
|
1430
1245
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1431
1246
|
var rule = this.getRule(code, options);
|
|
1432
|
-
|
|
1433
1247
|
if (!rule) {
|
|
1434
1248
|
return [];
|
|
1435
1249
|
}
|
|
1436
|
-
|
|
1437
1250
|
if (this.shouldUseIntlApi()) {
|
|
1438
1251
|
return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
|
|
1439
1252
|
return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
|
|
@@ -1441,7 +1254,6 @@ var PluralResolver = function () {
|
|
|
1441
1254
|
return "".concat(_this.options.prepend).concat(pluralCategory);
|
|
1442
1255
|
});
|
|
1443
1256
|
}
|
|
1444
|
-
|
|
1445
1257
|
return rule.numbers.map(function (number) {
|
|
1446
1258
|
return _this.getSuffix(code, number, options);
|
|
1447
1259
|
});
|
|
@@ -1451,15 +1263,12 @@ var PluralResolver = function () {
|
|
|
1451
1263
|
value: function getSuffix(code, count) {
|
|
1452
1264
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1453
1265
|
var rule = this.getRule(code, options);
|
|
1454
|
-
|
|
1455
1266
|
if (rule) {
|
|
1456
1267
|
if (this.shouldUseIntlApi()) {
|
|
1457
1268
|
return "".concat(this.options.prepend).concat(rule.select(count));
|
|
1458
1269
|
}
|
|
1459
|
-
|
|
1460
1270
|
return this.getSuffixRetroCompatible(rule, count);
|
|
1461
1271
|
}
|
|
1462
|
-
|
|
1463
1272
|
this.logger.warn("no plural rule found for: ".concat(code));
|
|
1464
1273
|
return '';
|
|
1465
1274
|
}
|
|
@@ -1467,10 +1276,8 @@ var PluralResolver = function () {
|
|
|
1467
1276
|
key: "getSuffixRetroCompatible",
|
|
1468
1277
|
value: function getSuffixRetroCompatible(rule, count) {
|
|
1469
1278
|
var _this2 = this;
|
|
1470
|
-
|
|
1471
1279
|
var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
1472
1280
|
var suffix = rule.numbers[idx];
|
|
1473
|
-
|
|
1474
1281
|
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1475
1282
|
if (suffix === 2) {
|
|
1476
1283
|
suffix = 'plural';
|
|
@@ -1478,11 +1285,9 @@ var PluralResolver = function () {
|
|
|
1478
1285
|
suffix = '';
|
|
1479
1286
|
}
|
|
1480
1287
|
}
|
|
1481
|
-
|
|
1482
1288
|
var returnSuffix = function returnSuffix() {
|
|
1483
1289
|
return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
|
|
1484
1290
|
};
|
|
1485
|
-
|
|
1486
1291
|
if (this.options.compatibilityJSON === 'v1') {
|
|
1487
1292
|
if (suffix === 1) return '';
|
|
1488
1293
|
if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
|
|
@@ -1492,7 +1297,6 @@ var PluralResolver = function () {
|
|
|
1492
1297
|
} else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1493
1298
|
return returnSuffix();
|
|
1494
1299
|
}
|
|
1495
|
-
|
|
1496
1300
|
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
|
1497
1301
|
}
|
|
1498
1302
|
}, {
|
|
@@ -1501,30 +1305,22 @@ var PluralResolver = function () {
|
|
|
1501
1305
|
return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
|
|
1502
1306
|
}
|
|
1503
1307
|
}]);
|
|
1504
|
-
|
|
1505
1308
|
return PluralResolver;
|
|
1506
1309
|
}();
|
|
1507
1310
|
|
|
1508
|
-
function ownKeys$3$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1509
|
-
|
|
1510
|
-
function _objectSpread$3$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1511
|
-
|
|
1311
|
+
function ownKeys$3$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1312
|
+
function _objectSpread$3$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1512
1313
|
var Interpolator = function () {
|
|
1513
1314
|
function Interpolator() {
|
|
1514
1315
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1515
|
-
|
|
1516
1316
|
_classCallCheck(this, Interpolator);
|
|
1517
|
-
|
|
1518
1317
|
this.logger = baseLogger.create('interpolator');
|
|
1519
1318
|
this.options = options;
|
|
1520
|
-
|
|
1521
1319
|
this.format = options.interpolation && options.interpolation.format || function (value) {
|
|
1522
1320
|
return value;
|
|
1523
1321
|
};
|
|
1524
|
-
|
|
1525
1322
|
this.init(options);
|
|
1526
1323
|
}
|
|
1527
|
-
|
|
1528
1324
|
_createClass(Interpolator, [{
|
|
1529
1325
|
key: "init",
|
|
1530
1326
|
value: function init() {
|
|
@@ -1567,16 +1363,13 @@ var Interpolator = function () {
|
|
|
1567
1363
|
key: "interpolate",
|
|
1568
1364
|
value: function interpolate(str, data, lng, options) {
|
|
1569
1365
|
var _this = this;
|
|
1570
|
-
|
|
1571
1366
|
var match;
|
|
1572
1367
|
var value;
|
|
1573
1368
|
var replaces;
|
|
1574
1369
|
var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
1575
|
-
|
|
1576
1370
|
function regexSafe(val) {
|
|
1577
1371
|
return val.replace(/\$/g, '$$$$');
|
|
1578
1372
|
}
|
|
1579
|
-
|
|
1580
1373
|
var handleFormat = function handleFormat(key) {
|
|
1581
1374
|
if (key.indexOf(_this.formatSeparator) < 0) {
|
|
1582
1375
|
var path = getPathWithDefaults(data, defaultData, key);
|
|
@@ -1584,7 +1377,6 @@ var Interpolator = function () {
|
|
|
1584
1377
|
interpolationkey: key
|
|
1585
1378
|
})) : path;
|
|
1586
1379
|
}
|
|
1587
|
-
|
|
1588
1380
|
var p = key.split(_this.formatSeparator);
|
|
1589
1381
|
var k = p.shift().trim();
|
|
1590
1382
|
var f = p.join(_this.formatSeparator).trim();
|
|
@@ -1592,7 +1384,6 @@ var Interpolator = function () {
|
|
|
1592
1384
|
interpolationkey: k
|
|
1593
1385
|
}));
|
|
1594
1386
|
};
|
|
1595
|
-
|
|
1596
1387
|
this.resetRegExp();
|
|
1597
1388
|
var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
1598
1389
|
var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
@@ -1609,11 +1400,9 @@ var Interpolator = function () {
|
|
|
1609
1400
|
}];
|
|
1610
1401
|
todos.forEach(function (todo) {
|
|
1611
1402
|
replaces = 0;
|
|
1612
|
-
|
|
1613
1403
|
while (match = todo.regex.exec(str)) {
|
|
1614
1404
|
var matchedVar = match[1].trim();
|
|
1615
1405
|
value = handleFormat(matchedVar);
|
|
1616
|
-
|
|
1617
1406
|
if (value === undefined) {
|
|
1618
1407
|
if (typeof missingInterpolationHandler === 'function') {
|
|
1619
1408
|
var temp = missingInterpolationHandler(str, match, options);
|
|
@@ -1625,25 +1414,20 @@ var Interpolator = function () {
|
|
|
1625
1414
|
continue;
|
|
1626
1415
|
} else {
|
|
1627
1416
|
_this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
|
|
1628
|
-
|
|
1629
1417
|
value = '';
|
|
1630
1418
|
}
|
|
1631
1419
|
} else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
|
|
1632
1420
|
value = makeString(value);
|
|
1633
1421
|
}
|
|
1634
|
-
|
|
1635
1422
|
var safeValue = todo.safeValue(value);
|
|
1636
1423
|
str = str.replace(match[0], safeValue);
|
|
1637
|
-
|
|
1638
1424
|
if (skipOnVariables) {
|
|
1639
1425
|
todo.regex.lastIndex += value.length;
|
|
1640
1426
|
todo.regex.lastIndex -= match[0].length;
|
|
1641
1427
|
} else {
|
|
1642
1428
|
todo.regex.lastIndex = 0;
|
|
1643
1429
|
}
|
|
1644
|
-
|
|
1645
1430
|
replaces++;
|
|
1646
|
-
|
|
1647
1431
|
if (replaces >= _this.maxReplaces) {
|
|
1648
1432
|
break;
|
|
1649
1433
|
}
|
|
@@ -1655,16 +1439,10 @@ var Interpolator = function () {
|
|
|
1655
1439
|
key: "nest",
|
|
1656
1440
|
value: function nest(str, fc) {
|
|
1657
1441
|
var _this2 = this;
|
|
1658
|
-
|
|
1659
1442
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1660
1443
|
var match;
|
|
1661
1444
|
var value;
|
|
1662
|
-
|
|
1663
|
-
var clonedOptions = _objectSpread$3$1({}, options);
|
|
1664
|
-
|
|
1665
|
-
clonedOptions.applyPostProcessor = false;
|
|
1666
|
-
delete clonedOptions.defaultValue;
|
|
1667
|
-
|
|
1445
|
+
var clonedOptions;
|
|
1668
1446
|
function handleHasOptions(key, inheritedOptions) {
|
|
1669
1447
|
var sep = this.nestingOptionsSeparator;
|
|
1670
1448
|
if (key.indexOf(sep) < 0) return key;
|
|
@@ -1672,8 +1450,11 @@ var Interpolator = function () {
|
|
|
1672
1450
|
var optionsString = "{".concat(c[1]);
|
|
1673
1451
|
key = c[0];
|
|
1674
1452
|
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
1675
|
-
|
|
1676
|
-
|
|
1453
|
+
var matchedSingleQuotes = optionsString.match(/'/g);
|
|
1454
|
+
var matchedDoubleQuotes = optionsString.match(/"/g);
|
|
1455
|
+
if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
|
|
1456
|
+
optionsString = optionsString.replace(/'/g, '"');
|
|
1457
|
+
}
|
|
1677
1458
|
try {
|
|
1678
1459
|
clonedOptions = JSON.parse(optionsString);
|
|
1679
1460
|
if (inheritedOptions) clonedOptions = _objectSpread$3$1(_objectSpread$3$1({}, inheritedOptions), clonedOptions);
|
|
@@ -1681,15 +1462,16 @@ var Interpolator = function () {
|
|
|
1681
1462
|
this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
|
|
1682
1463
|
return "".concat(key).concat(sep).concat(optionsString);
|
|
1683
1464
|
}
|
|
1684
|
-
|
|
1685
1465
|
delete clonedOptions.defaultValue;
|
|
1686
1466
|
return key;
|
|
1687
1467
|
}
|
|
1688
|
-
|
|
1689
1468
|
while (match = this.nestingRegexp.exec(str)) {
|
|
1690
1469
|
var formatters = [];
|
|
1470
|
+
clonedOptions = _objectSpread$3$1({}, options);
|
|
1471
|
+
clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
|
|
1472
|
+
clonedOptions.applyPostProcessor = false;
|
|
1473
|
+
delete clonedOptions.defaultValue;
|
|
1691
1474
|
var doReduce = false;
|
|
1692
|
-
|
|
1693
1475
|
if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
|
|
1694
1476
|
var r = match[1].split(this.formatSeparator).map(function (elem) {
|
|
1695
1477
|
return elem.trim();
|
|
@@ -1698,16 +1480,13 @@ var Interpolator = function () {
|
|
|
1698
1480
|
formatters = r;
|
|
1699
1481
|
doReduce = true;
|
|
1700
1482
|
}
|
|
1701
|
-
|
|
1702
1483
|
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
1703
1484
|
if (value && match[0] === str && typeof value !== 'string') return value;
|
|
1704
1485
|
if (typeof value !== 'string') value = makeString(value);
|
|
1705
|
-
|
|
1706
1486
|
if (!value) {
|
|
1707
1487
|
this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
|
|
1708
1488
|
value = '';
|
|
1709
1489
|
}
|
|
1710
|
-
|
|
1711
1490
|
if (doReduce) {
|
|
1712
1491
|
value = formatters.reduce(function (v, f) {
|
|
1713
1492
|
return _this2.format(v, f, options.lng, _objectSpread$3$1(_objectSpread$3$1({}, options), {}, {
|
|
@@ -1715,31 +1494,24 @@ var Interpolator = function () {
|
|
|
1715
1494
|
}));
|
|
1716
1495
|
}, value.trim());
|
|
1717
1496
|
}
|
|
1718
|
-
|
|
1719
1497
|
str = str.replace(match[0], value);
|
|
1720
1498
|
this.regexp.lastIndex = 0;
|
|
1721
1499
|
}
|
|
1722
|
-
|
|
1723
1500
|
return str;
|
|
1724
1501
|
}
|
|
1725
1502
|
}]);
|
|
1726
|
-
|
|
1727
1503
|
return Interpolator;
|
|
1728
1504
|
}();
|
|
1729
1505
|
|
|
1730
|
-
function ownKeys$
|
|
1731
|
-
|
|
1732
|
-
function _objectSpread$4$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1733
|
-
|
|
1506
|
+
function ownKeys$2$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1507
|
+
function _objectSpread$2$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1734
1508
|
function parseFormatStr(formatStr) {
|
|
1735
1509
|
var formatName = formatStr.toLowerCase().trim();
|
|
1736
1510
|
var formatOptions = {};
|
|
1737
|
-
|
|
1738
1511
|
if (formatStr.indexOf('(') > -1) {
|
|
1739
1512
|
var p = formatStr.split('(');
|
|
1740
1513
|
formatName = p[0].toLowerCase().trim();
|
|
1741
1514
|
var optStr = p[1].substring(0, p[1].length - 1);
|
|
1742
|
-
|
|
1743
1515
|
if (formatName === 'currency' && optStr.indexOf(':') < 0) {
|
|
1744
1516
|
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
1745
1517
|
} else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
|
|
@@ -1748,12 +1520,10 @@ function parseFormatStr(formatStr) {
|
|
|
1748
1520
|
var opts = optStr.split(';');
|
|
1749
1521
|
opts.forEach(function (opt) {
|
|
1750
1522
|
if (!opt) return;
|
|
1751
|
-
|
|
1752
1523
|
var _opt$split = opt.split(':'),
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1524
|
+
_opt$split2 = _toArray(_opt$split),
|
|
1525
|
+
key = _opt$split2[0],
|
|
1526
|
+
rest = _opt$split2.slice(1);
|
|
1757
1527
|
var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
|
|
1758
1528
|
if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
|
|
1759
1529
|
if (val === 'false') formatOptions[key.trim()] = false;
|
|
@@ -1762,43 +1532,65 @@ function parseFormatStr(formatStr) {
|
|
|
1762
1532
|
});
|
|
1763
1533
|
}
|
|
1764
1534
|
}
|
|
1765
|
-
|
|
1766
1535
|
return {
|
|
1767
1536
|
formatName: formatName,
|
|
1768
1537
|
formatOptions: formatOptions
|
|
1769
1538
|
};
|
|
1770
1539
|
}
|
|
1771
|
-
|
|
1540
|
+
function createCachedFormatter(fn) {
|
|
1541
|
+
var cache = {};
|
|
1542
|
+
return function invokeFormatter(val, lng, options) {
|
|
1543
|
+
var key = lng + JSON.stringify(options);
|
|
1544
|
+
var formatter = cache[key];
|
|
1545
|
+
if (!formatter) {
|
|
1546
|
+
formatter = fn(lng, options);
|
|
1547
|
+
cache[key] = formatter;
|
|
1548
|
+
}
|
|
1549
|
+
return formatter(val);
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1772
1552
|
var Formatter = function () {
|
|
1773
1553
|
function Formatter() {
|
|
1774
1554
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1775
|
-
|
|
1776
1555
|
_classCallCheck(this, Formatter);
|
|
1777
|
-
|
|
1778
1556
|
this.logger = baseLogger.create('formatter');
|
|
1779
1557
|
this.options = options;
|
|
1780
1558
|
this.formats = {
|
|
1781
|
-
number: function
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1559
|
+
number: createCachedFormatter(function (lng, options) {
|
|
1560
|
+
var formatter = new Intl.NumberFormat(lng, options);
|
|
1561
|
+
return function (val) {
|
|
1562
|
+
return formatter.format(val);
|
|
1563
|
+
};
|
|
1564
|
+
}),
|
|
1565
|
+
currency: createCachedFormatter(function (lng, options) {
|
|
1566
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$2$1(_objectSpread$2$1({}, options), {}, {
|
|
1786
1567
|
style: 'currency'
|
|
1787
|
-
}))
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
},
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
}
|
|
1568
|
+
}));
|
|
1569
|
+
return function (val) {
|
|
1570
|
+
return formatter.format(val);
|
|
1571
|
+
};
|
|
1572
|
+
}),
|
|
1573
|
+
datetime: createCachedFormatter(function (lng, options) {
|
|
1574
|
+
var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2$1({}, options));
|
|
1575
|
+
return function (val) {
|
|
1576
|
+
return formatter.format(val);
|
|
1577
|
+
};
|
|
1578
|
+
}),
|
|
1579
|
+
relativetime: createCachedFormatter(function (lng, options) {
|
|
1580
|
+
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2$1({}, options));
|
|
1581
|
+
return function (val) {
|
|
1582
|
+
return formatter.format(val, options.range || 'day');
|
|
1583
|
+
};
|
|
1584
|
+
}),
|
|
1585
|
+
list: createCachedFormatter(function (lng, options) {
|
|
1586
|
+
var formatter = new Intl.ListFormat(lng, _objectSpread$2$1({}, options));
|
|
1587
|
+
return function (val) {
|
|
1588
|
+
return formatter.format(val);
|
|
1589
|
+
};
|
|
1590
|
+
})
|
|
1798
1591
|
};
|
|
1799
1592
|
this.init(options);
|
|
1800
1593
|
}
|
|
1801
|
-
|
|
1802
1594
|
_createClass(Formatter, [{
|
|
1803
1595
|
key: "init",
|
|
1804
1596
|
value: function init(services) {
|
|
@@ -1813,76 +1605,62 @@ var Formatter = function () {
|
|
|
1813
1605
|
value: function add(name, fc) {
|
|
1814
1606
|
this.formats[name.toLowerCase().trim()] = fc;
|
|
1815
1607
|
}
|
|
1608
|
+
}, {
|
|
1609
|
+
key: "addCached",
|
|
1610
|
+
value: function addCached(name, fc) {
|
|
1611
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1612
|
+
}
|
|
1816
1613
|
}, {
|
|
1817
1614
|
key: "format",
|
|
1818
1615
|
value: function format(value, _format, lng, options) {
|
|
1819
1616
|
var _this = this;
|
|
1820
|
-
|
|
1821
1617
|
var formats = _format.split(this.formatSeparator);
|
|
1822
|
-
|
|
1823
1618
|
var result = formats.reduce(function (mem, f) {
|
|
1824
1619
|
var _parseFormatStr = parseFormatStr(f),
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1620
|
+
formatName = _parseFormatStr.formatName,
|
|
1621
|
+
formatOptions = _parseFormatStr.formatOptions;
|
|
1828
1622
|
if (_this.formats[formatName]) {
|
|
1829
1623
|
var formatted = mem;
|
|
1830
|
-
|
|
1831
1624
|
try {
|
|
1832
1625
|
var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
|
|
1833
1626
|
var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1834
|
-
formatted = _this.formats[formatName](mem, l, _objectSpread$
|
|
1627
|
+
formatted = _this.formats[formatName](mem, l, _objectSpread$2$1(_objectSpread$2$1(_objectSpread$2$1({}, formatOptions), options), valOptions));
|
|
1835
1628
|
} catch (error) {
|
|
1836
1629
|
_this.logger.warn(error);
|
|
1837
1630
|
}
|
|
1838
|
-
|
|
1839
1631
|
return formatted;
|
|
1840
1632
|
} else {
|
|
1841
1633
|
_this.logger.warn("there was no format function for ".concat(formatName));
|
|
1842
1634
|
}
|
|
1843
|
-
|
|
1844
1635
|
return mem;
|
|
1845
1636
|
}, value);
|
|
1846
1637
|
return result;
|
|
1847
1638
|
}
|
|
1848
1639
|
}]);
|
|
1849
|
-
|
|
1850
1640
|
return Formatter;
|
|
1851
1641
|
}();
|
|
1852
1642
|
|
|
1853
|
-
function ownKeys$
|
|
1854
|
-
|
|
1855
|
-
function
|
|
1856
|
-
|
|
1857
|
-
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
1858
|
-
|
|
1859
|
-
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1860
|
-
|
|
1643
|
+
function ownKeys$1$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1644
|
+
function _objectSpread$1$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1645
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
1646
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1861
1647
|
function removePending(q, name) {
|
|
1862
1648
|
if (q.pending[name] !== undefined) {
|
|
1863
1649
|
delete q.pending[name];
|
|
1864
1650
|
q.pendingCount--;
|
|
1865
1651
|
}
|
|
1866
1652
|
}
|
|
1867
|
-
|
|
1868
1653
|
var Connector = function (_EventEmitter) {
|
|
1869
1654
|
_inherits(Connector, _EventEmitter);
|
|
1870
|
-
|
|
1871
|
-
var _super = _createSuper$2(Connector);
|
|
1872
|
-
|
|
1655
|
+
var _super = _createSuper$1(Connector);
|
|
1873
1656
|
function Connector(backend, store, services) {
|
|
1874
1657
|
var _this;
|
|
1875
|
-
|
|
1876
1658
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1877
|
-
|
|
1878
1659
|
_classCallCheck(this, Connector);
|
|
1879
|
-
|
|
1880
1660
|
_this = _super.call(this);
|
|
1881
|
-
|
|
1882
1661
|
if (isIE10) {
|
|
1883
1662
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
1884
1663
|
}
|
|
1885
|
-
|
|
1886
1664
|
_this.backend = backend;
|
|
1887
1665
|
_this.store = store;
|
|
1888
1666
|
_this.services = services;
|
|
@@ -1892,21 +1670,19 @@ var Connector = function (_EventEmitter) {
|
|
|
1892
1670
|
_this.waitingReads = [];
|
|
1893
1671
|
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
1894
1672
|
_this.readingCalls = 0;
|
|
1673
|
+
_this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
1674
|
+
_this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
1895
1675
|
_this.state = {};
|
|
1896
1676
|
_this.queue = [];
|
|
1897
|
-
|
|
1898
1677
|
if (_this.backend && _this.backend.init) {
|
|
1899
1678
|
_this.backend.init(services, options.backend, options);
|
|
1900
1679
|
}
|
|
1901
|
-
|
|
1902
1680
|
return _this;
|
|
1903
1681
|
}
|
|
1904
|
-
|
|
1905
1682
|
_createClass(Connector, [{
|
|
1906
1683
|
key: "queueLoad",
|
|
1907
1684
|
value: function queueLoad(languages, namespaces, options, callback) {
|
|
1908
1685
|
var _this2 = this;
|
|
1909
|
-
|
|
1910
1686
|
var toLoad = {};
|
|
1911
1687
|
var pending = {};
|
|
1912
1688
|
var toLoadLanguages = {};
|
|
@@ -1915,7 +1691,6 @@ var Connector = function (_EventEmitter) {
|
|
|
1915
1691
|
var hasAllNamespaces = true;
|
|
1916
1692
|
namespaces.forEach(function (ns) {
|
|
1917
1693
|
var name = "".concat(lng, "|").concat(ns);
|
|
1918
|
-
|
|
1919
1694
|
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
1920
1695
|
_this2.state[name] = 2;
|
|
1921
1696
|
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
@@ -1930,7 +1705,6 @@ var Connector = function (_EventEmitter) {
|
|
|
1930
1705
|
});
|
|
1931
1706
|
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1932
1707
|
});
|
|
1933
|
-
|
|
1934
1708
|
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
1935
1709
|
this.queue.push({
|
|
1936
1710
|
pending: pending,
|
|
@@ -1940,7 +1714,6 @@ var Connector = function (_EventEmitter) {
|
|
|
1940
1714
|
callback: callback
|
|
1941
1715
|
});
|
|
1942
1716
|
}
|
|
1943
|
-
|
|
1944
1717
|
return {
|
|
1945
1718
|
toLoad: Object.keys(toLoad),
|
|
1946
1719
|
pending: Object.keys(pending),
|
|
@@ -1955,23 +1728,19 @@ var Connector = function (_EventEmitter) {
|
|
|
1955
1728
|
var lng = s[0];
|
|
1956
1729
|
var ns = s[1];
|
|
1957
1730
|
if (err) this.emit('failedLoading', lng, ns, err);
|
|
1958
|
-
|
|
1959
1731
|
if (data) {
|
|
1960
1732
|
this.store.addResourceBundle(lng, ns, data);
|
|
1961
1733
|
}
|
|
1962
|
-
|
|
1963
1734
|
this.state[name] = err ? -1 : 2;
|
|
1964
1735
|
var loaded = {};
|
|
1965
1736
|
this.queue.forEach(function (q) {
|
|
1966
1737
|
pushPath(q.loaded, [lng], ns);
|
|
1967
1738
|
removePending(q, name);
|
|
1968
1739
|
if (err) q.errors.push(err);
|
|
1969
|
-
|
|
1970
1740
|
if (q.pendingCount === 0 && !q.done) {
|
|
1971
1741
|
Object.keys(q.loaded).forEach(function (l) {
|
|
1972
1742
|
if (!loaded[l]) loaded[l] = {};
|
|
1973
1743
|
var loadedKeys = q.loaded[l];
|
|
1974
|
-
|
|
1975
1744
|
if (loadedKeys.length) {
|
|
1976
1745
|
loadedKeys.forEach(function (ns) {
|
|
1977
1746
|
if (loaded[l][ns] === undefined) loaded[l][ns] = true;
|
|
@@ -1979,7 +1748,6 @@ var Connector = function (_EventEmitter) {
|
|
|
1979
1748
|
}
|
|
1980
1749
|
});
|
|
1981
1750
|
q.done = true;
|
|
1982
|
-
|
|
1983
1751
|
if (q.errors.length) {
|
|
1984
1752
|
q.callback(q.errors);
|
|
1985
1753
|
} else {
|
|
@@ -1996,12 +1764,10 @@ var Connector = function (_EventEmitter) {
|
|
|
1996
1764
|
key: "read",
|
|
1997
1765
|
value: function read(lng, ns, fcName) {
|
|
1998
1766
|
var _this3 = this;
|
|
1999
|
-
|
|
2000
1767
|
var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
2001
|
-
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] :
|
|
1768
|
+
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
|
|
2002
1769
|
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
2003
1770
|
if (!lng.length) return callback(null, {});
|
|
2004
|
-
|
|
2005
1771
|
if (this.readingCalls >= this.maxParallelReads) {
|
|
2006
1772
|
this.waitingReads.push({
|
|
2007
1773
|
lng: lng,
|
|
@@ -2013,49 +1779,56 @@ var Connector = function (_EventEmitter) {
|
|
|
2013
1779
|
});
|
|
2014
1780
|
return;
|
|
2015
1781
|
}
|
|
2016
|
-
|
|
2017
1782
|
this.readingCalls++;
|
|
2018
|
-
|
|
2019
|
-
if (err && data && tried < 5) {
|
|
2020
|
-
setTimeout(function () {
|
|
2021
|
-
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
2022
|
-
}, wait);
|
|
2023
|
-
return;
|
|
2024
|
-
}
|
|
2025
|
-
|
|
1783
|
+
var resolver = function resolver(err, data) {
|
|
2026
1784
|
_this3.readingCalls--;
|
|
2027
|
-
|
|
2028
1785
|
if (_this3.waitingReads.length > 0) {
|
|
2029
1786
|
var next = _this3.waitingReads.shift();
|
|
2030
|
-
|
|
2031
1787
|
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
2032
1788
|
}
|
|
2033
|
-
|
|
1789
|
+
if (err && data && tried < _this3.maxRetries) {
|
|
1790
|
+
setTimeout(function () {
|
|
1791
|
+
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
1792
|
+
}, wait);
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
2034
1795
|
callback(err, data);
|
|
2035
|
-
}
|
|
1796
|
+
};
|
|
1797
|
+
var fc = this.backend[fcName].bind(this.backend);
|
|
1798
|
+
if (fc.length === 2) {
|
|
1799
|
+
try {
|
|
1800
|
+
var r = fc(lng, ns);
|
|
1801
|
+
if (r && typeof r.then === 'function') {
|
|
1802
|
+
r.then(function (data) {
|
|
1803
|
+
return resolver(null, data);
|
|
1804
|
+
})["catch"](resolver);
|
|
1805
|
+
} else {
|
|
1806
|
+
resolver(null, r);
|
|
1807
|
+
}
|
|
1808
|
+
} catch (err) {
|
|
1809
|
+
resolver(err);
|
|
1810
|
+
}
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
return fc(lng, ns, resolver);
|
|
2036
1814
|
}
|
|
2037
1815
|
}, {
|
|
2038
1816
|
key: "prepareLoading",
|
|
2039
1817
|
value: function prepareLoading(languages, namespaces) {
|
|
2040
1818
|
var _this4 = this;
|
|
2041
|
-
|
|
2042
1819
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2043
1820
|
var callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
2044
|
-
|
|
2045
1821
|
if (!this.backend) {
|
|
2046
1822
|
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
|
2047
1823
|
return callback && callback();
|
|
2048
1824
|
}
|
|
2049
|
-
|
|
2050
1825
|
if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
|
|
2051
1826
|
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
2052
1827
|
var toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
2053
|
-
|
|
2054
1828
|
if (!toLoad.toLoad.length) {
|
|
2055
1829
|
if (!toLoad.pending.length) callback();
|
|
2056
1830
|
return null;
|
|
2057
1831
|
}
|
|
2058
|
-
|
|
2059
1832
|
toLoad.toLoad.forEach(function (name) {
|
|
2060
1833
|
_this4.loadOne(name);
|
|
2061
1834
|
});
|
|
@@ -2076,7 +1849,6 @@ var Connector = function (_EventEmitter) {
|
|
|
2076
1849
|
key: "loadOne",
|
|
2077
1850
|
value: function loadOne(name) {
|
|
2078
1851
|
var _this5 = this;
|
|
2079
|
-
|
|
2080
1852
|
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2081
1853
|
var s = name.split('|');
|
|
2082
1854
|
var lng = s[0];
|
|
@@ -2084,7 +1856,6 @@ var Connector = function (_EventEmitter) {
|
|
|
2084
1856
|
this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
|
|
2085
1857
|
if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
|
|
2086
1858
|
if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
|
|
2087
|
-
|
|
2088
1859
|
_this5.loaded(name, err, data);
|
|
2089
1860
|
});
|
|
2090
1861
|
}
|
|
@@ -2092,25 +1863,43 @@ var Connector = function (_EventEmitter) {
|
|
|
2092
1863
|
key: "saveMissing",
|
|
2093
1864
|
value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
|
2094
1865
|
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
2095
|
-
|
|
1866
|
+
var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};
|
|
2096
1867
|
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
|
|
2097
1868
|
this.logger.warn("did not save key \"".concat(key, "\" as the namespace \"").concat(namespace, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
|
|
2098
1869
|
return;
|
|
2099
1870
|
}
|
|
2100
|
-
|
|
2101
1871
|
if (key === undefined || key === null || key === '') return;
|
|
2102
|
-
|
|
2103
1872
|
if (this.backend && this.backend.create) {
|
|
2104
|
-
|
|
1873
|
+
var opts = _objectSpread$1$1(_objectSpread$1$1({}, options), {}, {
|
|
2105
1874
|
isUpdate: isUpdate
|
|
2106
|
-
})
|
|
1875
|
+
});
|
|
1876
|
+
var fc = this.backend.create.bind(this.backend);
|
|
1877
|
+
if (fc.length < 6) {
|
|
1878
|
+
try {
|
|
1879
|
+
var r;
|
|
1880
|
+
if (fc.length === 5) {
|
|
1881
|
+
r = fc(languages, namespace, key, fallbackValue, opts);
|
|
1882
|
+
} else {
|
|
1883
|
+
r = fc(languages, namespace, key, fallbackValue);
|
|
1884
|
+
}
|
|
1885
|
+
if (r && typeof r.then === 'function') {
|
|
1886
|
+
r.then(function (data) {
|
|
1887
|
+
return clb(null, data);
|
|
1888
|
+
})["catch"](clb);
|
|
1889
|
+
} else {
|
|
1890
|
+
clb(null, r);
|
|
1891
|
+
}
|
|
1892
|
+
} catch (err) {
|
|
1893
|
+
clb(err);
|
|
1894
|
+
}
|
|
1895
|
+
} else {
|
|
1896
|
+
fc(languages, namespace, key, fallbackValue, clb, opts);
|
|
1897
|
+
}
|
|
2107
1898
|
}
|
|
2108
|
-
|
|
2109
1899
|
if (!languages || !languages[0]) return;
|
|
2110
1900
|
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
|
2111
1901
|
}
|
|
2112
1902
|
}]);
|
|
2113
|
-
|
|
2114
1903
|
return Connector;
|
|
2115
1904
|
}(EventEmitter);
|
|
2116
1905
|
|
|
@@ -2153,14 +1942,12 @@ function get() {
|
|
|
2153
1942
|
if (_typeof(args[1]) === 'object') ret = args[1];
|
|
2154
1943
|
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
|
2155
1944
|
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
|
2156
|
-
|
|
2157
1945
|
if (_typeof(args[2]) === 'object' || _typeof(args[3]) === 'object') {
|
|
2158
1946
|
var options = args[3] || args[2];
|
|
2159
1947
|
Object.keys(options).forEach(function (key) {
|
|
2160
1948
|
ret[key] = options[key];
|
|
2161
1949
|
});
|
|
2162
1950
|
}
|
|
2163
|
-
|
|
2164
1951
|
return ret;
|
|
2165
1952
|
},
|
|
2166
1953
|
interpolation: {
|
|
@@ -2184,24 +1971,17 @@ function transformOptions(options) {
|
|
|
2184
1971
|
if (typeof options.ns === 'string') options.ns = [options.ns];
|
|
2185
1972
|
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
|
2186
1973
|
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
|
|
2187
|
-
|
|
2188
1974
|
if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
|
|
2189
1975
|
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
2190
1976
|
}
|
|
2191
|
-
|
|
2192
1977
|
return options;
|
|
2193
1978
|
}
|
|
2194
1979
|
|
|
2195
|
-
function ownKeys$
|
|
2196
|
-
|
|
2197
|
-
function
|
|
2198
|
-
|
|
2199
|
-
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
2200
|
-
|
|
2201
|
-
function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2202
|
-
|
|
1980
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1981
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1982
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
1983
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2203
1984
|
function noop$1() {}
|
|
2204
|
-
|
|
2205
1985
|
function bindMemberFunctions(inst) {
|
|
2206
1986
|
var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
2207
1987
|
mems.forEach(function (mem) {
|
|
@@ -2210,26 +1990,18 @@ function bindMemberFunctions(inst) {
|
|
|
2210
1990
|
}
|
|
2211
1991
|
});
|
|
2212
1992
|
}
|
|
2213
|
-
|
|
2214
1993
|
var I18n = function (_EventEmitter) {
|
|
2215
1994
|
_inherits(I18n, _EventEmitter);
|
|
2216
|
-
|
|
2217
|
-
var _super = _createSuper$3(I18n);
|
|
2218
|
-
|
|
1995
|
+
var _super = _createSuper(I18n);
|
|
2219
1996
|
function I18n() {
|
|
2220
1997
|
var _this;
|
|
2221
|
-
|
|
2222
1998
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2223
1999
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2224
|
-
|
|
2225
2000
|
_classCallCheck(this, I18n);
|
|
2226
|
-
|
|
2227
2001
|
_this = _super.call(this);
|
|
2228
|
-
|
|
2229
2002
|
if (isIE10) {
|
|
2230
2003
|
EventEmitter.call(_assertThisInitialized(_this));
|
|
2231
2004
|
}
|
|
2232
|
-
|
|
2233
2005
|
_this.options = transformOptions(options);
|
|
2234
2006
|
_this.services = {};
|
|
2235
2007
|
_this.logger = baseLogger;
|
|
@@ -2237,79 +2009,62 @@ var I18n = function (_EventEmitter) {
|
|
|
2237
2009
|
external: []
|
|
2238
2010
|
};
|
|
2239
2011
|
bindMemberFunctions(_assertThisInitialized(_this));
|
|
2240
|
-
|
|
2241
2012
|
if (callback && !_this.isInitialized && !options.isClone) {
|
|
2242
2013
|
if (!_this.options.initImmediate) {
|
|
2243
2014
|
_this.init(options, callback);
|
|
2244
|
-
|
|
2245
2015
|
return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
|
|
2246
2016
|
}
|
|
2247
|
-
|
|
2248
2017
|
setTimeout(function () {
|
|
2249
2018
|
_this.init(options, callback);
|
|
2250
2019
|
}, 0);
|
|
2251
2020
|
}
|
|
2252
|
-
|
|
2253
2021
|
return _this;
|
|
2254
2022
|
}
|
|
2255
|
-
|
|
2256
2023
|
_createClass(I18n, [{
|
|
2257
2024
|
key: "init",
|
|
2258
2025
|
value: function init() {
|
|
2259
2026
|
var _this2 = this;
|
|
2260
|
-
|
|
2261
2027
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2262
2028
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2263
|
-
|
|
2264
2029
|
if (typeof options === 'function') {
|
|
2265
2030
|
callback = options;
|
|
2266
2031
|
options = {};
|
|
2267
2032
|
}
|
|
2268
|
-
|
|
2269
|
-
if (!options.defaultNS && options.ns) {
|
|
2033
|
+
if (!options.defaultNS && options.defaultNS !== false && options.ns) {
|
|
2270
2034
|
if (typeof options.ns === 'string') {
|
|
2271
2035
|
options.defaultNS = options.ns;
|
|
2272
2036
|
} else if (options.ns.indexOf('translation') < 0) {
|
|
2273
2037
|
options.defaultNS = options.ns[0];
|
|
2274
2038
|
}
|
|
2275
2039
|
}
|
|
2276
|
-
|
|
2277
2040
|
var defOpts = get();
|
|
2278
|
-
this.options = _objectSpread$
|
|
2279
|
-
|
|
2041
|
+
this.options = _objectSpread$9(_objectSpread$9(_objectSpread$9({}, defOpts), this.options), transformOptions(options));
|
|
2280
2042
|
if (this.options.compatibilityAPI !== 'v1') {
|
|
2281
|
-
this.options.interpolation = _objectSpread$
|
|
2043
|
+
this.options.interpolation = _objectSpread$9(_objectSpread$9({}, defOpts.interpolation), this.options.interpolation);
|
|
2282
2044
|
}
|
|
2283
|
-
|
|
2284
2045
|
if (options.keySeparator !== undefined) {
|
|
2285
2046
|
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
2286
2047
|
}
|
|
2287
|
-
|
|
2288
2048
|
if (options.nsSeparator !== undefined) {
|
|
2289
2049
|
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
2290
2050
|
}
|
|
2291
|
-
|
|
2292
2051
|
function createClassOnDemand(ClassOrObject) {
|
|
2293
2052
|
if (!ClassOrObject) return null;
|
|
2294
2053
|
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
2295
2054
|
return ClassOrObject;
|
|
2296
2055
|
}
|
|
2297
|
-
|
|
2298
2056
|
if (!this.options.isClone) {
|
|
2299
2057
|
if (this.modules.logger) {
|
|
2300
2058
|
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
2301
2059
|
} else {
|
|
2302
2060
|
baseLogger.init(null, this.options);
|
|
2303
2061
|
}
|
|
2304
|
-
|
|
2305
2062
|
var formatter;
|
|
2306
|
-
|
|
2307
2063
|
if (this.modules.formatter) {
|
|
2308
2064
|
formatter = this.modules.formatter;
|
|
2309
2065
|
} else if (typeof Intl !== 'undefined') {
|
|
2310
2066
|
formatter = Formatter;
|
|
2311
2067
|
}
|
|
2312
|
-
|
|
2313
2068
|
var lu = new LanguageUtil(this.options);
|
|
2314
2069
|
this.store = new ResourceStore(this.options.resources, this.options);
|
|
2315
2070
|
var s = this.services;
|
|
@@ -2321,13 +2076,11 @@ var I18n = function (_EventEmitter) {
|
|
|
2321
2076
|
compatibilityJSON: this.options.compatibilityJSON,
|
|
2322
2077
|
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
2323
2078
|
});
|
|
2324
|
-
|
|
2325
2079
|
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
2326
2080
|
s.formatter = createClassOnDemand(formatter);
|
|
2327
2081
|
s.formatter.init(s, this.options);
|
|
2328
2082
|
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
2329
2083
|
}
|
|
2330
|
-
|
|
2331
2084
|
s.interpolator = new Interpolator(this.options);
|
|
2332
2085
|
s.utils = {
|
|
2333
2086
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
@@ -2337,50 +2090,40 @@ var I18n = function (_EventEmitter) {
|
|
|
2337
2090
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2338
2091
|
args[_key - 1] = arguments[_key];
|
|
2339
2092
|
}
|
|
2340
|
-
|
|
2341
2093
|
_this2.emit.apply(_this2, [event].concat(args));
|
|
2342
2094
|
});
|
|
2343
|
-
|
|
2344
2095
|
if (this.modules.languageDetector) {
|
|
2345
2096
|
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
2346
|
-
s.languageDetector.init(s, this.options.detection, this.options);
|
|
2097
|
+
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
|
2347
2098
|
}
|
|
2348
|
-
|
|
2349
2099
|
if (this.modules.i18nFormat) {
|
|
2350
2100
|
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
2351
2101
|
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
|
2352
2102
|
}
|
|
2353
|
-
|
|
2354
2103
|
this.translator = new Translator(this.services, this.options);
|
|
2355
2104
|
this.translator.on('*', function (event) {
|
|
2356
2105
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2357
2106
|
args[_key2 - 1] = arguments[_key2];
|
|
2358
2107
|
}
|
|
2359
|
-
|
|
2360
2108
|
_this2.emit.apply(_this2, [event].concat(args));
|
|
2361
2109
|
});
|
|
2362
2110
|
this.modules.external.forEach(function (m) {
|
|
2363
2111
|
if (m.init) m.init(_this2);
|
|
2364
2112
|
});
|
|
2365
2113
|
}
|
|
2366
|
-
|
|
2367
2114
|
this.format = this.options.interpolation.format;
|
|
2368
2115
|
if (!callback) callback = noop$1;
|
|
2369
|
-
|
|
2370
2116
|
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
2371
2117
|
var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2372
2118
|
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
2373
2119
|
}
|
|
2374
|
-
|
|
2375
2120
|
if (!this.services.languageDetector && !this.options.lng) {
|
|
2376
2121
|
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
|
2377
2122
|
}
|
|
2378
|
-
|
|
2379
2123
|
var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
|
2380
2124
|
storeApi.forEach(function (fcName) {
|
|
2381
2125
|
_this2[fcName] = function () {
|
|
2382
2126
|
var _this2$store;
|
|
2383
|
-
|
|
2384
2127
|
return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
|
|
2385
2128
|
};
|
|
2386
2129
|
});
|
|
@@ -2388,63 +2131,48 @@ var I18n = function (_EventEmitter) {
|
|
|
2388
2131
|
storeApiChained.forEach(function (fcName) {
|
|
2389
2132
|
_this2[fcName] = function () {
|
|
2390
2133
|
var _this2$store2;
|
|
2391
|
-
|
|
2392
2134
|
(_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
|
|
2393
|
-
|
|
2394
2135
|
return _this2;
|
|
2395
2136
|
};
|
|
2396
2137
|
});
|
|
2397
2138
|
var deferred = defer();
|
|
2398
|
-
|
|
2399
2139
|
var load = function load() {
|
|
2400
2140
|
var finish = function finish(err, t) {
|
|
2401
2141
|
if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
|
|
2402
2142
|
_this2.isInitialized = true;
|
|
2403
2143
|
if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
|
|
2404
|
-
|
|
2405
2144
|
_this2.emit('initialized', _this2.options);
|
|
2406
|
-
|
|
2407
2145
|
deferred.resolve(t);
|
|
2408
2146
|
callback(err, t);
|
|
2409
2147
|
};
|
|
2410
|
-
|
|
2411
2148
|
if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
|
|
2412
|
-
|
|
2413
2149
|
_this2.changeLanguage(_this2.options.lng, finish);
|
|
2414
2150
|
};
|
|
2415
|
-
|
|
2416
2151
|
if (this.options.resources || !this.options.initImmediate) {
|
|
2417
2152
|
load();
|
|
2418
2153
|
} else {
|
|
2419
2154
|
setTimeout(load, 0);
|
|
2420
2155
|
}
|
|
2421
|
-
|
|
2422
2156
|
return deferred;
|
|
2423
2157
|
}
|
|
2424
2158
|
}, {
|
|
2425
2159
|
key: "loadResources",
|
|
2426
2160
|
value: function loadResources(language) {
|
|
2427
2161
|
var _this3 = this;
|
|
2428
|
-
|
|
2429
2162
|
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
|
|
2430
2163
|
var usedCallback = callback;
|
|
2431
2164
|
var usedLng = typeof language === 'string' ? language : this.language;
|
|
2432
2165
|
if (typeof language === 'function') usedCallback = language;
|
|
2433
|
-
|
|
2434
2166
|
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
2435
2167
|
if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
|
|
2436
2168
|
var toLoad = [];
|
|
2437
|
-
|
|
2438
2169
|
var append = function append(lng) {
|
|
2439
2170
|
if (!lng) return;
|
|
2440
|
-
|
|
2441
2171
|
var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
|
|
2442
|
-
|
|
2443
2172
|
lngs.forEach(function (l) {
|
|
2444
2173
|
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
|
2445
2174
|
});
|
|
2446
2175
|
};
|
|
2447
|
-
|
|
2448
2176
|
if (!usedLng) {
|
|
2449
2177
|
var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2450
2178
|
fallbacks.forEach(function (l) {
|
|
@@ -2453,13 +2181,11 @@ var I18n = function (_EventEmitter) {
|
|
|
2453
2181
|
} else {
|
|
2454
2182
|
append(usedLng);
|
|
2455
2183
|
}
|
|
2456
|
-
|
|
2457
2184
|
if (this.options.preload) {
|
|
2458
2185
|
this.options.preload.forEach(function (l) {
|
|
2459
2186
|
return append(l);
|
|
2460
2187
|
});
|
|
2461
2188
|
}
|
|
2462
|
-
|
|
2463
2189
|
this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
|
|
2464
2190
|
if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
|
|
2465
2191
|
usedCallback(e);
|
|
@@ -2486,35 +2212,27 @@ var I18n = function (_EventEmitter) {
|
|
|
2486
2212
|
value: function use(module) {
|
|
2487
2213
|
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
|
|
2488
2214
|
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
|
|
2489
|
-
|
|
2490
2215
|
if (module.type === 'backend') {
|
|
2491
2216
|
this.modules.backend = module;
|
|
2492
2217
|
}
|
|
2493
|
-
|
|
2494
2218
|
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
|
2495
2219
|
this.modules.logger = module;
|
|
2496
2220
|
}
|
|
2497
|
-
|
|
2498
2221
|
if (module.type === 'languageDetector') {
|
|
2499
2222
|
this.modules.languageDetector = module;
|
|
2500
2223
|
}
|
|
2501
|
-
|
|
2502
2224
|
if (module.type === 'i18nFormat') {
|
|
2503
2225
|
this.modules.i18nFormat = module;
|
|
2504
2226
|
}
|
|
2505
|
-
|
|
2506
2227
|
if (module.type === 'postProcessor') {
|
|
2507
2228
|
postProcessor.addPostProcessor(module);
|
|
2508
2229
|
}
|
|
2509
|
-
|
|
2510
2230
|
if (module.type === 'formatter') {
|
|
2511
2231
|
this.modules.formatter = module;
|
|
2512
2232
|
}
|
|
2513
|
-
|
|
2514
2233
|
if (module.type === '3rdParty') {
|
|
2515
2234
|
this.modules.external.push(module);
|
|
2516
2235
|
}
|
|
2517
|
-
|
|
2518
2236
|
return this;
|
|
2519
2237
|
}
|
|
2520
2238
|
}, {
|
|
@@ -2522,11 +2240,9 @@ var I18n = function (_EventEmitter) {
|
|
|
2522
2240
|
value: function setResolvedLanguage(l) {
|
|
2523
2241
|
if (!l || !this.languages) return;
|
|
2524
2242
|
if (['cimode', 'dev'].indexOf(l) > -1) return;
|
|
2525
|
-
|
|
2526
2243
|
for (var li = 0; li < this.languages.length; li++) {
|
|
2527
2244
|
var lngInLngs = this.languages[li];
|
|
2528
2245
|
if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
|
|
2529
|
-
|
|
2530
2246
|
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
2531
2247
|
this.resolvedLanguage = lngInLngs;
|
|
2532
2248
|
break;
|
|
@@ -2537,34 +2253,25 @@ var I18n = function (_EventEmitter) {
|
|
|
2537
2253
|
key: "changeLanguage",
|
|
2538
2254
|
value: function changeLanguage(lng, callback) {
|
|
2539
2255
|
var _this4 = this;
|
|
2540
|
-
|
|
2541
2256
|
this.isLanguageChangingTo = lng;
|
|
2542
2257
|
var deferred = defer();
|
|
2543
2258
|
this.emit('languageChanging', lng);
|
|
2544
|
-
|
|
2545
2259
|
var setLngProps = function setLngProps(l) {
|
|
2546
2260
|
_this4.language = l;
|
|
2547
2261
|
_this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
|
|
2548
2262
|
_this4.resolvedLanguage = undefined;
|
|
2549
|
-
|
|
2550
2263
|
_this4.setResolvedLanguage(l);
|
|
2551
2264
|
};
|
|
2552
|
-
|
|
2553
2265
|
var done = function done(err, l) {
|
|
2554
2266
|
if (l) {
|
|
2555
2267
|
setLngProps(l);
|
|
2556
|
-
|
|
2557
2268
|
_this4.translator.changeLanguage(l);
|
|
2558
|
-
|
|
2559
2269
|
_this4.isLanguageChangingTo = undefined;
|
|
2560
|
-
|
|
2561
2270
|
_this4.emit('languageChanged', l);
|
|
2562
|
-
|
|
2563
2271
|
_this4.logger.log('languageChanged', l);
|
|
2564
2272
|
} else {
|
|
2565
2273
|
_this4.isLanguageChangingTo = undefined;
|
|
2566
2274
|
}
|
|
2567
|
-
|
|
2568
2275
|
deferred.resolve(function () {
|
|
2569
2276
|
return _this4.t.apply(_this4, arguments);
|
|
2570
2277
|
});
|
|
@@ -2572,67 +2279,67 @@ var I18n = function (_EventEmitter) {
|
|
|
2572
2279
|
return _this4.t.apply(_this4, arguments);
|
|
2573
2280
|
});
|
|
2574
2281
|
};
|
|
2575
|
-
|
|
2576
2282
|
var setLng = function setLng(lngs) {
|
|
2577
2283
|
if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
|
|
2578
2284
|
var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
|
|
2579
|
-
|
|
2580
2285
|
if (l) {
|
|
2581
2286
|
if (!_this4.language) {
|
|
2582
2287
|
setLngProps(l);
|
|
2583
2288
|
}
|
|
2584
|
-
|
|
2585
2289
|
if (!_this4.translator.language) _this4.translator.changeLanguage(l);
|
|
2586
|
-
if (_this4.services.languageDetector) _this4.services.languageDetector.cacheUserLanguage(l);
|
|
2290
|
+
if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);
|
|
2587
2291
|
}
|
|
2588
|
-
|
|
2589
2292
|
_this4.loadResources(l, function (err) {
|
|
2590
2293
|
done(err, l);
|
|
2591
2294
|
});
|
|
2592
2295
|
};
|
|
2593
|
-
|
|
2594
2296
|
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
|
2595
2297
|
setLng(this.services.languageDetector.detect());
|
|
2596
2298
|
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
|
2597
|
-
this.services.languageDetector.detect
|
|
2299
|
+
if (this.services.languageDetector.detect.length === 0) {
|
|
2300
|
+
this.services.languageDetector.detect().then(setLng);
|
|
2301
|
+
} else {
|
|
2302
|
+
this.services.languageDetector.detect(setLng);
|
|
2303
|
+
}
|
|
2598
2304
|
} else {
|
|
2599
2305
|
setLng(lng);
|
|
2600
2306
|
}
|
|
2601
|
-
|
|
2602
2307
|
return deferred;
|
|
2603
2308
|
}
|
|
2604
2309
|
}, {
|
|
2605
2310
|
key: "getFixedT",
|
|
2606
2311
|
value: function getFixedT(lng, ns, keyPrefix) {
|
|
2607
2312
|
var _this5 = this;
|
|
2608
|
-
|
|
2609
2313
|
var fixedT = function fixedT(key, opts) {
|
|
2610
2314
|
var options;
|
|
2611
|
-
|
|
2612
2315
|
if (_typeof(opts) !== 'object') {
|
|
2613
2316
|
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
2614
2317
|
rest[_key3 - 2] = arguments[_key3];
|
|
2615
2318
|
}
|
|
2616
|
-
|
|
2617
2319
|
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
2618
2320
|
} else {
|
|
2619
|
-
options = _objectSpread$
|
|
2321
|
+
options = _objectSpread$9({}, opts);
|
|
2620
2322
|
}
|
|
2621
|
-
|
|
2622
2323
|
options.lng = options.lng || fixedT.lng;
|
|
2623
2324
|
options.lngs = options.lngs || fixedT.lngs;
|
|
2624
2325
|
options.ns = options.ns || fixedT.ns;
|
|
2326
|
+
options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
2625
2327
|
var keySeparator = _this5.options.keySeparator || '.';
|
|
2626
|
-
var resultKey
|
|
2328
|
+
var resultKey;
|
|
2329
|
+
if (options.keyPrefix && Array.isArray(key)) {
|
|
2330
|
+
resultKey = key.map(function (k) {
|
|
2331
|
+
return "".concat(options.keyPrefix).concat(keySeparator).concat(k);
|
|
2332
|
+
});
|
|
2333
|
+
} else {
|
|
2334
|
+
resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
|
|
2335
|
+
}
|
|
2627
2336
|
return _this5.t(resultKey, options);
|
|
2628
2337
|
};
|
|
2629
|
-
|
|
2630
2338
|
if (typeof lng === 'string') {
|
|
2631
2339
|
fixedT.lng = lng;
|
|
2632
2340
|
} else {
|
|
2633
2341
|
fixedT.lngs = lng;
|
|
2634
2342
|
}
|
|
2635
|
-
|
|
2636
2343
|
fixedT.ns = ns;
|
|
2637
2344
|
fixedT.keyPrefix = keyPrefix;
|
|
2638
2345
|
return fixedT;
|
|
@@ -2641,14 +2348,12 @@ var I18n = function (_EventEmitter) {
|
|
|
2641
2348
|
key: "t",
|
|
2642
2349
|
value: function t() {
|
|
2643
2350
|
var _this$translator;
|
|
2644
|
-
|
|
2645
2351
|
return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
|
|
2646
2352
|
}
|
|
2647
2353
|
}, {
|
|
2648
2354
|
key: "exists",
|
|
2649
2355
|
value: function exists() {
|
|
2650
2356
|
var _this$translator2;
|
|
2651
|
-
|
|
2652
2357
|
return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
|
|
2653
2358
|
}
|
|
2654
2359
|
}, {
|
|
@@ -2660,35 +2365,27 @@ var I18n = function (_EventEmitter) {
|
|
|
2660
2365
|
key: "hasLoadedNamespace",
|
|
2661
2366
|
value: function hasLoadedNamespace(ns) {
|
|
2662
2367
|
var _this6 = this;
|
|
2663
|
-
|
|
2664
2368
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2665
|
-
|
|
2666
2369
|
if (!this.isInitialized) {
|
|
2667
2370
|
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
|
|
2668
2371
|
return false;
|
|
2669
2372
|
}
|
|
2670
|
-
|
|
2671
2373
|
if (!this.languages || !this.languages.length) {
|
|
2672
2374
|
this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
|
|
2673
2375
|
return false;
|
|
2674
2376
|
}
|
|
2675
|
-
|
|
2676
2377
|
var lng = this.resolvedLanguage || this.languages[0];
|
|
2677
2378
|
var fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
2678
2379
|
var lastLng = this.languages[this.languages.length - 1];
|
|
2679
2380
|
if (lng.toLowerCase() === 'cimode') return true;
|
|
2680
|
-
|
|
2681
2381
|
var loadNotPending = function loadNotPending(l, n) {
|
|
2682
2382
|
var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
|
|
2683
|
-
|
|
2684
2383
|
return loadState === -1 || loadState === 2;
|
|
2685
2384
|
};
|
|
2686
|
-
|
|
2687
2385
|
if (options.precheck) {
|
|
2688
2386
|
var preResult = options.precheck(this, loadNotPending);
|
|
2689
2387
|
if (preResult !== undefined) return preResult;
|
|
2690
2388
|
}
|
|
2691
|
-
|
|
2692
2389
|
if (this.hasResourceBundle(lng, ns)) return true;
|
|
2693
2390
|
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
|
2694
2391
|
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
@@ -2698,14 +2395,11 @@ var I18n = function (_EventEmitter) {
|
|
|
2698
2395
|
key: "loadNamespaces",
|
|
2699
2396
|
value: function loadNamespaces(ns, callback) {
|
|
2700
2397
|
var _this7 = this;
|
|
2701
|
-
|
|
2702
2398
|
var deferred = defer();
|
|
2703
|
-
|
|
2704
2399
|
if (!this.options.ns) {
|
|
2705
2400
|
callback && callback();
|
|
2706
2401
|
return Promise.resolve();
|
|
2707
2402
|
}
|
|
2708
|
-
|
|
2709
2403
|
if (typeof ns === 'string') ns = [ns];
|
|
2710
2404
|
ns.forEach(function (n) {
|
|
2711
2405
|
if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
|
|
@@ -2725,12 +2419,10 @@ var I18n = function (_EventEmitter) {
|
|
|
2725
2419
|
var newLngs = lngs.filter(function (lng) {
|
|
2726
2420
|
return preloaded.indexOf(lng) < 0;
|
|
2727
2421
|
});
|
|
2728
|
-
|
|
2729
2422
|
if (!newLngs.length) {
|
|
2730
2423
|
if (callback) callback();
|
|
2731
2424
|
return Promise.resolve();
|
|
2732
2425
|
}
|
|
2733
|
-
|
|
2734
2426
|
this.options.preload = preloaded.concat(newLngs);
|
|
2735
2427
|
this.loadResources(function (err) {
|
|
2736
2428
|
deferred.resolve();
|
|
@@ -2744,26 +2436,27 @@ var I18n = function (_EventEmitter) {
|
|
|
2744
2436
|
if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
|
|
2745
2437
|
if (!lng) return 'rtl';
|
|
2746
2438
|
var rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
|
|
2747
|
-
|
|
2439
|
+
var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
|
|
2440
|
+
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2748
2441
|
}
|
|
2749
2442
|
}, {
|
|
2750
2443
|
key: "cloneInstance",
|
|
2751
2444
|
value: function cloneInstance() {
|
|
2752
2445
|
var _this8 = this;
|
|
2753
|
-
|
|
2754
2446
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2755
2447
|
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
|
|
2756
|
-
|
|
2757
|
-
var mergedOptions = _objectSpread$6$1(_objectSpread$6$1(_objectSpread$6$1({}, this.options), options), {
|
|
2448
|
+
var mergedOptions = _objectSpread$9(_objectSpread$9(_objectSpread$9({}, this.options), options), {
|
|
2758
2449
|
isClone: true
|
|
2759
2450
|
});
|
|
2760
|
-
|
|
2761
2451
|
var clone = new I18n(mergedOptions);
|
|
2452
|
+
if (options.debug !== undefined || options.prefix !== undefined) {
|
|
2453
|
+
clone.logger = clone.logger.clone(options);
|
|
2454
|
+
}
|
|
2762
2455
|
var membersToCopy = ['store', 'services', 'language'];
|
|
2763
2456
|
membersToCopy.forEach(function (m) {
|
|
2764
2457
|
clone[m] = _this8[m];
|
|
2765
2458
|
});
|
|
2766
|
-
clone.services = _objectSpread$
|
|
2459
|
+
clone.services = _objectSpread$9({}, this.services);
|
|
2767
2460
|
clone.services.utils = {
|
|
2768
2461
|
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2769
2462
|
};
|
|
@@ -2772,7 +2465,6 @@ var I18n = function (_EventEmitter) {
|
|
|
2772
2465
|
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
2773
2466
|
args[_key4 - 1] = arguments[_key4];
|
|
2774
2467
|
}
|
|
2775
|
-
|
|
2776
2468
|
clone.emit.apply(clone, [event].concat(args));
|
|
2777
2469
|
});
|
|
2778
2470
|
clone.init(mergedOptions, callback);
|
|
@@ -2794,20 +2486,18 @@ var I18n = function (_EventEmitter) {
|
|
|
2794
2486
|
};
|
|
2795
2487
|
}
|
|
2796
2488
|
}]);
|
|
2797
|
-
|
|
2798
2489
|
return I18n;
|
|
2799
2490
|
}(EventEmitter);
|
|
2800
|
-
|
|
2801
2491
|
_defineProperty(I18n, "createInstance", function () {
|
|
2802
2492
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2803
2493
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2804
2494
|
return new I18n(options, callback);
|
|
2805
2495
|
});
|
|
2806
|
-
|
|
2807
2496
|
var instance = I18n.createInstance();
|
|
2808
2497
|
instance.createInstance = I18n.createInstance;
|
|
2809
2498
|
|
|
2810
2499
|
instance.createInstance;
|
|
2500
|
+
instance.dir;
|
|
2811
2501
|
instance.init;
|
|
2812
2502
|
instance.loadResources;
|
|
2813
2503
|
instance.reloadResources;
|
|
@@ -2823,111 +2513,28 @@ instance.loadLanguages;
|
|
|
2823
2513
|
|
|
2824
2514
|
/**
|
|
2825
2515
|
* This file automatically generated from `pre-publish.js`.
|
|
2826
|
-
* Do not manually edit.
|
|
2827
|
-
*/
|
|
2828
|
-
|
|
2829
|
-
var voidElements = {
|
|
2830
|
-
"area": true,
|
|
2831
|
-
"base": true,
|
|
2832
|
-
"br": true,
|
|
2833
|
-
"col": true,
|
|
2834
|
-
"embed": true,
|
|
2835
|
-
"hr": true,
|
|
2836
|
-
"img": true,
|
|
2837
|
-
"input": true,
|
|
2838
|
-
"link": true,
|
|
2839
|
-
"meta": true,
|
|
2840
|
-
"param": true,
|
|
2841
|
-
"source": true,
|
|
2842
|
-
"track": true,
|
|
2843
|
-
"wbr": true
|
|
2844
|
-
};
|
|
2845
|
-
|
|
2846
|
-
var t=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i=/^\s*$/,s=Object.create(null);function a(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c={parse:function(e,t){t||(t={}),t.components||(t.components=s);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a("",t)},"")}};
|
|
2847
|
-
|
|
2848
|
-
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
|
|
2849
|
-
var htmlEntities = {
|
|
2850
|
-
'&': '&',
|
|
2851
|
-
'&': '&',
|
|
2852
|
-
'<': '<',
|
|
2853
|
-
'<': '<',
|
|
2854
|
-
'>': '>',
|
|
2855
|
-
'>': '>',
|
|
2856
|
-
''': "'",
|
|
2857
|
-
''': "'",
|
|
2858
|
-
'"': '"',
|
|
2859
|
-
'"': '"'
|
|
2860
|
-
};
|
|
2861
|
-
|
|
2862
|
-
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
|
|
2863
|
-
return htmlEntities[m];
|
|
2864
|
-
};
|
|
2865
|
-
|
|
2866
|
-
var unescape = function unescape(text) {
|
|
2867
|
-
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
2868
|
-
};
|
|
2869
|
-
|
|
2870
|
-
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2871
|
-
|
|
2872
|
-
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2873
|
-
var defaultOptions = {
|
|
2874
|
-
bindI18n: 'languageChanged',
|
|
2875
|
-
bindI18nStore: '',
|
|
2876
|
-
transEmptyNodeValue: '',
|
|
2877
|
-
transSupportBasicHtmlNodes: true,
|
|
2878
|
-
transWrapTextNodes: '',
|
|
2879
|
-
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
2880
|
-
useSuspense: true,
|
|
2881
|
-
unescape: unescape
|
|
2882
|
-
};
|
|
2883
|
-
var i18nInstance;
|
|
2884
|
-
var I18nContext = createContext();
|
|
2885
|
-
function setDefaults() {
|
|
2886
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2887
|
-
defaultOptions = _objectSpread$7(_objectSpread$7({}, defaultOptions), options);
|
|
2888
|
-
}
|
|
2889
|
-
function getDefaults() {
|
|
2890
|
-
return defaultOptions;
|
|
2891
|
-
}
|
|
2892
|
-
var ReportNamespaces = function () {
|
|
2893
|
-
function ReportNamespaces() {
|
|
2894
|
-
_classCallCheck$1(this, ReportNamespaces);
|
|
2895
|
-
|
|
2896
|
-
this.usedNamespaces = {};
|
|
2897
|
-
}
|
|
2898
|
-
|
|
2899
|
-
_createClass$1(ReportNamespaces, [{
|
|
2900
|
-
key: "addUsedNamespaces",
|
|
2901
|
-
value: function addUsedNamespaces(namespaces) {
|
|
2902
|
-
var _this = this;
|
|
2903
|
-
|
|
2904
|
-
namespaces.forEach(function (ns) {
|
|
2905
|
-
if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
|
|
2906
|
-
});
|
|
2907
|
-
}
|
|
2908
|
-
}, {
|
|
2909
|
-
key: "getUsedNamespaces",
|
|
2910
|
-
value: function getUsedNamespaces() {
|
|
2911
|
-
return Object.keys(this.usedNamespaces);
|
|
2912
|
-
}
|
|
2913
|
-
}]);
|
|
2914
|
-
|
|
2915
|
-
return ReportNamespaces;
|
|
2916
|
-
}();
|
|
2917
|
-
function setI18n(instance) {
|
|
2918
|
-
i18nInstance = instance;
|
|
2919
|
-
}
|
|
2920
|
-
function getI18n() {
|
|
2921
|
-
return i18nInstance;
|
|
2922
|
-
}
|
|
2923
|
-
var initReactI18next = {
|
|
2924
|
-
type: '3rdParty',
|
|
2925
|
-
init: function init(instance) {
|
|
2926
|
-
setDefaults(instance.options.react);
|
|
2927
|
-
setI18n(instance);
|
|
2928
|
-
}
|
|
2516
|
+
* Do not manually edit.
|
|
2517
|
+
*/
|
|
2518
|
+
|
|
2519
|
+
var voidElements = {
|
|
2520
|
+
"area": true,
|
|
2521
|
+
"base": true,
|
|
2522
|
+
"br": true,
|
|
2523
|
+
"col": true,
|
|
2524
|
+
"embed": true,
|
|
2525
|
+
"hr": true,
|
|
2526
|
+
"img": true,
|
|
2527
|
+
"input": true,
|
|
2528
|
+
"link": true,
|
|
2529
|
+
"meta": true,
|
|
2530
|
+
"param": true,
|
|
2531
|
+
"source": true,
|
|
2532
|
+
"track": true,
|
|
2533
|
+
"wbr": true
|
|
2929
2534
|
};
|
|
2930
2535
|
|
|
2536
|
+
var t=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i=/^\s*$/,s=Object.create(null);function a(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c={parse:function(e,t){t||(t={}),t.components||(t.components=s);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a("",t)},"")}};
|
|
2537
|
+
|
|
2931
2538
|
function warn() {
|
|
2932
2539
|
if (console && console.warn) {
|
|
2933
2540
|
var _console;
|
|
@@ -3008,12 +2615,73 @@ function hasLoadedNamespace(ns, i18n) {
|
|
|
3008
2615
|
});
|
|
3009
2616
|
}
|
|
3010
2617
|
|
|
3011
|
-
var
|
|
2618
|
+
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
2619
|
+
var htmlEntities = {
|
|
2620
|
+
'&': '&',
|
|
2621
|
+
'&': '&',
|
|
2622
|
+
'<': '<',
|
|
2623
|
+
'<': '<',
|
|
2624
|
+
'>': '>',
|
|
2625
|
+
'>': '>',
|
|
2626
|
+
''': "'",
|
|
2627
|
+
''': "'",
|
|
2628
|
+
'"': '"',
|
|
2629
|
+
'"': '"',
|
|
2630
|
+
' ': ' ',
|
|
2631
|
+
' ': ' ',
|
|
2632
|
+
'©': '©',
|
|
2633
|
+
'©': '©',
|
|
2634
|
+
'®': '®',
|
|
2635
|
+
'®': '®',
|
|
2636
|
+
'…': '…',
|
|
2637
|
+
'…': '…',
|
|
2638
|
+
'/': '/',
|
|
2639
|
+
'/': '/'
|
|
2640
|
+
};
|
|
2641
|
+
|
|
2642
|
+
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
|
|
2643
|
+
return htmlEntities[m];
|
|
2644
|
+
};
|
|
2645
|
+
|
|
2646
|
+
var unescape = function unescape(text) {
|
|
2647
|
+
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
2648
|
+
};
|
|
2649
|
+
|
|
2650
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2651
|
+
|
|
2652
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2653
|
+
var defaultOptions = {
|
|
2654
|
+
bindI18n: 'languageChanged',
|
|
2655
|
+
bindI18nStore: '',
|
|
2656
|
+
transEmptyNodeValue: '',
|
|
2657
|
+
transSupportBasicHtmlNodes: true,
|
|
2658
|
+
transWrapTextNodes: '',
|
|
2659
|
+
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
2660
|
+
useSuspense: true,
|
|
2661
|
+
unescape: unescape
|
|
2662
|
+
};
|
|
2663
|
+
function setDefaults() {
|
|
2664
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2665
|
+
defaultOptions = _objectSpread$8(_objectSpread$8({}, defaultOptions), options);
|
|
2666
|
+
}
|
|
2667
|
+
function getDefaults() {
|
|
2668
|
+
return defaultOptions;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
var i18nInstance;
|
|
2672
|
+
function setI18n(instance) {
|
|
2673
|
+
i18nInstance = instance;
|
|
2674
|
+
}
|
|
2675
|
+
function getI18n() {
|
|
2676
|
+
return i18nInstance;
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
var _excluded$1 = ["format"],
|
|
3012
2680
|
_excluded2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
|
|
3013
2681
|
|
|
3014
|
-
function ownKeys$
|
|
2682
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3015
2683
|
|
|
3016
|
-
function _objectSpread$
|
|
2684
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3017
2685
|
|
|
3018
2686
|
function hasChildren(node, checkLength) {
|
|
3019
2687
|
if (!node) return false;
|
|
@@ -3024,7 +2692,7 @@ function hasChildren(node, checkLength) {
|
|
|
3024
2692
|
|
|
3025
2693
|
function getChildren(node) {
|
|
3026
2694
|
if (!node) return [];
|
|
3027
|
-
return node
|
|
2695
|
+
return node.props ? node.props.children : node.children;
|
|
3028
2696
|
}
|
|
3029
2697
|
|
|
3030
2698
|
function hasValidReactChildren(children) {
|
|
@@ -3039,7 +2707,7 @@ function getAsArray(data) {
|
|
|
3039
2707
|
}
|
|
3040
2708
|
|
|
3041
2709
|
function mergeProps(source, target) {
|
|
3042
|
-
var newTarget = _objectSpread$
|
|
2710
|
+
var newTarget = _objectSpread$7({}, target);
|
|
3043
2711
|
|
|
3044
2712
|
newTarget.props = Object.assign(source.props, target.props);
|
|
3045
2713
|
return newTarget;
|
|
@@ -3074,7 +2742,7 @@ function nodesToString(children, i18nOptions) {
|
|
|
3074
2742
|
warn("Trans: the passed in value is invalid - seems you passed in a null child.");
|
|
3075
2743
|
} else if (_typeof$1(child) === 'object') {
|
|
3076
2744
|
var format = child.format,
|
|
3077
|
-
clone = _objectWithoutProperties(child, _excluded);
|
|
2745
|
+
clone = _objectWithoutProperties(child, _excluded$1);
|
|
3078
2746
|
|
|
3079
2747
|
var keys = Object.keys(clone);
|
|
3080
2748
|
|
|
@@ -3109,7 +2777,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
|
|
|
3109
2777
|
getData(children);
|
|
3110
2778
|
var ast = c.parse("<0>".concat(targetString, "</0>"));
|
|
3111
2779
|
|
|
3112
|
-
var opts = _objectSpread$
|
|
2780
|
+
var opts = _objectSpread$7(_objectSpread$7({}, data), combinedTOpts);
|
|
3113
2781
|
|
|
3114
2782
|
function renderInner(child, node, rootReactNode) {
|
|
3115
2783
|
var childs = getChildren(child);
|
|
@@ -3119,7 +2787,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
|
|
|
3119
2787
|
|
|
3120
2788
|
function pushTranslatedJSX(child, inner, mem, i, isVoid) {
|
|
3121
2789
|
if (child.dummy) child.children = inner;
|
|
3122
|
-
mem.push(cloneElement(child, _objectSpread$
|
|
2790
|
+
mem.push(cloneElement(child, _objectSpread$7(_objectSpread$7({}, child.props), {}, {
|
|
3123
2791
|
key: i
|
|
3124
2792
|
}), isVoid ? undefined : inner));
|
|
3125
2793
|
}
|
|
@@ -3151,7 +2819,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
|
|
|
3151
2819
|
} else if (isEmptyTransWithHTML) {
|
|
3152
2820
|
var _inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
3153
2821
|
|
|
3154
|
-
mem.push(cloneElement(child, _objectSpread$
|
|
2822
|
+
mem.push(cloneElement(child, _objectSpread$7(_objectSpread$7({}, child.props), {}, {
|
|
3155
2823
|
key: i
|
|
3156
2824
|
}), _inner));
|
|
3157
2825
|
} else if (Number.isNaN(parseFloat(node.name))) {
|
|
@@ -3182,11 +2850,11 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
|
|
|
3182
2850
|
var content = node.children[0] ? translationContent : null;
|
|
3183
2851
|
if (content) mem.push(content);
|
|
3184
2852
|
} else if (node.children.length === 1 && translationContent) {
|
|
3185
|
-
mem.push(cloneElement(child, _objectSpread$
|
|
2853
|
+
mem.push(cloneElement(child, _objectSpread$7(_objectSpread$7({}, child.props), {}, {
|
|
3186
2854
|
key: i
|
|
3187
2855
|
}), translationContent));
|
|
3188
2856
|
} else {
|
|
3189
|
-
mem.push(cloneElement(child, _objectSpread$
|
|
2857
|
+
mem.push(cloneElement(child, _objectSpread$7(_objectSpread$7({}, child.props), {}, {
|
|
3190
2858
|
key: i
|
|
3191
2859
|
})));
|
|
3192
2860
|
}
|
|
@@ -3215,7 +2883,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, s
|
|
|
3215
2883
|
return getChildren(result[0]);
|
|
3216
2884
|
}
|
|
3217
2885
|
|
|
3218
|
-
function Trans(_ref) {
|
|
2886
|
+
function Trans$1(_ref) {
|
|
3219
2887
|
var children = _ref.children,
|
|
3220
2888
|
count = _ref.count,
|
|
3221
2889
|
parent = _ref.parent,
|
|
@@ -3232,11 +2900,7 @@ function Trans(_ref) {
|
|
|
3232
2900
|
shouldUnescape = _ref.shouldUnescape,
|
|
3233
2901
|
additionalProps = _objectWithoutProperties(_ref, _excluded2);
|
|
3234
2902
|
|
|
3235
|
-
var
|
|
3236
|
-
i18nFromContext = _ref2.i18n,
|
|
3237
|
-
defaultNSFromContext = _ref2.defaultNS;
|
|
3238
|
-
|
|
3239
|
-
var i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
2903
|
+
var i18n = i18nFromProps || getI18n();
|
|
3240
2904
|
|
|
3241
2905
|
if (!i18n) {
|
|
3242
2906
|
warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
|
|
@@ -3249,21 +2913,21 @@ function Trans(_ref) {
|
|
|
3249
2913
|
|
|
3250
2914
|
if (context) tOptions.context = context;
|
|
3251
2915
|
|
|
3252
|
-
var reactI18nextOptions = _objectSpread$
|
|
2916
|
+
var reactI18nextOptions = _objectSpread$7(_objectSpread$7({}, getDefaults()), i18n.options && i18n.options.react);
|
|
3253
2917
|
|
|
3254
|
-
var namespaces = ns || t.ns ||
|
|
2918
|
+
var namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
|
|
3255
2919
|
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
|
|
3256
2920
|
var defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
|
|
3257
2921
|
var hashTransKey = reactI18nextOptions.hashTransKey;
|
|
3258
2922
|
var key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
|
|
3259
2923
|
var interpolationOverride = values ? tOptions.interpolation : {
|
|
3260
|
-
interpolation: _objectSpread$
|
|
2924
|
+
interpolation: _objectSpread$7(_objectSpread$7({}, tOptions.interpolation), {}, {
|
|
3261
2925
|
prefix: '#$?',
|
|
3262
2926
|
suffix: '?$#'
|
|
3263
2927
|
})
|
|
3264
2928
|
};
|
|
3265
2929
|
|
|
3266
|
-
var combinedTOpts = _objectSpread$
|
|
2930
|
+
var combinedTOpts = _objectSpread$7(_objectSpread$7(_objectSpread$7(_objectSpread$7({}, tOptions), {}, {
|
|
3267
2931
|
count: count
|
|
3268
2932
|
}, values), interpolationOverride), {}, {
|
|
3269
2933
|
defaultValue: defaultValue,
|
|
@@ -3276,6 +2940,86 @@ function Trans(_ref) {
|
|
|
3276
2940
|
return useAsParent ? createElement(useAsParent, additionalProps, content) : content;
|
|
3277
2941
|
}
|
|
3278
2942
|
|
|
2943
|
+
var initReactI18next = {
|
|
2944
|
+
type: '3rdParty',
|
|
2945
|
+
init: function init(instance) {
|
|
2946
|
+
setDefaults(instance.options.react);
|
|
2947
|
+
setI18n(instance);
|
|
2948
|
+
}
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2951
|
+
var I18nContext = createContext();
|
|
2952
|
+
var ReportNamespaces = function () {
|
|
2953
|
+
function ReportNamespaces() {
|
|
2954
|
+
_classCallCheck$1(this, ReportNamespaces);
|
|
2955
|
+
|
|
2956
|
+
this.usedNamespaces = {};
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
_createClass$1(ReportNamespaces, [{
|
|
2960
|
+
key: "addUsedNamespaces",
|
|
2961
|
+
value: function addUsedNamespaces(namespaces) {
|
|
2962
|
+
var _this = this;
|
|
2963
|
+
|
|
2964
|
+
namespaces.forEach(function (ns) {
|
|
2965
|
+
if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
|
|
2966
|
+
});
|
|
2967
|
+
}
|
|
2968
|
+
}, {
|
|
2969
|
+
key: "getUsedNamespaces",
|
|
2970
|
+
value: function getUsedNamespaces() {
|
|
2971
|
+
return Object.keys(this.usedNamespaces);
|
|
2972
|
+
}
|
|
2973
|
+
}]);
|
|
2974
|
+
|
|
2975
|
+
return ReportNamespaces;
|
|
2976
|
+
}();
|
|
2977
|
+
|
|
2978
|
+
var _excluded = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
|
|
2979
|
+
|
|
2980
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2981
|
+
|
|
2982
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2983
|
+
function Trans(_ref) {
|
|
2984
|
+
var children = _ref.children,
|
|
2985
|
+
count = _ref.count,
|
|
2986
|
+
parent = _ref.parent,
|
|
2987
|
+
i18nKey = _ref.i18nKey,
|
|
2988
|
+
context = _ref.context,
|
|
2989
|
+
_ref$tOptions = _ref.tOptions,
|
|
2990
|
+
tOptions = _ref$tOptions === void 0 ? {} : _ref$tOptions,
|
|
2991
|
+
values = _ref.values,
|
|
2992
|
+
defaults = _ref.defaults,
|
|
2993
|
+
components = _ref.components,
|
|
2994
|
+
ns = _ref.ns,
|
|
2995
|
+
i18nFromProps = _ref.i18n,
|
|
2996
|
+
tFromProps = _ref.t,
|
|
2997
|
+
shouldUnescape = _ref.shouldUnescape,
|
|
2998
|
+
additionalProps = _objectWithoutProperties(_ref, _excluded);
|
|
2999
|
+
|
|
3000
|
+
var _ref2 = useContext(I18nContext) || {},
|
|
3001
|
+
i18nFromContext = _ref2.i18n,
|
|
3002
|
+
defaultNSFromContext = _ref2.defaultNS;
|
|
3003
|
+
|
|
3004
|
+
var i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
3005
|
+
var t = tFromProps || i18n && i18n.t.bind(i18n);
|
|
3006
|
+
return Trans$1(_objectSpread$6({
|
|
3007
|
+
children: children,
|
|
3008
|
+
count: count,
|
|
3009
|
+
parent: parent,
|
|
3010
|
+
i18nKey: i18nKey,
|
|
3011
|
+
context: context,
|
|
3012
|
+
tOptions: tOptions,
|
|
3013
|
+
values: values,
|
|
3014
|
+
defaults: defaults,
|
|
3015
|
+
components: components,
|
|
3016
|
+
ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
|
|
3017
|
+
i18n: i18n,
|
|
3018
|
+
t: tFromProps,
|
|
3019
|
+
shouldUnescape: shouldUnescape
|
|
3020
|
+
}, additionalProps));
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3279
3023
|
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
3280
3024
|
|
|
3281
3025
|
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -3376,7 +3120,7 @@ function useTranslation(ns) {
|
|
|
3376
3120
|
}
|
|
3377
3121
|
|
|
3378
3122
|
isInitial.current = false;
|
|
3379
|
-
}, [i18n]);
|
|
3123
|
+
}, [i18n, keyPrefix]);
|
|
3380
3124
|
var ret = [t, i18n, ready];
|
|
3381
3125
|
ret.t = t;
|
|
3382
3126
|
ret.i18n = i18n;
|
|
@@ -3501,21 +3245,19 @@ instance.use(initReactI18next).init({
|
|
|
3501
3245
|
*/
|
|
3502
3246
|
var Tags$2 = function Tags(_ref) {
|
|
3503
3247
|
var _ref$label = _ref.label,
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3248
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
3249
|
+
allTags = _ref.allTags,
|
|
3250
|
+
selectedTags = _ref.selectedTags,
|
|
3251
|
+
onTagSelect = _ref.onTagSelect,
|
|
3252
|
+
onTagCreate = _ref.onTagCreate,
|
|
3253
|
+
onTagDelete = _ref.onTagDelete,
|
|
3254
|
+
tagProps = _ref.tagProps,
|
|
3255
|
+
selectProps = _ref.selectProps,
|
|
3256
|
+
buttonProps = _ref.buttonProps;
|
|
3514
3257
|
var _useState = useState(false),
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3258
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3259
|
+
addTag = _useState2[0],
|
|
3260
|
+
setAddTag = _useState2[1];
|
|
3519
3261
|
var tags = useMemo(function () {
|
|
3520
3262
|
if (!allTags) return [];
|
|
3521
3263
|
if (!selectedTags) return allTags;
|
|
@@ -3622,7 +3364,7 @@ var PLURAL = {
|
|
|
3622
3364
|
};
|
|
3623
3365
|
|
|
3624
3366
|
var Menu$1 = Dropdown.Menu,
|
|
3625
|
-
|
|
3367
|
+
MenuItem = Dropdown.MenuItem;
|
|
3626
3368
|
var renderColumnData = function renderColumnData(columns, handleEdit, handleDelete) {
|
|
3627
3369
|
return [].concat(_toConsumableArray(columns), [{
|
|
3628
3370
|
id: "actions",
|
|
@@ -3660,7 +3402,6 @@ var getCurrentTagType = function getCurrentTagType() {
|
|
|
3660
3402
|
var tagLabel = searchParams.get("view");
|
|
3661
3403
|
var requiredTagType = tagTypes.find(function (tagType) {
|
|
3662
3404
|
var _tagType$label;
|
|
3663
|
-
|
|
3664
3405
|
return (tagType === null || tagType === void 0 ? void 0 : (_tagType$label = tagType.label) === null || _tagType$label === void 0 ? void 0 : _tagType$label.toLowerCase()) === tagLabel;
|
|
3665
3406
|
});
|
|
3666
3407
|
return requiredTagType || tagTypes[0];
|
|
@@ -3668,10 +3409,9 @@ var getCurrentTagType = function getCurrentTagType() {
|
|
|
3668
3409
|
|
|
3669
3410
|
function useDebounce(value, delay) {
|
|
3670
3411
|
var _useState = useState(value),
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3412
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3413
|
+
debouncedValue = _useState2[0],
|
|
3414
|
+
setDebouncedValue = _useState2[1];
|
|
3675
3415
|
useEffect(function () {
|
|
3676
3416
|
var timer = setTimeout(function () {
|
|
3677
3417
|
return setDebouncedValue(value);
|
|
@@ -4533,8 +4273,10 @@ var Query = /*#__PURE__*/function () {
|
|
|
4533
4273
|
};
|
|
4534
4274
|
|
|
4535
4275
|
_proto.clearGcTimeout = function clearGcTimeout() {
|
|
4536
|
-
|
|
4537
|
-
|
|
4276
|
+
if (this.gcTimeout) {
|
|
4277
|
+
clearTimeout(this.gcTimeout);
|
|
4278
|
+
this.gcTimeout = undefined;
|
|
4279
|
+
}
|
|
4538
4280
|
};
|
|
4539
4281
|
|
|
4540
4282
|
_proto.optionalRemove = function optionalRemove() {
|
|
@@ -6183,13 +5925,17 @@ var QueryObserver = /*#__PURE__*/function (_Subscribable) {
|
|
|
6183
5925
|
};
|
|
6184
5926
|
|
|
6185
5927
|
_proto.clearStaleTimeout = function clearStaleTimeout() {
|
|
6186
|
-
|
|
6187
|
-
|
|
5928
|
+
if (this.staleTimeoutId) {
|
|
5929
|
+
clearTimeout(this.staleTimeoutId);
|
|
5930
|
+
this.staleTimeoutId = undefined;
|
|
5931
|
+
}
|
|
6188
5932
|
};
|
|
6189
5933
|
|
|
6190
5934
|
_proto.clearRefetchInterval = function clearRefetchInterval() {
|
|
6191
|
-
|
|
6192
|
-
|
|
5935
|
+
if (this.refetchIntervalId) {
|
|
5936
|
+
clearInterval(this.refetchIntervalId);
|
|
5937
|
+
this.refetchIntervalId = undefined;
|
|
5938
|
+
}
|
|
6193
5939
|
};
|
|
6194
5940
|
|
|
6195
5941
|
_proto.createResult = function createResult(query, options) {
|
|
@@ -6833,9 +6579,9 @@ function useQuery(arg1, arg2, arg3) {
|
|
|
6833
6579
|
|
|
6834
6580
|
var fetch = function fetch(_ref) {
|
|
6835
6581
|
var url = _ref.url,
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6582
|
+
searchTerm = _ref.searchTerm,
|
|
6583
|
+
limit = _ref.limit,
|
|
6584
|
+
pageNo = _ref.pageNo;
|
|
6839
6585
|
return axios.get(url, {
|
|
6840
6586
|
params: {
|
|
6841
6587
|
search_term: searchTerm,
|
|
@@ -6845,23 +6591,18 @@ var fetch = function fetch(_ref) {
|
|
|
6845
6591
|
}
|
|
6846
6592
|
});
|
|
6847
6593
|
};
|
|
6848
|
-
|
|
6849
6594
|
var create = function create(url, payload) {
|
|
6850
6595
|
return axios.post(url, payload);
|
|
6851
6596
|
};
|
|
6852
|
-
|
|
6853
6597
|
var update = function update(url, id, payload) {
|
|
6854
6598
|
return axios.put("".concat(url, "/").concat(id), payload);
|
|
6855
6599
|
};
|
|
6856
|
-
|
|
6857
6600
|
var destroy = function destroy(url, id) {
|
|
6858
6601
|
return axios["delete"]("".concat(url, "/").concat(id));
|
|
6859
6602
|
};
|
|
6860
|
-
|
|
6861
6603
|
var merge = function merge(url, payload) {
|
|
6862
6604
|
return axios.patch("".concat(url, "/merge"), payload);
|
|
6863
6605
|
};
|
|
6864
|
-
|
|
6865
6606
|
var tagsApi = {
|
|
6866
6607
|
fetch: fetch,
|
|
6867
6608
|
create: create,
|
|
@@ -6879,11 +6620,9 @@ var queryClient = new QueryClient({
|
|
|
6879
6620
|
});
|
|
6880
6621
|
|
|
6881
6622
|
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6882
|
-
|
|
6883
6623
|
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6884
6624
|
var TAG_KEY = "tag-key";
|
|
6885
6625
|
var STALE_TIME = 3200000;
|
|
6886
|
-
|
|
6887
6626
|
var useFetchTags = function useFetchTags(params) {
|
|
6888
6627
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6889
6628
|
return useQuery([TAG_KEY, Object.values(params)], function () {
|
|
@@ -6896,11 +6635,10 @@ var useFetchTags = function useFetchTags(params) {
|
|
|
6896
6635
|
keepPreviousData: true
|
|
6897
6636
|
}, options));
|
|
6898
6637
|
};
|
|
6899
|
-
|
|
6900
6638
|
var useCreateTag = function useCreateTag() {
|
|
6901
6639
|
return useMutation(function (_ref) {
|
|
6902
6640
|
var url = _ref.url,
|
|
6903
|
-
|
|
6641
|
+
payload = _ref.payload;
|
|
6904
6642
|
return tagsApi.create(url, payload);
|
|
6905
6643
|
}, {
|
|
6906
6644
|
onSuccess: function onSuccess() {
|
|
@@ -6908,12 +6646,11 @@ var useCreateTag = function useCreateTag() {
|
|
|
6908
6646
|
}
|
|
6909
6647
|
});
|
|
6910
6648
|
};
|
|
6911
|
-
|
|
6912
6649
|
var useUpdateTag = function useUpdateTag() {
|
|
6913
6650
|
return useMutation(function (_ref2) {
|
|
6914
6651
|
var url = _ref2.url,
|
|
6915
|
-
|
|
6916
|
-
|
|
6652
|
+
id = _ref2.id,
|
|
6653
|
+
payload = _ref2.payload;
|
|
6917
6654
|
return tagsApi.update(url, id, payload);
|
|
6918
6655
|
}, {
|
|
6919
6656
|
onSuccess: function onSuccess() {
|
|
@@ -6921,11 +6658,10 @@ var useUpdateTag = function useUpdateTag() {
|
|
|
6921
6658
|
}
|
|
6922
6659
|
});
|
|
6923
6660
|
};
|
|
6924
|
-
|
|
6925
6661
|
var useDeleteTag = function useDeleteTag() {
|
|
6926
6662
|
return useMutation(function (_ref3) {
|
|
6927
6663
|
var url = _ref3.url,
|
|
6928
|
-
|
|
6664
|
+
id = _ref3.id;
|
|
6929
6665
|
return tagsApi.destroy(url, id);
|
|
6930
6666
|
}, {
|
|
6931
6667
|
onSuccess: function onSuccess() {
|
|
@@ -6933,11 +6669,10 @@ var useDeleteTag = function useDeleteTag() {
|
|
|
6933
6669
|
}
|
|
6934
6670
|
});
|
|
6935
6671
|
};
|
|
6936
|
-
|
|
6937
6672
|
var useMergeTags = function useMergeTags() {
|
|
6938
6673
|
return useMutation(function (_ref4) {
|
|
6939
6674
|
var url = _ref4.url,
|
|
6940
|
-
|
|
6675
|
+
payload = _ref4.payload;
|
|
6941
6676
|
return tagsApi.merge(url, payload);
|
|
6942
6677
|
}, {
|
|
6943
6678
|
onSuccess: function onSuccess(_ref5) {
|
|
@@ -6947,7 +6682,6 @@ var useMergeTags = function useMergeTags() {
|
|
|
6947
6682
|
}
|
|
6948
6683
|
});
|
|
6949
6684
|
};
|
|
6950
|
-
|
|
6951
6685
|
var refetchTags = function refetchTags() {
|
|
6952
6686
|
return queryClient.invalidateQueries([TAG_KEY]);
|
|
6953
6687
|
};
|
|
@@ -6961,22 +6695,19 @@ var NO_DATA_PRIMARY_BUTTON_PROPS$1 = {
|
|
|
6961
6695
|
|
|
6962
6696
|
var useTagsForm = function useTagsForm(_ref) {
|
|
6963
6697
|
var createTags = _ref.createTags,
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6698
|
+
goToFirstPage = _ref.goToFirstPage,
|
|
6699
|
+
isEdit = _ref.isEdit,
|
|
6700
|
+
onPaneClose = _ref.onPaneClose,
|
|
6701
|
+
setHasSubmitted = _ref.setHasSubmitted,
|
|
6702
|
+
tagType = _ref.tagType,
|
|
6703
|
+
updateTags = _ref.updateTags;
|
|
6970
6704
|
var tagModification = isEdit ? useUpdateTag : useCreateTag;
|
|
6971
6705
|
var tagOperation = isEdit ? updateTags : createTags;
|
|
6972
|
-
|
|
6973
6706
|
var _tagModification = tagModification(),
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6707
|
+
mutate = _tagModification.mutate,
|
|
6708
|
+
isSubmitting = _tagModification.isLoading;
|
|
6977
6709
|
var handleSubmit = function handleSubmit(values, _ref2) {
|
|
6978
6710
|
var _values$description;
|
|
6979
|
-
|
|
6980
6711
|
var resetForm = _ref2.resetForm;
|
|
6981
6712
|
setHasSubmitted(true);
|
|
6982
6713
|
values.description = values === null || values === void 0 ? void 0 : (_values$description = values.description) === null || _values$description === void 0 ? void 0 : _values$description.trim();
|
|
@@ -6986,15 +6717,12 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
6986
6717
|
}
|
|
6987
6718
|
};
|
|
6988
6719
|
tagData.url = tagType.url;
|
|
6989
|
-
|
|
6990
6720
|
if (isEdit) {
|
|
6991
6721
|
tagData.id = values.id;
|
|
6992
6722
|
}
|
|
6993
|
-
|
|
6994
6723
|
mutate(tagData, {
|
|
6995
6724
|
onSuccess: function onSuccess() {
|
|
6996
6725
|
var _tagOperation$onSucce;
|
|
6997
|
-
|
|
6998
6726
|
!isEdit && goToFirstPage();
|
|
6999
6727
|
tagOperation === null || tagOperation === void 0 ? void 0 : (_tagOperation$onSucce = tagOperation.onSuccess) === null || _tagOperation$onSucce === void 0 ? void 0 : _tagOperation$onSucce.callback();
|
|
7000
6728
|
onPaneClose();
|
|
@@ -7004,7 +6732,6 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
7004
6732
|
}
|
|
7005
6733
|
});
|
|
7006
6734
|
};
|
|
7007
|
-
|
|
7008
6735
|
return {
|
|
7009
6736
|
handleSubmit: handleSubmit,
|
|
7010
6737
|
isSubmitting: isSubmitting
|
|
@@ -7013,42 +6740,38 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
7013
6740
|
|
|
7014
6741
|
var ManageTags = function ManageTags(_ref) {
|
|
7015
6742
|
var createTags = _ref.createTags,
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
6743
|
+
goToFirstPage = _ref.goToFirstPage,
|
|
6744
|
+
onClose = _ref.onClose,
|
|
6745
|
+
tag = _ref.tag,
|
|
6746
|
+
tagType = _ref.tagType,
|
|
6747
|
+
type = _ref.type,
|
|
6748
|
+
updateTags = _ref.updateTags;
|
|
7023
6749
|
var _useTranslation = useTranslation(),
|
|
7024
|
-
|
|
7025
|
-
|
|
6750
|
+
t = _useTranslation.t;
|
|
7026
6751
|
var _useState = useState(false),
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
6752
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6753
|
+
hasSubmitted = _useState2[0],
|
|
6754
|
+
setHasSubmitted = _useState2[1];
|
|
7031
6755
|
var isEdit = type === PANE_TYPES.EDIT;
|
|
7032
6756
|
var initValues = isEdit ? tag : INITIAL_TAG_VALUES;
|
|
7033
|
-
|
|
6757
|
+
var inputRef = useRef(null);
|
|
7034
6758
|
var onPaneClose = function onPaneClose() {
|
|
7035
6759
|
setHasSubmitted(false);
|
|
7036
6760
|
onClose();
|
|
7037
6761
|
};
|
|
7038
|
-
|
|
7039
6762
|
var _useTagsForm = useTagsForm({
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
6763
|
+
createTags: createTags,
|
|
6764
|
+
goToFirstPage: goToFirstPage,
|
|
6765
|
+
isEdit: isEdit,
|
|
6766
|
+
onPaneClose: onPaneClose,
|
|
6767
|
+
setHasSubmitted: setHasSubmitted,
|
|
6768
|
+
tagType: tagType,
|
|
6769
|
+
updateTags: updateTags
|
|
6770
|
+
}),
|
|
6771
|
+
handleSubmit = _useTagsForm.handleSubmit,
|
|
6772
|
+
isSubmitting = _useTagsForm.isSubmitting;
|
|
7051
6773
|
return /*#__PURE__*/React.createElement(Pane, {
|
|
6774
|
+
initialFocusRef: inputRef,
|
|
7052
6775
|
isOpen: !!type,
|
|
7053
6776
|
onClose: onPaneClose
|
|
7054
6777
|
}, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
|
|
@@ -7072,12 +6795,12 @@ var ManageTags = function ManageTags(_ref) {
|
|
|
7072
6795
|
className: "neeto-ui-flex neeto-ui-w-full neeto-ui-flex-col"
|
|
7073
6796
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
7074
6797
|
required: true,
|
|
7075
|
-
autoFocus: true,
|
|
7076
6798
|
name: "name",
|
|
7077
6799
|
label: "".concat(t("tag"), " ").concat(t("name").toLocaleLowerCase()),
|
|
7078
6800
|
"data-cy": "tag-name-text-field",
|
|
7079
6801
|
maxLength: 50,
|
|
7080
|
-
className: "neeto-ui-mb-4"
|
|
6802
|
+
className: "neeto-ui-mb-4",
|
|
6803
|
+
ref: inputRef
|
|
7081
6804
|
}), /*#__PURE__*/React.createElement(Textarea, {
|
|
7082
6805
|
name: "description",
|
|
7083
6806
|
label: t("description"),
|
|
@@ -7114,98 +6837,79 @@ var getHelpText = function getHelpText(url) {
|
|
|
7114
6837
|
};
|
|
7115
6838
|
|
|
7116
6839
|
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7117
|
-
|
|
7118
6840
|
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7119
|
-
|
|
7120
6841
|
var Dashboard = function Dashboard(_ref) {
|
|
7121
6842
|
var _data$tags2, _tagType$label;
|
|
7122
|
-
|
|
7123
6843
|
var breadcrumbs = _ref.breadcrumbs,
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
6844
|
+
createTags = _ref.createTags,
|
|
6845
|
+
deleteTags = _ref.deleteTags,
|
|
6846
|
+
displayMenu = _ref.displayMenu,
|
|
6847
|
+
handleMenuToggle = _ref.handleMenuToggle,
|
|
6848
|
+
kbArticleUrl = _ref.kbArticleUrl,
|
|
6849
|
+
onTagRowClick = _ref.onTagRowClick,
|
|
6850
|
+
_ref$tagsMergable = _ref.tagsMergable,
|
|
6851
|
+
tagsMergable = _ref$tagsMergable === void 0 ? false : _ref$tagsMergable,
|
|
6852
|
+
tagsPath = _ref.tagsPath,
|
|
6853
|
+
tagType = _ref.tagType,
|
|
6854
|
+
updateTags = _ref.updateTags;
|
|
7136
6855
|
var _useState = useState(null),
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
6856
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6857
|
+
selectedTag = _useState2[0],
|
|
6858
|
+
setSelectedTag = _useState2[1];
|
|
7141
6859
|
var _useState3 = useState(""),
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
6860
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
6861
|
+
searchTerm = _useState4[0],
|
|
6862
|
+
setSearchTerm = _useState4[1];
|
|
7146
6863
|
var _useState5 = useState(DEFAULT_PAGE_INDEX),
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
6864
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
6865
|
+
pageIndex = _useState6[0],
|
|
6866
|
+
setPageIndex = _useState6[1];
|
|
7151
6867
|
var _useState7 = useState(null),
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
6868
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
6869
|
+
paneType = _useState8[0],
|
|
6870
|
+
setPaneType = _useState8[1];
|
|
7156
6871
|
var _useState9 = useState(false),
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
6872
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
6873
|
+
isDeleteAlertOpen = _useState10[0],
|
|
6874
|
+
setIsDeleteAlertOpen = _useState10[1];
|
|
7161
6875
|
var debouncedSearchTerm = useDebounce(searchTerm, 500);
|
|
7162
|
-
|
|
7163
6876
|
var _useFetchTags = useFetchTags({
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
6877
|
+
url: tagType.url,
|
|
6878
|
+
searchTerm: debouncedSearchTerm.trim(),
|
|
6879
|
+
limit: DEFAULT_PAGE_SIZE,
|
|
6880
|
+
pageNo: pageIndex
|
|
6881
|
+
}),
|
|
6882
|
+
data = _useFetchTags.data,
|
|
6883
|
+
isLoading = _useFetchTags.isLoading;
|
|
7172
6884
|
var _useTranslation = useTranslation(),
|
|
7173
|
-
|
|
7174
|
-
|
|
6885
|
+
t = _useTranslation.t;
|
|
7175
6886
|
var history = useHistory();
|
|
7176
|
-
|
|
7177
6887
|
var primaryButtonProps = _objectSpread$3(_objectSpread$3({}, NO_DATA_PRIMARY_BUTTON_PROPS$1), {}, {
|
|
7178
6888
|
onClick: function onClick() {
|
|
7179
6889
|
setSelectedTag(null);
|
|
7180
6890
|
setPaneType(PANE_TYPES.CREATE);
|
|
7181
6891
|
}
|
|
7182
6892
|
});
|
|
7183
|
-
|
|
7184
6893
|
var goToFirstPage = function goToFirstPage() {
|
|
7185
6894
|
if (pageIndex !== DEFAULT_PAGE_INDEX) {
|
|
7186
6895
|
setPageIndex(DEFAULT_PAGE_INDEX);
|
|
7187
6896
|
}
|
|
7188
6897
|
};
|
|
7189
|
-
|
|
7190
6898
|
var handleEdit = function handleEdit(tag) {
|
|
7191
6899
|
setSelectedTag(tag);
|
|
7192
6900
|
setPaneType(PANE_TYPES.EDIT);
|
|
7193
6901
|
};
|
|
7194
|
-
|
|
7195
6902
|
var handleDelete = function handleDelete(tag) {
|
|
7196
6903
|
setSelectedTag(tag);
|
|
7197
6904
|
setIsDeleteAlertOpen(true);
|
|
7198
6905
|
};
|
|
7199
|
-
|
|
7200
6906
|
var handleAlertClose = function handleAlertClose() {
|
|
7201
6907
|
setIsDeleteAlertOpen(false);
|
|
7202
6908
|
setSelectedTag(null);
|
|
7203
6909
|
};
|
|
7204
|
-
|
|
7205
6910
|
var _useDeleteTag = useDeleteTag(),
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
6911
|
+
mutate = _useDeleteTag.mutate,
|
|
6912
|
+
isDeletingTag = _useDeleteTag.isLoading;
|
|
7209
6913
|
var handleConfirmDelete = function handleConfirmDelete() {
|
|
7210
6914
|
var payload = {
|
|
7211
6915
|
url: tagType.url,
|
|
@@ -7215,15 +6919,12 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
7215
6919
|
isNotDeleting && mutate(payload, {
|
|
7216
6920
|
onSuccess: function onSuccess() {
|
|
7217
6921
|
var _data$tags, _deleteTags$onSuccess;
|
|
7218
|
-
|
|
7219
6922
|
setIsDeleteAlertOpen(false);
|
|
7220
|
-
|
|
7221
6923
|
if ((data === null || data === void 0 ? void 0 : (_data$tags = data.tags) === null || _data$tags === void 0 ? void 0 : _data$tags.length) === 1) {
|
|
7222
6924
|
setPageIndex(function (pageIndex) {
|
|
7223
6925
|
return pageIndex - 1;
|
|
7224
6926
|
});
|
|
7225
6927
|
}
|
|
7226
|
-
|
|
7227
6928
|
deleteTags === null || deleteTags === void 0 ? void 0 : (_deleteTags$onSuccess = deleteTags.onSuccess) === null || _deleteTags$onSuccess === void 0 ? void 0 : _deleteTags$onSuccess.callback();
|
|
7228
6929
|
Toastr.success(t("deleteSuccess"));
|
|
7229
6930
|
},
|
|
@@ -7233,13 +6934,11 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
7233
6934
|
}
|
|
7234
6935
|
});
|
|
7235
6936
|
};
|
|
7236
|
-
|
|
7237
6937
|
if (isLoading) {
|
|
7238
6938
|
return /*#__PURE__*/React.createElement("div", {
|
|
7239
6939
|
className: "neeto-ui-w-full neeto-ui-h-screen"
|
|
7240
6940
|
}, /*#__PURE__*/React.createElement(PageLoader, null));
|
|
7241
6941
|
}
|
|
7242
|
-
|
|
7243
6942
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Container, {
|
|
7244
6943
|
isHeaderFixed: true
|
|
7245
6944
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
@@ -7350,26 +7049,22 @@ var NO_DATA_PRIMARY_BUTTON_PROPS = {
|
|
|
7350
7049
|
|
|
7351
7050
|
var List = function List(_ref) {
|
|
7352
7051
|
var _ref$tagList = _ref.tagList,
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7052
|
+
tagList = _ref$tagList === void 0 ? [] : _ref$tagList,
|
|
7053
|
+
onSelect = _ref.onSelect,
|
|
7054
|
+
selectedCounterTagId = _ref.selectedCounterTagId,
|
|
7055
|
+
selectedTagId = _ref.selectedTagId,
|
|
7056
|
+
type = _ref.type,
|
|
7057
|
+
isSource = _ref.isSource;
|
|
7360
7058
|
var _useTranslation = useTranslation(),
|
|
7361
|
-
|
|
7362
|
-
|
|
7059
|
+
t = _useTranslation.t;
|
|
7363
7060
|
var _useState = useState([]),
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7061
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7062
|
+
tags = _useState2[0],
|
|
7063
|
+
setTags = _useState2[1];
|
|
7368
7064
|
var _useState3 = useState(""),
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7065
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
7066
|
+
searchTerm = _useState4[0],
|
|
7067
|
+
setSearchTerm = _useState4[1];
|
|
7373
7068
|
var listType = isSource ? "source" : "destination";
|
|
7374
7069
|
useEffect(function () {
|
|
7375
7070
|
var filteredTags = tagList.filter(function (_ref2) {
|
|
@@ -7423,63 +7118,52 @@ var unusualPlurals = {
|
|
|
7423
7118
|
person: "people",
|
|
7424
7119
|
woman: "women"
|
|
7425
7120
|
};
|
|
7426
|
-
|
|
7427
7121
|
var pluralize = function pluralize(_ref) {
|
|
7428
7122
|
var _ref$count = _ref.count,
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7123
|
+
count = _ref$count === void 0 ? 0 : _ref$count,
|
|
7124
|
+
_ref$singular = _ref.singular,
|
|
7125
|
+
singular = _ref$singular === void 0 ? "" : _ref$singular,
|
|
7126
|
+
_ref$plural = _ref.plural,
|
|
7127
|
+
plural = _ref$plural === void 0 ? "" : _ref$plural,
|
|
7128
|
+
_ref$zero = _ref.zero,
|
|
7129
|
+
zero = _ref$zero === void 0 ? false : _ref$zero,
|
|
7130
|
+
_ref$skipCount = _ref.skipCount,
|
|
7131
|
+
skipCount = _ref$skipCount === void 0 ? false : _ref$skipCount;
|
|
7439
7132
|
var pluralString = function pluralString() {
|
|
7440
7133
|
if (plural) return plural;
|
|
7441
7134
|
var str = unusualPlurals[singular];
|
|
7442
7135
|
if (str) return str;
|
|
7443
7136
|
return "".concat(singular, "s");
|
|
7444
7137
|
};
|
|
7445
|
-
|
|
7446
7138
|
var resultText = "";
|
|
7447
7139
|
if (!skipCount) resultText += "".concat(count, " ");
|
|
7448
|
-
|
|
7449
7140
|
switch (count) {
|
|
7450
7141
|
case 0:
|
|
7451
7142
|
if (zero) return zero;
|
|
7452
7143
|
resultText += pluralString();
|
|
7453
7144
|
break;
|
|
7454
|
-
|
|
7455
7145
|
case 1:
|
|
7456
7146
|
resultText += singular;
|
|
7457
7147
|
break;
|
|
7458
|
-
|
|
7459
7148
|
default:
|
|
7460
7149
|
resultText += pluralString();
|
|
7461
7150
|
break;
|
|
7462
7151
|
}
|
|
7463
|
-
|
|
7464
7152
|
return resultText;
|
|
7465
7153
|
};
|
|
7466
7154
|
|
|
7467
7155
|
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7468
|
-
|
|
7469
7156
|
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7470
|
-
|
|
7471
7157
|
var MergeAlert = function MergeAlert(_ref) {
|
|
7472
7158
|
var sourceTag = _ref.sourceTag,
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7159
|
+
destinationTag = _ref.destinationTag,
|
|
7160
|
+
showModal = _ref.showModal,
|
|
7161
|
+
setShowModal = _ref.setShowModal,
|
|
7162
|
+
tagType = _ref.tagType,
|
|
7163
|
+
handleSubmit = _ref.handleSubmit,
|
|
7164
|
+
isSubmitting = _ref.isSubmitting;
|
|
7480
7165
|
var _useTranslation = useTranslation(),
|
|
7481
|
-
|
|
7482
|
-
|
|
7166
|
+
t = _useTranslation.t;
|
|
7483
7167
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
7484
7168
|
isOpen: showModal,
|
|
7485
7169
|
onClose: function onClose() {
|
|
@@ -7521,63 +7205,50 @@ var MergeAlert = function MergeAlert(_ref) {
|
|
|
7521
7205
|
};
|
|
7522
7206
|
|
|
7523
7207
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7524
|
-
|
|
7525
7208
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7526
|
-
|
|
7527
7209
|
var Merge = function Merge(_ref) {
|
|
7528
7210
|
var _data$tags;
|
|
7529
|
-
|
|
7530
7211
|
var breadcrumbs = _ref.breadcrumbs,
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7212
|
+
displayMenu = _ref.displayMenu,
|
|
7213
|
+
handleMenuToggle = _ref.handleMenuToggle,
|
|
7214
|
+
kbArticleUrl = _ref.kbArticleUrl,
|
|
7215
|
+
mergeTags = _ref.mergeTags,
|
|
7216
|
+
tagsPath = _ref.tagsPath,
|
|
7217
|
+
tagType = _ref.tagType;
|
|
7538
7218
|
var _useState = useState({}),
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7219
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7220
|
+
sourceTag = _useState2[0],
|
|
7221
|
+
setSourceTag = _useState2[1];
|
|
7543
7222
|
var _useState3 = useState({}),
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7223
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
7224
|
+
destinationTag = _useState4[0],
|
|
7225
|
+
setDestinationTag = _useState4[1];
|
|
7548
7226
|
var _useState5 = useState(false),
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7227
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
7228
|
+
isModalOpen = _useState6[0],
|
|
7229
|
+
setIsModalOpen = _useState6[1];
|
|
7553
7230
|
var _useTranslation = useTranslation(),
|
|
7554
|
-
|
|
7555
|
-
|
|
7231
|
+
t = _useTranslation.t;
|
|
7556
7232
|
var history = useHistory();
|
|
7557
|
-
|
|
7558
7233
|
var _useFetchTags = useFetchTags({
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7234
|
+
url: tagType.url
|
|
7235
|
+
}),
|
|
7236
|
+
data = _useFetchTags.data,
|
|
7237
|
+
isLoading = _useFetchTags.isLoading;
|
|
7564
7238
|
var _useMergeTags = useMergeTags(),
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7239
|
+
mutate = _useMergeTags.mutate,
|
|
7240
|
+
isSubmitting = _useMergeTags.isLoading;
|
|
7568
7241
|
var primaryButtonProps = _objectSpread$1(_objectSpread$1({}, NO_DATA_PRIMARY_BUTTON_PROPS), {}, {
|
|
7569
7242
|
onClick: function onClick() {
|
|
7570
7243
|
return history.push(tagsPath);
|
|
7571
7244
|
}
|
|
7572
7245
|
});
|
|
7573
|
-
|
|
7574
7246
|
var updatedBreadcrumbs = useMemo(function () {
|
|
7575
7247
|
return [].concat(_toConsumableArray(breadcrumbs), [{
|
|
7576
7248
|
text: tagType.label,
|
|
7577
7249
|
link: tagsPath
|
|
7578
7250
|
}]);
|
|
7579
7251
|
}, [breadcrumbs, tagsPath]);
|
|
7580
|
-
|
|
7581
7252
|
var handleSubmit = function handleSubmit() {
|
|
7582
7253
|
var payload = {
|
|
7583
7254
|
tags: {
|
|
@@ -7591,7 +7262,6 @@ var Merge = function Merge(_ref) {
|
|
|
7591
7262
|
}, {
|
|
7592
7263
|
onSuccess: function onSuccess() {
|
|
7593
7264
|
var _mergeTags$onSuccess;
|
|
7594
|
-
|
|
7595
7265
|
setDestinationTag("");
|
|
7596
7266
|
setSourceTag("");
|
|
7597
7267
|
mergeTags === null || mergeTags === void 0 ? void 0 : (_mergeTags$onSuccess = mergeTags.onSuccess) === null || _mergeTags$onSuccess === void 0 ? void 0 : _mergeTags$onSuccess.callback();
|
|
@@ -7599,13 +7269,11 @@ var Merge = function Merge(_ref) {
|
|
|
7599
7269
|
}
|
|
7600
7270
|
});
|
|
7601
7271
|
};
|
|
7602
|
-
|
|
7603
7272
|
if (isLoading) {
|
|
7604
7273
|
return /*#__PURE__*/React.createElement("div", {
|
|
7605
7274
|
className: "neeto-ui-w-full neeto-ui-h-screen"
|
|
7606
7275
|
}, /*#__PURE__*/React.createElement(PageLoader, null));
|
|
7607
7276
|
}
|
|
7608
|
-
|
|
7609
7277
|
return /*#__PURE__*/React.createElement("div", {
|
|
7610
7278
|
className: "neeto-ui-w-full"
|
|
7611
7279
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
@@ -7668,7 +7336,6 @@ var Merge = function Merge(_ref) {
|
|
|
7668
7336
|
var renderComponent = function renderComponent(Component, props) {
|
|
7669
7337
|
return /*#__PURE__*/React.createElement(Component, props);
|
|
7670
7338
|
};
|
|
7671
|
-
|
|
7672
7339
|
var createRoutes = function createRoutes(props) {
|
|
7673
7340
|
return [{
|
|
7674
7341
|
component: function component() {
|
|
@@ -7687,13 +7354,11 @@ var createRoutes = function createRoutes(props) {
|
|
|
7687
7354
|
|
|
7688
7355
|
var Menu = function Menu(_ref) {
|
|
7689
7356
|
var tagTypes = _ref.tagTypes,
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7357
|
+
showMenu = _ref.showMenu,
|
|
7358
|
+
tagType = _ref.tagType,
|
|
7359
|
+
setTagType = _ref.setTagType;
|
|
7694
7360
|
var _useTranslation = useTranslation(),
|
|
7695
|
-
|
|
7696
|
-
|
|
7361
|
+
t = _useTranslation.t;
|
|
7697
7362
|
return /*#__PURE__*/React.createElement(MenuBar, {
|
|
7698
7363
|
showMenu: showMenu,
|
|
7699
7364
|
title: t("title")
|
|
@@ -7710,7 +7375,11 @@ var Menu = function Menu(_ref) {
|
|
|
7710
7375
|
}));
|
|
7711
7376
|
};
|
|
7712
7377
|
|
|
7713
|
-
var
|
|
7378
|
+
var devtoolsExports = {};
|
|
7379
|
+
var devtools = {
|
|
7380
|
+
get exports(){ return devtoolsExports; },
|
|
7381
|
+
set exports(v){ devtoolsExports = v; },
|
|
7382
|
+
};
|
|
7714
7383
|
|
|
7715
7384
|
{
|
|
7716
7385
|
devtools.exports = {
|
|
@@ -7727,41 +7396,34 @@ var withReactQuery = function withReactQuery(Component) {
|
|
|
7727
7396
|
var QueryWrapper = function QueryWrapper(props) {
|
|
7728
7397
|
return /*#__PURE__*/React.createElement(QueryClientProvider, {
|
|
7729
7398
|
client: queryClient
|
|
7730
|
-
}, /*#__PURE__*/React.createElement(Component, props), /*#__PURE__*/React.createElement(
|
|
7399
|
+
}, /*#__PURE__*/React.createElement(Component, props), /*#__PURE__*/React.createElement(devtoolsExports.ReactQueryDevtools, {
|
|
7731
7400
|
initialIsOpen: false,
|
|
7732
7401
|
position: "bottom-right"
|
|
7733
7402
|
}));
|
|
7734
7403
|
};
|
|
7735
|
-
|
|
7736
7404
|
return QueryWrapper;
|
|
7737
7405
|
};
|
|
7738
7406
|
|
|
7739
7407
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7740
|
-
|
|
7741
7408
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7742
|
-
|
|
7743
7409
|
var Tags = function Tags(_ref) {
|
|
7744
7410
|
var config = _ref.config;
|
|
7745
7411
|
var tagTypes = config.tagTypes,
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7412
|
+
_config$displayMenu = config.displayMenu,
|
|
7413
|
+
displayMenu = _config$displayMenu === void 0 ? true : _config$displayMenu;
|
|
7749
7414
|
var _useState = useState(getCurrentTagType(tagTypes)),
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7415
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7416
|
+
tagType = _useState2[0],
|
|
7417
|
+
setTagType = _useState2[1];
|
|
7754
7418
|
var _useState3 = useState(false),
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7419
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
7420
|
+
isMenuOpen = _useState4[0],
|
|
7421
|
+
setIsMenuOpen = _useState4[1];
|
|
7759
7422
|
var handleMenuToggle = function handleMenuToggle() {
|
|
7760
7423
|
return setIsMenuOpen(function (isMenuOpen) {
|
|
7761
7424
|
return !isMenuOpen;
|
|
7762
7425
|
});
|
|
7763
7426
|
};
|
|
7764
|
-
|
|
7765
7427
|
var routes = createRoutes(_objectSpread(_objectSpread({}, config), {}, {
|
|
7766
7428
|
handleMenuToggle: handleMenuToggle,
|
|
7767
7429
|
displayMenu: displayMenu,
|
|
@@ -7776,8 +7438,8 @@ var Tags = function Tags(_ref) {
|
|
|
7776
7438
|
setTagType: setTagType
|
|
7777
7439
|
}), /*#__PURE__*/React.createElement(Switch, null, routes.map(function (_ref2) {
|
|
7778
7440
|
var exact = _ref2.exact,
|
|
7779
|
-
|
|
7780
|
-
|
|
7441
|
+
path = _ref2.path,
|
|
7442
|
+
component = _ref2.component;
|
|
7781
7443
|
return /*#__PURE__*/React.createElement(Route, {
|
|
7782
7444
|
key: path,
|
|
7783
7445
|
exact: exact,
|
|
@@ -7786,7 +7448,6 @@ var Tags = function Tags(_ref) {
|
|
|
7786
7448
|
});
|
|
7787
7449
|
})));
|
|
7788
7450
|
};
|
|
7789
|
-
|
|
7790
7451
|
var Tags$1 = withReactQuery(Tags);
|
|
7791
7452
|
|
|
7792
7453
|
var App = function App(_ref) {
|