@steedos-widgets/amis-object 1.2.15 → 1.2.18
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/amis-object.cjs.js +3363 -140
- package/dist/amis-object.cjs.js.map +1 -1
- package/dist/amis-object.esm.js +3366 -143
- package/dist/amis-object.esm.js.map +1 -1
- package/dist/amis-object.umd.js +3363 -140
- package/dist/amis-object.umd.js.map +1 -1
- package/dist/assets.json +11 -11
- package/dist/meta.js +15 -9
- package/package.json +3 -3
package/dist/amis-object.cjs.js
CHANGED
|
@@ -147,8 +147,2805 @@ function __spreadArray(to, from, pack) {
|
|
|
147
147
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
function _typeof$1(obj) {
|
|
151
|
+
"@babel/helpers - typeof";
|
|
152
|
+
|
|
153
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
154
|
+
return typeof obj;
|
|
155
|
+
} : function (obj) {
|
|
156
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
157
|
+
}, _typeof$1(obj);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
161
|
+
if (!(instance instanceof Constructor)) {
|
|
162
|
+
throw new TypeError("Cannot call a class as a function");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function _toPrimitive$1(input, hint) {
|
|
167
|
+
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
168
|
+
var prim = input[Symbol.toPrimitive];
|
|
169
|
+
if (prim !== undefined) {
|
|
170
|
+
var res = prim.call(input, hint || "default");
|
|
171
|
+
if (_typeof$1(res) !== "object") return res;
|
|
172
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
173
|
+
}
|
|
174
|
+
return (hint === "string" ? String : Number)(input);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function _toPropertyKey$1(arg) {
|
|
178
|
+
var key = _toPrimitive$1(arg, "string");
|
|
179
|
+
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function _defineProperties$1(target, props) {
|
|
183
|
+
for (var i = 0; i < props.length; i++) {
|
|
184
|
+
var descriptor = props[i];
|
|
185
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
186
|
+
descriptor.configurable = true;
|
|
187
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
188
|
+
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
192
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
193
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
194
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
195
|
+
writable: false
|
|
196
|
+
});
|
|
197
|
+
return Constructor;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function _assertThisInitialized(self) {
|
|
201
|
+
if (self === void 0) {
|
|
202
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
203
|
+
}
|
|
204
|
+
return self;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function _setPrototypeOf(o, p) {
|
|
208
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
209
|
+
o.__proto__ = p;
|
|
210
|
+
return o;
|
|
211
|
+
};
|
|
212
|
+
return _setPrototypeOf(o, p);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function _inherits(subClass, superClass) {
|
|
216
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
217
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
218
|
+
}
|
|
219
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
220
|
+
constructor: {
|
|
221
|
+
value: subClass,
|
|
222
|
+
writable: true,
|
|
223
|
+
configurable: true
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(subClass, "prototype", {
|
|
227
|
+
writable: false
|
|
228
|
+
});
|
|
229
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function _possibleConstructorReturn(self, call) {
|
|
233
|
+
if (call && (_typeof$1(call) === "object" || typeof call === "function")) {
|
|
234
|
+
return call;
|
|
235
|
+
} else if (call !== void 0) {
|
|
236
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
237
|
+
}
|
|
238
|
+
return _assertThisInitialized(self);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function _getPrototypeOf(o) {
|
|
242
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
243
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
244
|
+
};
|
|
245
|
+
return _getPrototypeOf(o);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function _defineProperty$1(obj, key, value) {
|
|
249
|
+
key = _toPropertyKey$1(key);
|
|
250
|
+
if (key in obj) {
|
|
251
|
+
Object.defineProperty(obj, key, {
|
|
252
|
+
value: value,
|
|
253
|
+
enumerable: true,
|
|
254
|
+
configurable: true,
|
|
255
|
+
writable: true
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
obj[key] = value;
|
|
259
|
+
}
|
|
260
|
+
return obj;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function _arrayWithHoles(arr) {
|
|
264
|
+
if (Array.isArray(arr)) return arr;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function _iterableToArray(iter) {
|
|
268
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function _arrayLikeToArray(arr, len) {
|
|
272
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
273
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
274
|
+
return arr2;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
278
|
+
if (!o) return;
|
|
279
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
280
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
281
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
282
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
283
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function _nonIterableRest() {
|
|
287
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function _toArray(arr) {
|
|
291
|
+
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function ownKeys$6(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; }
|
|
295
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
296
|
+
var consoleLogger = {
|
|
297
|
+
type: 'logger',
|
|
298
|
+
log: function log(args) {
|
|
299
|
+
this.output('log', args);
|
|
300
|
+
},
|
|
301
|
+
warn: function warn(args) {
|
|
302
|
+
this.output('warn', args);
|
|
303
|
+
},
|
|
304
|
+
error: function error(args) {
|
|
305
|
+
this.output('error', args);
|
|
306
|
+
},
|
|
307
|
+
output: function output(type, args) {
|
|
308
|
+
if (console && console[type]) console[type].apply(console, args);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var Logger = function () {
|
|
312
|
+
function Logger(concreteLogger) {
|
|
313
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
314
|
+
_classCallCheck$1(this, Logger);
|
|
315
|
+
this.init(concreteLogger, options);
|
|
316
|
+
}
|
|
317
|
+
_createClass$1(Logger, [{
|
|
318
|
+
key: "init",
|
|
319
|
+
value: function init(concreteLogger) {
|
|
320
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
321
|
+
this.prefix = options.prefix || 'i18next:';
|
|
322
|
+
this.logger = concreteLogger || consoleLogger;
|
|
323
|
+
this.options = options;
|
|
324
|
+
this.debug = options.debug;
|
|
325
|
+
}
|
|
326
|
+
}, {
|
|
327
|
+
key: "setDebug",
|
|
328
|
+
value: function setDebug(bool) {
|
|
329
|
+
this.debug = bool;
|
|
330
|
+
}
|
|
331
|
+
}, {
|
|
332
|
+
key: "log",
|
|
333
|
+
value: function log() {
|
|
334
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
335
|
+
args[_key] = arguments[_key];
|
|
336
|
+
}
|
|
337
|
+
return this.forward(args, 'log', '', true);
|
|
338
|
+
}
|
|
339
|
+
}, {
|
|
340
|
+
key: "warn",
|
|
341
|
+
value: function warn() {
|
|
342
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
343
|
+
args[_key2] = arguments[_key2];
|
|
344
|
+
}
|
|
345
|
+
return this.forward(args, 'warn', '', true);
|
|
346
|
+
}
|
|
347
|
+
}, {
|
|
348
|
+
key: "error",
|
|
349
|
+
value: function error() {
|
|
350
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
351
|
+
args[_key3] = arguments[_key3];
|
|
352
|
+
}
|
|
353
|
+
return this.forward(args, 'error', '');
|
|
354
|
+
}
|
|
355
|
+
}, {
|
|
356
|
+
key: "deprecate",
|
|
357
|
+
value: function deprecate() {
|
|
358
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
359
|
+
args[_key4] = arguments[_key4];
|
|
360
|
+
}
|
|
361
|
+
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
|
362
|
+
}
|
|
363
|
+
}, {
|
|
364
|
+
key: "forward",
|
|
365
|
+
value: function forward(args, lvl, prefix, debugOnly) {
|
|
366
|
+
if (debugOnly && !this.debug) return null;
|
|
367
|
+
if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
|
|
368
|
+
return this.logger[lvl](args);
|
|
369
|
+
}
|
|
370
|
+
}, {
|
|
371
|
+
key: "create",
|
|
372
|
+
value: function create(moduleName) {
|
|
373
|
+
return new Logger(this.logger, _objectSpread$6(_objectSpread$6({}, {
|
|
374
|
+
prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
|
|
375
|
+
}), this.options));
|
|
376
|
+
}
|
|
377
|
+
}, {
|
|
378
|
+
key: "clone",
|
|
379
|
+
value: function clone(options) {
|
|
380
|
+
options = options || this.options;
|
|
381
|
+
options.prefix = options.prefix || this.prefix;
|
|
382
|
+
return new Logger(this.logger, options);
|
|
383
|
+
}
|
|
384
|
+
}]);
|
|
385
|
+
return Logger;
|
|
386
|
+
}();
|
|
387
|
+
var baseLogger = new Logger();
|
|
388
|
+
|
|
389
|
+
var EventEmitter = function () {
|
|
390
|
+
function EventEmitter() {
|
|
391
|
+
_classCallCheck$1(this, EventEmitter);
|
|
392
|
+
this.observers = {};
|
|
393
|
+
}
|
|
394
|
+
_createClass$1(EventEmitter, [{
|
|
395
|
+
key: "on",
|
|
396
|
+
value: function on(events, listener) {
|
|
397
|
+
var _this = this;
|
|
398
|
+
events.split(' ').forEach(function (event) {
|
|
399
|
+
_this.observers[event] = _this.observers[event] || [];
|
|
400
|
+
_this.observers[event].push(listener);
|
|
401
|
+
});
|
|
402
|
+
return this;
|
|
403
|
+
}
|
|
404
|
+
}, {
|
|
405
|
+
key: "off",
|
|
406
|
+
value: function off(event, listener) {
|
|
407
|
+
if (!this.observers[event]) return;
|
|
408
|
+
if (!listener) {
|
|
409
|
+
delete this.observers[event];
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
this.observers[event] = this.observers[event].filter(function (l) {
|
|
413
|
+
return l !== listener;
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}, {
|
|
417
|
+
key: "emit",
|
|
418
|
+
value: function emit(event) {
|
|
419
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
420
|
+
args[_key - 1] = arguments[_key];
|
|
421
|
+
}
|
|
422
|
+
if (this.observers[event]) {
|
|
423
|
+
var cloned = [].concat(this.observers[event]);
|
|
424
|
+
cloned.forEach(function (observer) {
|
|
425
|
+
observer.apply(void 0, args);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
if (this.observers['*']) {
|
|
429
|
+
var _cloned = [].concat(this.observers['*']);
|
|
430
|
+
_cloned.forEach(function (observer) {
|
|
431
|
+
observer.apply(observer, [event].concat(args));
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}]);
|
|
436
|
+
return EventEmitter;
|
|
437
|
+
}();
|
|
438
|
+
|
|
439
|
+
function defer() {
|
|
440
|
+
var res;
|
|
441
|
+
var rej;
|
|
442
|
+
var promise = new Promise(function (resolve, reject) {
|
|
443
|
+
res = resolve;
|
|
444
|
+
rej = reject;
|
|
445
|
+
});
|
|
446
|
+
promise.resolve = res;
|
|
447
|
+
promise.reject = rej;
|
|
448
|
+
return promise;
|
|
449
|
+
}
|
|
450
|
+
function makeString(object) {
|
|
451
|
+
if (object == null) return '';
|
|
452
|
+
return '' + object;
|
|
453
|
+
}
|
|
454
|
+
function copy(a, s, t) {
|
|
455
|
+
a.forEach(function (m) {
|
|
456
|
+
if (s[m]) t[m] = s[m];
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
function getLastOfPath(object, path, Empty) {
|
|
460
|
+
function cleanKey(key) {
|
|
461
|
+
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
|
|
462
|
+
}
|
|
463
|
+
function canNotTraverseDeeper() {
|
|
464
|
+
return !object || typeof object === 'string';
|
|
465
|
+
}
|
|
466
|
+
var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
|
|
467
|
+
while (stack.length > 1) {
|
|
468
|
+
if (canNotTraverseDeeper()) return {};
|
|
469
|
+
var key = cleanKey(stack.shift());
|
|
470
|
+
if (!object[key] && Empty) object[key] = new Empty();
|
|
471
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
472
|
+
object = object[key];
|
|
473
|
+
} else {
|
|
474
|
+
object = {};
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (canNotTraverseDeeper()) return {};
|
|
478
|
+
return {
|
|
479
|
+
obj: object,
|
|
480
|
+
k: cleanKey(stack.shift())
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
function setPath(object, path, newValue) {
|
|
484
|
+
var _getLastOfPath = getLastOfPath(object, path, Object),
|
|
485
|
+
obj = _getLastOfPath.obj,
|
|
486
|
+
k = _getLastOfPath.k;
|
|
487
|
+
obj[k] = newValue;
|
|
488
|
+
}
|
|
489
|
+
function pushPath(object, path, newValue, concat) {
|
|
490
|
+
var _getLastOfPath2 = getLastOfPath(object, path, Object),
|
|
491
|
+
obj = _getLastOfPath2.obj,
|
|
492
|
+
k = _getLastOfPath2.k;
|
|
493
|
+
obj[k] = obj[k] || [];
|
|
494
|
+
if (concat) obj[k] = obj[k].concat(newValue);
|
|
495
|
+
if (!concat) obj[k].push(newValue);
|
|
496
|
+
}
|
|
497
|
+
function getPath(object, path) {
|
|
498
|
+
var _getLastOfPath3 = getLastOfPath(object, path),
|
|
499
|
+
obj = _getLastOfPath3.obj,
|
|
500
|
+
k = _getLastOfPath3.k;
|
|
501
|
+
if (!obj) return undefined;
|
|
502
|
+
return obj[k];
|
|
503
|
+
}
|
|
504
|
+
function getPathWithDefaults(data, defaultData, key) {
|
|
505
|
+
var value = getPath(data, key);
|
|
506
|
+
if (value !== undefined) {
|
|
507
|
+
return value;
|
|
508
|
+
}
|
|
509
|
+
return getPath(defaultData, key);
|
|
510
|
+
}
|
|
511
|
+
function deepExtend(target, source, overwrite) {
|
|
512
|
+
for (var prop in source) {
|
|
513
|
+
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
514
|
+
if (prop in target) {
|
|
515
|
+
if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
|
|
516
|
+
if (overwrite) target[prop] = source[prop];
|
|
517
|
+
} else {
|
|
518
|
+
deepExtend(target[prop], source[prop], overwrite);
|
|
519
|
+
}
|
|
520
|
+
} else {
|
|
521
|
+
target[prop] = source[prop];
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return target;
|
|
526
|
+
}
|
|
527
|
+
function regexEscape(str) {
|
|
528
|
+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
529
|
+
}
|
|
530
|
+
var _entityMap = {
|
|
531
|
+
'&': '&',
|
|
532
|
+
'<': '<',
|
|
533
|
+
'>': '>',
|
|
534
|
+
'"': '"',
|
|
535
|
+
"'": ''',
|
|
536
|
+
'/': '/'
|
|
537
|
+
};
|
|
538
|
+
function escape(data) {
|
|
539
|
+
if (typeof data === 'string') {
|
|
540
|
+
return data.replace(/[&<>"'\/]/g, function (s) {
|
|
541
|
+
return _entityMap[s];
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
return data;
|
|
545
|
+
}
|
|
546
|
+
var isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
|
|
547
|
+
var chars = [' ', ',', '?', '!', ';'];
|
|
548
|
+
function looksLikeObjectPath(key, nsSeparator, keySeparator) {
|
|
549
|
+
nsSeparator = nsSeparator || '';
|
|
550
|
+
keySeparator = keySeparator || '';
|
|
551
|
+
var possibleChars = chars.filter(function (c) {
|
|
552
|
+
return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;
|
|
553
|
+
});
|
|
554
|
+
if (possibleChars.length === 0) return true;
|
|
555
|
+
var r = new RegExp("(".concat(possibleChars.map(function (c) {
|
|
556
|
+
return c === '?' ? '\\?' : c;
|
|
557
|
+
}).join('|'), ")"));
|
|
558
|
+
var matched = !r.test(key);
|
|
559
|
+
if (!matched) {
|
|
560
|
+
var ki = key.indexOf(keySeparator);
|
|
561
|
+
if (ki > 0 && !r.test(key.substring(0, ki))) {
|
|
562
|
+
matched = true;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return matched;
|
|
566
|
+
}
|
|
567
|
+
function deepFind(obj, path) {
|
|
568
|
+
var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
569
|
+
if (!obj) return undefined;
|
|
570
|
+
if (obj[path]) return obj[path];
|
|
571
|
+
var paths = path.split(keySeparator);
|
|
572
|
+
var current = obj;
|
|
573
|
+
for (var i = 0; i < paths.length; ++i) {
|
|
574
|
+
if (!current) return undefined;
|
|
575
|
+
if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
|
|
576
|
+
return undefined;
|
|
577
|
+
}
|
|
578
|
+
if (current[paths[i]] === undefined) {
|
|
579
|
+
var j = 2;
|
|
580
|
+
var p = paths.slice(i, i + j).join(keySeparator);
|
|
581
|
+
var mix = current[p];
|
|
582
|
+
while (mix === undefined && paths.length > i + j) {
|
|
583
|
+
j++;
|
|
584
|
+
p = paths.slice(i, i + j).join(keySeparator);
|
|
585
|
+
mix = current[p];
|
|
586
|
+
}
|
|
587
|
+
if (mix === undefined) return undefined;
|
|
588
|
+
if (mix === null) return null;
|
|
589
|
+
if (path.endsWith(p)) {
|
|
590
|
+
if (typeof mix === 'string') return mix;
|
|
591
|
+
if (p && typeof mix[p] === 'string') return mix[p];
|
|
592
|
+
}
|
|
593
|
+
var joinedPath = paths.slice(i + j).join(keySeparator);
|
|
594
|
+
if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
current = current[paths[i]];
|
|
598
|
+
}
|
|
599
|
+
return current;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function ownKeys$5(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; }
|
|
603
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
604
|
+
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); }; }
|
|
605
|
+
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; } }
|
|
606
|
+
var ResourceStore = function (_EventEmitter) {
|
|
607
|
+
_inherits(ResourceStore, _EventEmitter);
|
|
608
|
+
var _super = _createSuper$3(ResourceStore);
|
|
609
|
+
function ResourceStore(data) {
|
|
610
|
+
var _this;
|
|
611
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
612
|
+
ns: ['translation'],
|
|
613
|
+
defaultNS: 'translation'
|
|
614
|
+
};
|
|
615
|
+
_classCallCheck$1(this, ResourceStore);
|
|
616
|
+
_this = _super.call(this);
|
|
617
|
+
if (isIE10) {
|
|
618
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
619
|
+
}
|
|
620
|
+
_this.data = data || {};
|
|
621
|
+
_this.options = options;
|
|
622
|
+
if (_this.options.keySeparator === undefined) {
|
|
623
|
+
_this.options.keySeparator = '.';
|
|
624
|
+
}
|
|
625
|
+
if (_this.options.ignoreJSONStructure === undefined) {
|
|
626
|
+
_this.options.ignoreJSONStructure = true;
|
|
627
|
+
}
|
|
628
|
+
return _this;
|
|
629
|
+
}
|
|
630
|
+
_createClass$1(ResourceStore, [{
|
|
631
|
+
key: "addNamespaces",
|
|
632
|
+
value: function addNamespaces(ns) {
|
|
633
|
+
if (this.options.ns.indexOf(ns) < 0) {
|
|
634
|
+
this.options.ns.push(ns);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}, {
|
|
638
|
+
key: "removeNamespaces",
|
|
639
|
+
value: function removeNamespaces(ns) {
|
|
640
|
+
var index = this.options.ns.indexOf(ns);
|
|
641
|
+
if (index > -1) {
|
|
642
|
+
this.options.ns.splice(index, 1);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}, {
|
|
646
|
+
key: "getResource",
|
|
647
|
+
value: function getResource(lng, ns, key) {
|
|
648
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
649
|
+
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
650
|
+
var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
651
|
+
var path = [lng, ns];
|
|
652
|
+
if (key && typeof key !== 'string') path = path.concat(key);
|
|
653
|
+
if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
654
|
+
if (lng.indexOf('.') > -1) {
|
|
655
|
+
path = lng.split('.');
|
|
656
|
+
}
|
|
657
|
+
var result = getPath(this.data, path);
|
|
658
|
+
if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
|
|
659
|
+
return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
|
|
660
|
+
}
|
|
661
|
+
}, {
|
|
662
|
+
key: "addResource",
|
|
663
|
+
value: function addResource(lng, ns, key, value) {
|
|
664
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
665
|
+
silent: false
|
|
666
|
+
};
|
|
667
|
+
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
668
|
+
var path = [lng, ns];
|
|
669
|
+
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
670
|
+
if (lng.indexOf('.') > -1) {
|
|
671
|
+
path = lng.split('.');
|
|
672
|
+
value = ns;
|
|
673
|
+
ns = path[1];
|
|
674
|
+
}
|
|
675
|
+
this.addNamespaces(ns);
|
|
676
|
+
setPath(this.data, path, value);
|
|
677
|
+
if (!options.silent) this.emit('added', lng, ns, key, value);
|
|
678
|
+
}
|
|
679
|
+
}, {
|
|
680
|
+
key: "addResources",
|
|
681
|
+
value: function addResources(lng, ns, resources) {
|
|
682
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
683
|
+
silent: false
|
|
684
|
+
};
|
|
685
|
+
for (var m in resources) {
|
|
686
|
+
if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
|
|
687
|
+
silent: true
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
691
|
+
}
|
|
692
|
+
}, {
|
|
693
|
+
key: "addResourceBundle",
|
|
694
|
+
value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
|
|
695
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
|
696
|
+
silent: false
|
|
697
|
+
};
|
|
698
|
+
var path = [lng, ns];
|
|
699
|
+
if (lng.indexOf('.') > -1) {
|
|
700
|
+
path = lng.split('.');
|
|
701
|
+
deep = resources;
|
|
702
|
+
resources = ns;
|
|
703
|
+
ns = path[1];
|
|
704
|
+
}
|
|
705
|
+
this.addNamespaces(ns);
|
|
706
|
+
var pack = getPath(this.data, path) || {};
|
|
707
|
+
if (deep) {
|
|
708
|
+
deepExtend(pack, resources, overwrite);
|
|
709
|
+
} else {
|
|
710
|
+
pack = _objectSpread$5(_objectSpread$5({}, pack), resources);
|
|
711
|
+
}
|
|
712
|
+
setPath(this.data, path, pack);
|
|
713
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
714
|
+
}
|
|
715
|
+
}, {
|
|
716
|
+
key: "removeResourceBundle",
|
|
717
|
+
value: function removeResourceBundle(lng, ns) {
|
|
718
|
+
if (this.hasResourceBundle(lng, ns)) {
|
|
719
|
+
delete this.data[lng][ns];
|
|
720
|
+
}
|
|
721
|
+
this.removeNamespaces(ns);
|
|
722
|
+
this.emit('removed', lng, ns);
|
|
723
|
+
}
|
|
724
|
+
}, {
|
|
725
|
+
key: "hasResourceBundle",
|
|
726
|
+
value: function hasResourceBundle(lng, ns) {
|
|
727
|
+
return this.getResource(lng, ns) !== undefined;
|
|
728
|
+
}
|
|
729
|
+
}, {
|
|
730
|
+
key: "getResourceBundle",
|
|
731
|
+
value: function getResourceBundle(lng, ns) {
|
|
732
|
+
if (!ns) ns = this.options.defaultNS;
|
|
733
|
+
if (this.options.compatibilityAPI === 'v1') return _objectSpread$5(_objectSpread$5({}, {}), this.getResource(lng, ns));
|
|
734
|
+
return this.getResource(lng, ns);
|
|
735
|
+
}
|
|
736
|
+
}, {
|
|
737
|
+
key: "getDataByLanguage",
|
|
738
|
+
value: function getDataByLanguage(lng) {
|
|
739
|
+
return this.data[lng];
|
|
740
|
+
}
|
|
741
|
+
}, {
|
|
742
|
+
key: "hasLanguageSomeTranslations",
|
|
743
|
+
value: function hasLanguageSomeTranslations(lng) {
|
|
744
|
+
var data = this.getDataByLanguage(lng);
|
|
745
|
+
var n = data && Object.keys(data) || [];
|
|
746
|
+
return !!n.find(function (v) {
|
|
747
|
+
return data[v] && Object.keys(data[v]).length > 0;
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
}, {
|
|
751
|
+
key: "toJSON",
|
|
752
|
+
value: function toJSON() {
|
|
753
|
+
return this.data;
|
|
754
|
+
}
|
|
755
|
+
}]);
|
|
756
|
+
return ResourceStore;
|
|
757
|
+
}(EventEmitter);
|
|
758
|
+
|
|
759
|
+
var postProcessor = {
|
|
760
|
+
processors: {},
|
|
761
|
+
addPostProcessor: function addPostProcessor(module) {
|
|
762
|
+
this.processors[module.name] = module;
|
|
763
|
+
},
|
|
764
|
+
handle: function handle(processors, value, key, options, translator) {
|
|
765
|
+
var _this = this;
|
|
766
|
+
processors.forEach(function (processor) {
|
|
767
|
+
if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
|
|
768
|
+
});
|
|
769
|
+
return value;
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
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; }
|
|
774
|
+
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; }
|
|
775
|
+
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); }; }
|
|
776
|
+
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; } }
|
|
777
|
+
var checkedLoadedFor = {};
|
|
778
|
+
var Translator = function (_EventEmitter) {
|
|
779
|
+
_inherits(Translator, _EventEmitter);
|
|
780
|
+
var _super = _createSuper$2(Translator);
|
|
781
|
+
function Translator(services) {
|
|
782
|
+
var _this;
|
|
783
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
784
|
+
_classCallCheck$1(this, Translator);
|
|
785
|
+
_this = _super.call(this);
|
|
786
|
+
if (isIE10) {
|
|
787
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
788
|
+
}
|
|
789
|
+
copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
|
|
790
|
+
_this.options = options;
|
|
791
|
+
if (_this.options.keySeparator === undefined) {
|
|
792
|
+
_this.options.keySeparator = '.';
|
|
793
|
+
}
|
|
794
|
+
_this.logger = baseLogger.create('translator');
|
|
795
|
+
return _this;
|
|
796
|
+
}
|
|
797
|
+
_createClass$1(Translator, [{
|
|
798
|
+
key: "changeLanguage",
|
|
799
|
+
value: function changeLanguage(lng) {
|
|
800
|
+
if (lng) this.language = lng;
|
|
801
|
+
}
|
|
802
|
+
}, {
|
|
803
|
+
key: "exists",
|
|
804
|
+
value: function exists(key) {
|
|
805
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
806
|
+
interpolation: {}
|
|
807
|
+
};
|
|
808
|
+
if (key === undefined || key === null) {
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
var resolved = this.resolve(key, options);
|
|
812
|
+
return resolved && resolved.res !== undefined;
|
|
813
|
+
}
|
|
814
|
+
}, {
|
|
815
|
+
key: "extractFromKey",
|
|
816
|
+
value: function extractFromKey(key, options) {
|
|
817
|
+
var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
|
|
818
|
+
if (nsSeparator === undefined) nsSeparator = ':';
|
|
819
|
+
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
820
|
+
var namespaces = options.ns || this.options.defaultNS || [];
|
|
821
|
+
var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
|
822
|
+
var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
823
|
+
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
824
|
+
var m = key.match(this.interpolator.nestingRegexp);
|
|
825
|
+
if (m && m.length > 0) {
|
|
826
|
+
return {
|
|
827
|
+
key: key,
|
|
828
|
+
namespaces: namespaces
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
var parts = key.split(nsSeparator);
|
|
832
|
+
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
|
833
|
+
key = parts.join(keySeparator);
|
|
834
|
+
}
|
|
835
|
+
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
836
|
+
return {
|
|
837
|
+
key: key,
|
|
838
|
+
namespaces: namespaces
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
}, {
|
|
842
|
+
key: "translate",
|
|
843
|
+
value: function translate(keys, options, lastKey) {
|
|
844
|
+
var _this2 = this;
|
|
845
|
+
if (_typeof$1(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
846
|
+
options = this.options.overloadTranslationOptionHandler(arguments);
|
|
847
|
+
}
|
|
848
|
+
if (_typeof$1(options) === 'object') options = _objectSpread$4({}, options);
|
|
849
|
+
if (!options) options = {};
|
|
850
|
+
if (keys === undefined || keys === null) return '';
|
|
851
|
+
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
852
|
+
var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
|
|
853
|
+
var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
854
|
+
var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
|
|
855
|
+
key = _this$extractFromKey.key,
|
|
856
|
+
namespaces = _this$extractFromKey.namespaces;
|
|
857
|
+
var namespace = namespaces[namespaces.length - 1];
|
|
858
|
+
var lng = options.lng || this.language;
|
|
859
|
+
var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
860
|
+
if (lng && lng.toLowerCase() === 'cimode') {
|
|
861
|
+
if (appendNamespaceToCIMode) {
|
|
862
|
+
var nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
|
863
|
+
if (returnDetails) {
|
|
864
|
+
return {
|
|
865
|
+
res: "".concat(namespace).concat(nsSeparator).concat(key),
|
|
866
|
+
usedKey: key,
|
|
867
|
+
exactUsedKey: key,
|
|
868
|
+
usedLng: lng,
|
|
869
|
+
usedNS: namespace
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
return "".concat(namespace).concat(nsSeparator).concat(key);
|
|
873
|
+
}
|
|
874
|
+
if (returnDetails) {
|
|
875
|
+
return {
|
|
876
|
+
res: key,
|
|
877
|
+
usedKey: key,
|
|
878
|
+
exactUsedKey: key,
|
|
879
|
+
usedLng: lng,
|
|
880
|
+
usedNS: namespace
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
return key;
|
|
884
|
+
}
|
|
885
|
+
var resolved = this.resolve(keys, options);
|
|
886
|
+
var res = resolved && resolved.res;
|
|
887
|
+
var resUsedKey = resolved && resolved.usedKey || key;
|
|
888
|
+
var resExactUsedKey = resolved && resolved.exactUsedKey || key;
|
|
889
|
+
var resType = Object.prototype.toString.apply(res);
|
|
890
|
+
var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
|
891
|
+
var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
|
|
892
|
+
var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
893
|
+
var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
|
|
894
|
+
if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
|
|
895
|
+
if (!options.returnObjects && !this.options.returnObjects) {
|
|
896
|
+
if (!this.options.returnedObjectHandler) {
|
|
897
|
+
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
898
|
+
}
|
|
899
|
+
var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
900
|
+
ns: namespaces
|
|
901
|
+
})) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
|
|
902
|
+
if (returnDetails) {
|
|
903
|
+
resolved.res = r;
|
|
904
|
+
return resolved;
|
|
905
|
+
}
|
|
906
|
+
return r;
|
|
907
|
+
}
|
|
908
|
+
if (keySeparator) {
|
|
909
|
+
var resTypeIsArray = resType === '[object Array]';
|
|
910
|
+
var copy = resTypeIsArray ? [] : {};
|
|
911
|
+
var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
912
|
+
for (var m in res) {
|
|
913
|
+
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
914
|
+
var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
|
|
915
|
+
copy[m] = this.translate(deepKey, _objectSpread$4(_objectSpread$4({}, options), {
|
|
916
|
+
joinArrays: false,
|
|
917
|
+
ns: namespaces
|
|
918
|
+
}));
|
|
919
|
+
if (copy[m] === deepKey) copy[m] = res[m];
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
res = copy;
|
|
923
|
+
}
|
|
924
|
+
} else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
|
|
925
|
+
res = res.join(joinArrays);
|
|
926
|
+
if (res) res = this.extendTranslation(res, keys, options, lastKey);
|
|
927
|
+
} else {
|
|
928
|
+
var usedDefault = false;
|
|
929
|
+
var usedKey = false;
|
|
930
|
+
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
931
|
+
var hasDefaultValue = Translator.hasDefaultValue(options);
|
|
932
|
+
var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
|
|
933
|
+
var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
|
|
934
|
+
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
935
|
+
usedDefault = true;
|
|
936
|
+
res = defaultValue;
|
|
937
|
+
}
|
|
938
|
+
if (!this.isValidLookup(res)) {
|
|
939
|
+
usedKey = true;
|
|
940
|
+
res = key;
|
|
941
|
+
}
|
|
942
|
+
var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
943
|
+
var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
944
|
+
var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
945
|
+
if (usedKey || usedDefault || updateMissing) {
|
|
946
|
+
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
947
|
+
if (keySeparator) {
|
|
948
|
+
var fk = this.resolve(key, _objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
949
|
+
keySeparator: false
|
|
950
|
+
}));
|
|
951
|
+
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.');
|
|
952
|
+
}
|
|
953
|
+
var lngs = [];
|
|
954
|
+
var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
|
|
955
|
+
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
|
956
|
+
for (var i = 0; i < fallbackLngs.length; i++) {
|
|
957
|
+
lngs.push(fallbackLngs[i]);
|
|
958
|
+
}
|
|
959
|
+
} else if (this.options.saveMissingTo === 'all') {
|
|
960
|
+
lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
|
|
961
|
+
} else {
|
|
962
|
+
lngs.push(options.lng || this.language);
|
|
963
|
+
}
|
|
964
|
+
var send = function send(l, k, specificDefaultValue) {
|
|
965
|
+
var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
966
|
+
if (_this2.options.missingKeyHandler) {
|
|
967
|
+
_this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
968
|
+
} else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
|
|
969
|
+
_this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
970
|
+
}
|
|
971
|
+
_this2.emit('missingKey', l, namespace, k, res);
|
|
972
|
+
};
|
|
973
|
+
if (this.options.saveMissing) {
|
|
974
|
+
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
975
|
+
lngs.forEach(function (language) {
|
|
976
|
+
_this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {
|
|
977
|
+
send([language], key + suffix, options["defaultValue".concat(suffix)] || defaultValue);
|
|
978
|
+
});
|
|
979
|
+
});
|
|
980
|
+
} else {
|
|
981
|
+
send(lngs, key, defaultValue);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
res = this.extendTranslation(res, keys, options, resolved, lastKey);
|
|
986
|
+
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
|
|
987
|
+
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
988
|
+
if (this.options.compatibilityAPI !== 'v1') {
|
|
989
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? "".concat(namespace, ":").concat(key) : key, usedDefault ? res : undefined);
|
|
990
|
+
} else {
|
|
991
|
+
res = this.options.parseMissingKeyHandler(res);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if (returnDetails) {
|
|
996
|
+
resolved.res = res;
|
|
997
|
+
return resolved;
|
|
998
|
+
}
|
|
999
|
+
return res;
|
|
1000
|
+
}
|
|
1001
|
+
}, {
|
|
1002
|
+
key: "extendTranslation",
|
|
1003
|
+
value: function extendTranslation(res, key, options, resolved, lastKey) {
|
|
1004
|
+
var _this3 = this;
|
|
1005
|
+
if (this.i18nFormat && this.i18nFormat.parse) {
|
|
1006
|
+
res = this.i18nFormat.parse(res, _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
1007
|
+
resolved: resolved
|
|
1008
|
+
});
|
|
1009
|
+
} else if (!options.skipInterpolation) {
|
|
1010
|
+
if (options.interpolation) this.interpolator.init(_objectSpread$4(_objectSpread$4({}, options), {
|
|
1011
|
+
interpolation: _objectSpread$4(_objectSpread$4({}, this.options.interpolation), options.interpolation)
|
|
1012
|
+
}));
|
|
1013
|
+
var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
1014
|
+
var nestBef;
|
|
1015
|
+
if (skipOnVariables) {
|
|
1016
|
+
var nb = res.match(this.interpolator.nestingRegexp);
|
|
1017
|
+
nestBef = nb && nb.length;
|
|
1018
|
+
}
|
|
1019
|
+
var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
|
|
1020
|
+
if (this.options.interpolation.defaultVariables) data = _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), data);
|
|
1021
|
+
res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
|
|
1022
|
+
if (skipOnVariables) {
|
|
1023
|
+
var na = res.match(this.interpolator.nestingRegexp);
|
|
1024
|
+
var nestAft = na && na.length;
|
|
1025
|
+
if (nestBef < nestAft) options.nest = false;
|
|
1026
|
+
}
|
|
1027
|
+
if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;
|
|
1028
|
+
if (options.nest !== false) res = this.interpolator.nest(res, function () {
|
|
1029
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1030
|
+
args[_key] = arguments[_key];
|
|
1031
|
+
}
|
|
1032
|
+
if (lastKey && lastKey[0] === args[0] && !options.context) {
|
|
1033
|
+
_this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
|
|
1034
|
+
return null;
|
|
1035
|
+
}
|
|
1036
|
+
return _this3.translate.apply(_this3, args.concat([key]));
|
|
1037
|
+
}, options);
|
|
1038
|
+
if (options.interpolation) this.interpolator.reset();
|
|
1039
|
+
}
|
|
1040
|
+
var postProcess = options.postProcess || this.options.postProcess;
|
|
1041
|
+
var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
|
|
1042
|
+
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
|
1043
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4({
|
|
1044
|
+
i18nResolved: resolved
|
|
1045
|
+
}, options) : options, this);
|
|
1046
|
+
}
|
|
1047
|
+
return res;
|
|
1048
|
+
}
|
|
1049
|
+
}, {
|
|
1050
|
+
key: "resolve",
|
|
1051
|
+
value: function resolve(keys) {
|
|
1052
|
+
var _this4 = this;
|
|
1053
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1054
|
+
var found;
|
|
1055
|
+
var usedKey;
|
|
1056
|
+
var exactUsedKey;
|
|
1057
|
+
var usedLng;
|
|
1058
|
+
var usedNS;
|
|
1059
|
+
if (typeof keys === 'string') keys = [keys];
|
|
1060
|
+
keys.forEach(function (k) {
|
|
1061
|
+
if (_this4.isValidLookup(found)) return;
|
|
1062
|
+
var extracted = _this4.extractFromKey(k, options);
|
|
1063
|
+
var key = extracted.key;
|
|
1064
|
+
usedKey = key;
|
|
1065
|
+
var namespaces = extracted.namespaces;
|
|
1066
|
+
if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
|
|
1067
|
+
var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
|
|
1068
|
+
var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
|
|
1069
|
+
var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
|
|
1070
|
+
var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
|
|
1071
|
+
namespaces.forEach(function (ns) {
|
|
1072
|
+
if (_this4.isValidLookup(found)) return;
|
|
1073
|
+
usedNS = ns;
|
|
1074
|
+
if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
|
|
1075
|
+
checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
|
|
1076
|
+
_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!!!');
|
|
1077
|
+
}
|
|
1078
|
+
codes.forEach(function (code) {
|
|
1079
|
+
if (_this4.isValidLookup(found)) return;
|
|
1080
|
+
usedLng = code;
|
|
1081
|
+
var finalKeys = [key];
|
|
1082
|
+
if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
|
|
1083
|
+
_this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
|
|
1084
|
+
} else {
|
|
1085
|
+
var pluralSuffix;
|
|
1086
|
+
if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
|
|
1087
|
+
var zeroSuffix = "".concat(_this4.options.pluralSeparator, "zero");
|
|
1088
|
+
if (needsPluralHandling) {
|
|
1089
|
+
finalKeys.push(key + pluralSuffix);
|
|
1090
|
+
if (needsZeroSuffixLookup) {
|
|
1091
|
+
finalKeys.push(key + zeroSuffix);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
if (needsContextHandling) {
|
|
1095
|
+
var contextKey = "".concat(key).concat(_this4.options.contextSeparator).concat(options.context);
|
|
1096
|
+
finalKeys.push(contextKey);
|
|
1097
|
+
if (needsPluralHandling) {
|
|
1098
|
+
finalKeys.push(contextKey + pluralSuffix);
|
|
1099
|
+
if (needsZeroSuffixLookup) {
|
|
1100
|
+
finalKeys.push(contextKey + zeroSuffix);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
var possibleKey;
|
|
1106
|
+
while (possibleKey = finalKeys.pop()) {
|
|
1107
|
+
if (!_this4.isValidLookup(found)) {
|
|
1108
|
+
exactUsedKey = possibleKey;
|
|
1109
|
+
found = _this4.getResource(code, ns, possibleKey, options);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
});
|
|
1114
|
+
});
|
|
1115
|
+
return {
|
|
1116
|
+
res: found,
|
|
1117
|
+
usedKey: usedKey,
|
|
1118
|
+
exactUsedKey: exactUsedKey,
|
|
1119
|
+
usedLng: usedLng,
|
|
1120
|
+
usedNS: usedNS
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
}, {
|
|
1124
|
+
key: "isValidLookup",
|
|
1125
|
+
value: function isValidLookup(res) {
|
|
1126
|
+
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
|
1127
|
+
}
|
|
1128
|
+
}, {
|
|
1129
|
+
key: "getResource",
|
|
1130
|
+
value: function getResource(code, ns, key) {
|
|
1131
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1132
|
+
if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
1133
|
+
return this.resourceStore.getResource(code, ns, key, options);
|
|
1134
|
+
}
|
|
1135
|
+
}], [{
|
|
1136
|
+
key: "hasDefaultValue",
|
|
1137
|
+
value: function hasDefaultValue(options) {
|
|
1138
|
+
var prefix = 'defaultValue';
|
|
1139
|
+
for (var option in options) {
|
|
1140
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
|
1141
|
+
return true;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
return false;
|
|
1145
|
+
}
|
|
1146
|
+
}]);
|
|
1147
|
+
return Translator;
|
|
1148
|
+
}(EventEmitter);
|
|
1149
|
+
|
|
1150
|
+
function capitalize(string) {
|
|
1151
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
1152
|
+
}
|
|
1153
|
+
var LanguageUtil = function () {
|
|
1154
|
+
function LanguageUtil(options) {
|
|
1155
|
+
_classCallCheck$1(this, LanguageUtil);
|
|
1156
|
+
this.options = options;
|
|
1157
|
+
this.supportedLngs = this.options.supportedLngs || false;
|
|
1158
|
+
this.logger = baseLogger.create('languageUtils');
|
|
1159
|
+
}
|
|
1160
|
+
_createClass$1(LanguageUtil, [{
|
|
1161
|
+
key: "getScriptPartFromCode",
|
|
1162
|
+
value: function getScriptPartFromCode(code) {
|
|
1163
|
+
if (!code || code.indexOf('-') < 0) return null;
|
|
1164
|
+
var p = code.split('-');
|
|
1165
|
+
if (p.length === 2) return null;
|
|
1166
|
+
p.pop();
|
|
1167
|
+
if (p[p.length - 1].toLowerCase() === 'x') return null;
|
|
1168
|
+
return this.formatLanguageCode(p.join('-'));
|
|
1169
|
+
}
|
|
1170
|
+
}, {
|
|
1171
|
+
key: "getLanguagePartFromCode",
|
|
1172
|
+
value: function getLanguagePartFromCode(code) {
|
|
1173
|
+
if (!code || code.indexOf('-') < 0) return code;
|
|
1174
|
+
var p = code.split('-');
|
|
1175
|
+
return this.formatLanguageCode(p[0]);
|
|
1176
|
+
}
|
|
1177
|
+
}, {
|
|
1178
|
+
key: "formatLanguageCode",
|
|
1179
|
+
value: function formatLanguageCode(code) {
|
|
1180
|
+
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
1181
|
+
var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
|
|
1182
|
+
var p = code.split('-');
|
|
1183
|
+
if (this.options.lowerCaseLng) {
|
|
1184
|
+
p = p.map(function (part) {
|
|
1185
|
+
return part.toLowerCase();
|
|
1186
|
+
});
|
|
1187
|
+
} else if (p.length === 2) {
|
|
1188
|
+
p[0] = p[0].toLowerCase();
|
|
1189
|
+
p[1] = p[1].toUpperCase();
|
|
1190
|
+
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
1191
|
+
} else if (p.length === 3) {
|
|
1192
|
+
p[0] = p[0].toLowerCase();
|
|
1193
|
+
if (p[1].length === 2) p[1] = p[1].toUpperCase();
|
|
1194
|
+
if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
|
|
1195
|
+
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
1196
|
+
if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
|
|
1197
|
+
}
|
|
1198
|
+
return p.join('-');
|
|
1199
|
+
}
|
|
1200
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
1201
|
+
}
|
|
1202
|
+
}, {
|
|
1203
|
+
key: "isSupportedCode",
|
|
1204
|
+
value: function isSupportedCode(code) {
|
|
1205
|
+
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
1206
|
+
code = this.getLanguagePartFromCode(code);
|
|
1207
|
+
}
|
|
1208
|
+
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
|
1209
|
+
}
|
|
1210
|
+
}, {
|
|
1211
|
+
key: "getBestMatchFromCodes",
|
|
1212
|
+
value: function getBestMatchFromCodes(codes) {
|
|
1213
|
+
var _this = this;
|
|
1214
|
+
if (!codes) return null;
|
|
1215
|
+
var found;
|
|
1216
|
+
codes.forEach(function (code) {
|
|
1217
|
+
if (found) return;
|
|
1218
|
+
var cleanedLng = _this.formatLanguageCode(code);
|
|
1219
|
+
if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
|
1220
|
+
});
|
|
1221
|
+
if (!found && this.options.supportedLngs) {
|
|
1222
|
+
codes.forEach(function (code) {
|
|
1223
|
+
if (found) return;
|
|
1224
|
+
var lngOnly = _this.getLanguagePartFromCode(code);
|
|
1225
|
+
if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
1226
|
+
found = _this.options.supportedLngs.find(function (supportedLng) {
|
|
1227
|
+
if (supportedLng === lngOnly) return supportedLng;
|
|
1228
|
+
if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
|
|
1229
|
+
if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
|
|
1230
|
+
});
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
|
1234
|
+
return found;
|
|
1235
|
+
}
|
|
1236
|
+
}, {
|
|
1237
|
+
key: "getFallbackCodes",
|
|
1238
|
+
value: function getFallbackCodes(fallbacks, code) {
|
|
1239
|
+
if (!fallbacks) return [];
|
|
1240
|
+
if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
|
|
1241
|
+
if (typeof fallbacks === 'string') fallbacks = [fallbacks];
|
|
1242
|
+
if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
|
|
1243
|
+
if (!code) return fallbacks["default"] || [];
|
|
1244
|
+
var found = fallbacks[code];
|
|
1245
|
+
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
|
1246
|
+
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
|
1247
|
+
if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
|
|
1248
|
+
if (!found) found = fallbacks["default"];
|
|
1249
|
+
return found || [];
|
|
1250
|
+
}
|
|
1251
|
+
}, {
|
|
1252
|
+
key: "toResolveHierarchy",
|
|
1253
|
+
value: function toResolveHierarchy(code, fallbackCode) {
|
|
1254
|
+
var _this2 = this;
|
|
1255
|
+
var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
|
1256
|
+
var codes = [];
|
|
1257
|
+
var addCode = function addCode(c) {
|
|
1258
|
+
if (!c) return;
|
|
1259
|
+
if (_this2.isSupportedCode(c)) {
|
|
1260
|
+
codes.push(c);
|
|
1261
|
+
} else {
|
|
1262
|
+
_this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
if (typeof code === 'string' && code.indexOf('-') > -1) {
|
|
1266
|
+
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
1267
|
+
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
1268
|
+
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
|
1269
|
+
} else if (typeof code === 'string') {
|
|
1270
|
+
addCode(this.formatLanguageCode(code));
|
|
1271
|
+
}
|
|
1272
|
+
fallbackCodes.forEach(function (fc) {
|
|
1273
|
+
if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
|
|
1274
|
+
});
|
|
1275
|
+
return codes;
|
|
1276
|
+
}
|
|
1277
|
+
}]);
|
|
1278
|
+
return LanguageUtil;
|
|
1279
|
+
}();
|
|
1280
|
+
|
|
1281
|
+
var sets = [{
|
|
1282
|
+
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
|
|
1283
|
+
nr: [1, 2],
|
|
1284
|
+
fc: 1
|
|
1285
|
+
}, {
|
|
1286
|
+
lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
|
|
1287
|
+
nr: [1, 2],
|
|
1288
|
+
fc: 2
|
|
1289
|
+
}, {
|
|
1290
|
+
lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
|
|
1291
|
+
nr: [1],
|
|
1292
|
+
fc: 3
|
|
1293
|
+
}, {
|
|
1294
|
+
lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
|
|
1295
|
+
nr: [1, 2, 5],
|
|
1296
|
+
fc: 4
|
|
1297
|
+
}, {
|
|
1298
|
+
lngs: ['ar'],
|
|
1299
|
+
nr: [0, 1, 2, 3, 11, 100],
|
|
1300
|
+
fc: 5
|
|
1301
|
+
}, {
|
|
1302
|
+
lngs: ['cs', 'sk'],
|
|
1303
|
+
nr: [1, 2, 5],
|
|
1304
|
+
fc: 6
|
|
1305
|
+
}, {
|
|
1306
|
+
lngs: ['csb', 'pl'],
|
|
1307
|
+
nr: [1, 2, 5],
|
|
1308
|
+
fc: 7
|
|
1309
|
+
}, {
|
|
1310
|
+
lngs: ['cy'],
|
|
1311
|
+
nr: [1, 2, 3, 8],
|
|
1312
|
+
fc: 8
|
|
1313
|
+
}, {
|
|
1314
|
+
lngs: ['fr'],
|
|
1315
|
+
nr: [1, 2],
|
|
1316
|
+
fc: 9
|
|
1317
|
+
}, {
|
|
1318
|
+
lngs: ['ga'],
|
|
1319
|
+
nr: [1, 2, 3, 7, 11],
|
|
1320
|
+
fc: 10
|
|
1321
|
+
}, {
|
|
1322
|
+
lngs: ['gd'],
|
|
1323
|
+
nr: [1, 2, 3, 20],
|
|
1324
|
+
fc: 11
|
|
1325
|
+
}, {
|
|
1326
|
+
lngs: ['is'],
|
|
1327
|
+
nr: [1, 2],
|
|
1328
|
+
fc: 12
|
|
1329
|
+
}, {
|
|
1330
|
+
lngs: ['jv'],
|
|
1331
|
+
nr: [0, 1],
|
|
1332
|
+
fc: 13
|
|
1333
|
+
}, {
|
|
1334
|
+
lngs: ['kw'],
|
|
1335
|
+
nr: [1, 2, 3, 4],
|
|
1336
|
+
fc: 14
|
|
1337
|
+
}, {
|
|
1338
|
+
lngs: ['lt'],
|
|
1339
|
+
nr: [1, 2, 10],
|
|
1340
|
+
fc: 15
|
|
1341
|
+
}, {
|
|
1342
|
+
lngs: ['lv'],
|
|
1343
|
+
nr: [1, 2, 0],
|
|
1344
|
+
fc: 16
|
|
1345
|
+
}, {
|
|
1346
|
+
lngs: ['mk'],
|
|
1347
|
+
nr: [1, 2],
|
|
1348
|
+
fc: 17
|
|
1349
|
+
}, {
|
|
1350
|
+
lngs: ['mnk'],
|
|
1351
|
+
nr: [0, 1, 2],
|
|
1352
|
+
fc: 18
|
|
1353
|
+
}, {
|
|
1354
|
+
lngs: ['mt'],
|
|
1355
|
+
nr: [1, 2, 11, 20],
|
|
1356
|
+
fc: 19
|
|
1357
|
+
}, {
|
|
1358
|
+
lngs: ['or'],
|
|
1359
|
+
nr: [2, 1],
|
|
1360
|
+
fc: 2
|
|
1361
|
+
}, {
|
|
1362
|
+
lngs: ['ro'],
|
|
1363
|
+
nr: [1, 2, 20],
|
|
1364
|
+
fc: 20
|
|
1365
|
+
}, {
|
|
1366
|
+
lngs: ['sl'],
|
|
1367
|
+
nr: [5, 1, 2, 3],
|
|
1368
|
+
fc: 21
|
|
1369
|
+
}, {
|
|
1370
|
+
lngs: ['he', 'iw'],
|
|
1371
|
+
nr: [1, 2, 20, 21],
|
|
1372
|
+
fc: 22
|
|
1373
|
+
}];
|
|
1374
|
+
var _rulesPluralsTypes = {
|
|
1375
|
+
1: function _(n) {
|
|
1376
|
+
return Number(n > 1);
|
|
1377
|
+
},
|
|
1378
|
+
2: function _(n) {
|
|
1379
|
+
return Number(n != 1);
|
|
1380
|
+
},
|
|
1381
|
+
3: function _(n) {
|
|
1382
|
+
return 0;
|
|
1383
|
+
},
|
|
1384
|
+
4: function _(n) {
|
|
1385
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
1386
|
+
},
|
|
1387
|
+
5: function _(n) {
|
|
1388
|
+
return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
|
|
1389
|
+
},
|
|
1390
|
+
6: function _(n) {
|
|
1391
|
+
return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
|
|
1392
|
+
},
|
|
1393
|
+
7: function _(n) {
|
|
1394
|
+
return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
1395
|
+
},
|
|
1396
|
+
8: function _(n) {
|
|
1397
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
|
1398
|
+
},
|
|
1399
|
+
9: function _(n) {
|
|
1400
|
+
return Number(n >= 2);
|
|
1401
|
+
},
|
|
1402
|
+
10: function _(n) {
|
|
1403
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
|
1404
|
+
},
|
|
1405
|
+
11: function _(n) {
|
|
1406
|
+
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
|
1407
|
+
},
|
|
1408
|
+
12: function _(n) {
|
|
1409
|
+
return Number(n % 10 != 1 || n % 100 == 11);
|
|
1410
|
+
},
|
|
1411
|
+
13: function _(n) {
|
|
1412
|
+
return Number(n !== 0);
|
|
1413
|
+
},
|
|
1414
|
+
14: function _(n) {
|
|
1415
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
|
1416
|
+
},
|
|
1417
|
+
15: function _(n) {
|
|
1418
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
1419
|
+
},
|
|
1420
|
+
16: function _(n) {
|
|
1421
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
|
1422
|
+
},
|
|
1423
|
+
17: function _(n) {
|
|
1424
|
+
return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
|
|
1425
|
+
},
|
|
1426
|
+
18: function _(n) {
|
|
1427
|
+
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
|
1428
|
+
},
|
|
1429
|
+
19: function _(n) {
|
|
1430
|
+
return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
|
|
1431
|
+
},
|
|
1432
|
+
20: function _(n) {
|
|
1433
|
+
return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
|
|
1434
|
+
},
|
|
1435
|
+
21: function _(n) {
|
|
1436
|
+
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
|
1437
|
+
},
|
|
1438
|
+
22: function _(n) {
|
|
1439
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
var deprecatedJsonVersions = ['v1', 'v2', 'v3'];
|
|
1443
|
+
var suffixesOrder = {
|
|
1444
|
+
zero: 0,
|
|
1445
|
+
one: 1,
|
|
1446
|
+
two: 2,
|
|
1447
|
+
few: 3,
|
|
1448
|
+
many: 4,
|
|
1449
|
+
other: 5
|
|
1450
|
+
};
|
|
1451
|
+
function createRules() {
|
|
1452
|
+
var rules = {};
|
|
1453
|
+
sets.forEach(function (set) {
|
|
1454
|
+
set.lngs.forEach(function (l) {
|
|
1455
|
+
rules[l] = {
|
|
1456
|
+
numbers: set.nr,
|
|
1457
|
+
plurals: _rulesPluralsTypes[set.fc]
|
|
1458
|
+
};
|
|
1459
|
+
});
|
|
1460
|
+
});
|
|
1461
|
+
return rules;
|
|
1462
|
+
}
|
|
1463
|
+
var PluralResolver = function () {
|
|
1464
|
+
function PluralResolver(languageUtils) {
|
|
1465
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1466
|
+
_classCallCheck$1(this, PluralResolver);
|
|
1467
|
+
this.languageUtils = languageUtils;
|
|
1468
|
+
this.options = options;
|
|
1469
|
+
this.logger = baseLogger.create('pluralResolver');
|
|
1470
|
+
if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
|
|
1471
|
+
this.options.compatibilityJSON = 'v3';
|
|
1472
|
+
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.');
|
|
1473
|
+
}
|
|
1474
|
+
this.rules = createRules();
|
|
1475
|
+
}
|
|
1476
|
+
_createClass$1(PluralResolver, [{
|
|
1477
|
+
key: "addRule",
|
|
1478
|
+
value: function addRule(lng, obj) {
|
|
1479
|
+
this.rules[lng] = obj;
|
|
1480
|
+
}
|
|
1481
|
+
}, {
|
|
1482
|
+
key: "getRule",
|
|
1483
|
+
value: function getRule(code) {
|
|
1484
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1485
|
+
if (this.shouldUseIntlApi()) {
|
|
1486
|
+
try {
|
|
1487
|
+
return new Intl.PluralRules(code, {
|
|
1488
|
+
type: options.ordinal ? 'ordinal' : 'cardinal'
|
|
1489
|
+
});
|
|
1490
|
+
} catch (_unused) {
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
|
|
1495
|
+
}
|
|
1496
|
+
}, {
|
|
1497
|
+
key: "needsPlural",
|
|
1498
|
+
value: function needsPlural(code) {
|
|
1499
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1500
|
+
var rule = this.getRule(code, options);
|
|
1501
|
+
if (this.shouldUseIntlApi()) {
|
|
1502
|
+
return rule && rule.resolvedOptions().pluralCategories.length > 1;
|
|
1503
|
+
}
|
|
1504
|
+
return rule && rule.numbers.length > 1;
|
|
1505
|
+
}
|
|
1506
|
+
}, {
|
|
1507
|
+
key: "getPluralFormsOfKey",
|
|
1508
|
+
value: function getPluralFormsOfKey(code, key) {
|
|
1509
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1510
|
+
return this.getSuffixes(code, options).map(function (suffix) {
|
|
1511
|
+
return "".concat(key).concat(suffix);
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
}, {
|
|
1515
|
+
key: "getSuffixes",
|
|
1516
|
+
value: function getSuffixes(code) {
|
|
1517
|
+
var _this = this;
|
|
1518
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1519
|
+
var rule = this.getRule(code, options);
|
|
1520
|
+
if (!rule) {
|
|
1521
|
+
return [];
|
|
1522
|
+
}
|
|
1523
|
+
if (this.shouldUseIntlApi()) {
|
|
1524
|
+
return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
|
|
1525
|
+
return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
|
|
1526
|
+
}).map(function (pluralCategory) {
|
|
1527
|
+
return "".concat(_this.options.prepend).concat(pluralCategory);
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
return rule.numbers.map(function (number) {
|
|
1531
|
+
return _this.getSuffix(code, number, options);
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
}, {
|
|
1535
|
+
key: "getSuffix",
|
|
1536
|
+
value: function getSuffix(code, count) {
|
|
1537
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1538
|
+
var rule = this.getRule(code, options);
|
|
1539
|
+
if (rule) {
|
|
1540
|
+
if (this.shouldUseIntlApi()) {
|
|
1541
|
+
return "".concat(this.options.prepend).concat(rule.select(count));
|
|
1542
|
+
}
|
|
1543
|
+
return this.getSuffixRetroCompatible(rule, count);
|
|
1544
|
+
}
|
|
1545
|
+
this.logger.warn("no plural rule found for: ".concat(code));
|
|
1546
|
+
return '';
|
|
1547
|
+
}
|
|
1548
|
+
}, {
|
|
1549
|
+
key: "getSuffixRetroCompatible",
|
|
1550
|
+
value: function getSuffixRetroCompatible(rule, count) {
|
|
1551
|
+
var _this2 = this;
|
|
1552
|
+
var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
1553
|
+
var suffix = rule.numbers[idx];
|
|
1554
|
+
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1555
|
+
if (suffix === 2) {
|
|
1556
|
+
suffix = 'plural';
|
|
1557
|
+
} else if (suffix === 1) {
|
|
1558
|
+
suffix = '';
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
var returnSuffix = function returnSuffix() {
|
|
1562
|
+
return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
|
|
1563
|
+
};
|
|
1564
|
+
if (this.options.compatibilityJSON === 'v1') {
|
|
1565
|
+
if (suffix === 1) return '';
|
|
1566
|
+
if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
|
|
1567
|
+
return returnSuffix();
|
|
1568
|
+
} else if (this.options.compatibilityJSON === 'v2') {
|
|
1569
|
+
return returnSuffix();
|
|
1570
|
+
} else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1571
|
+
return returnSuffix();
|
|
1572
|
+
}
|
|
1573
|
+
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
|
1574
|
+
}
|
|
1575
|
+
}, {
|
|
1576
|
+
key: "shouldUseIntlApi",
|
|
1577
|
+
value: function shouldUseIntlApi() {
|
|
1578
|
+
return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
|
|
1579
|
+
}
|
|
1580
|
+
}]);
|
|
1581
|
+
return PluralResolver;
|
|
1582
|
+
}();
|
|
1583
|
+
|
|
1584
|
+
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; }
|
|
1585
|
+
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; }
|
|
1586
|
+
function deepFindWithDefaults(data, defaultData, key) {
|
|
1587
|
+
var keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
|
|
1588
|
+
var ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1589
|
+
var path = getPathWithDefaults(data, defaultData, key);
|
|
1590
|
+
if (!path && ignoreJSONStructure && typeof key === 'string') {
|
|
1591
|
+
path = deepFind(data, key, keySeparator);
|
|
1592
|
+
if (path === undefined) path = deepFind(defaultData, key, keySeparator);
|
|
1593
|
+
}
|
|
1594
|
+
return path;
|
|
1595
|
+
}
|
|
1596
|
+
var Interpolator = function () {
|
|
1597
|
+
function Interpolator() {
|
|
1598
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1599
|
+
_classCallCheck$1(this, Interpolator);
|
|
1600
|
+
this.logger = baseLogger.create('interpolator');
|
|
1601
|
+
this.options = options;
|
|
1602
|
+
this.format = options.interpolation && options.interpolation.format || function (value) {
|
|
1603
|
+
return value;
|
|
1604
|
+
};
|
|
1605
|
+
this.init(options);
|
|
1606
|
+
}
|
|
1607
|
+
_createClass$1(Interpolator, [{
|
|
1608
|
+
key: "init",
|
|
1609
|
+
value: function init() {
|
|
1610
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1611
|
+
if (!options.interpolation) options.interpolation = {
|
|
1612
|
+
escapeValue: true
|
|
1613
|
+
};
|
|
1614
|
+
var iOpts = options.interpolation;
|
|
1615
|
+
this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
|
|
1616
|
+
this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
|
|
1617
|
+
this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
|
|
1618
|
+
this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
|
|
1619
|
+
this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
|
|
1620
|
+
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
|
1621
|
+
this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
|
|
1622
|
+
this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
|
|
1623
|
+
this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
|
|
1624
|
+
this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
|
|
1625
|
+
this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
|
|
1626
|
+
this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
|
|
1627
|
+
this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
|
|
1628
|
+
this.resetRegExp();
|
|
1629
|
+
}
|
|
1630
|
+
}, {
|
|
1631
|
+
key: "reset",
|
|
1632
|
+
value: function reset() {
|
|
1633
|
+
if (this.options) this.init(this.options);
|
|
1634
|
+
}
|
|
1635
|
+
}, {
|
|
1636
|
+
key: "resetRegExp",
|
|
1637
|
+
value: function resetRegExp() {
|
|
1638
|
+
var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
|
|
1639
|
+
this.regexp = new RegExp(regexpStr, 'g');
|
|
1640
|
+
var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
|
|
1641
|
+
this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
|
|
1642
|
+
var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
|
|
1643
|
+
this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
|
|
1644
|
+
}
|
|
1645
|
+
}, {
|
|
1646
|
+
key: "interpolate",
|
|
1647
|
+
value: function interpolate(str, data, lng, options) {
|
|
1648
|
+
var _this = this;
|
|
1649
|
+
var match;
|
|
1650
|
+
var value;
|
|
1651
|
+
var replaces;
|
|
1652
|
+
var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
1653
|
+
function regexSafe(val) {
|
|
1654
|
+
return val.replace(/\$/g, '$$$$');
|
|
1655
|
+
}
|
|
1656
|
+
var handleFormat = function handleFormat(key) {
|
|
1657
|
+
if (key.indexOf(_this.formatSeparator) < 0) {
|
|
1658
|
+
var path = deepFindWithDefaults(data, defaultData, key, _this.options.keySeparator, _this.options.ignoreJSONStructure);
|
|
1659
|
+
return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
1660
|
+
interpolationkey: key
|
|
1661
|
+
})) : path;
|
|
1662
|
+
}
|
|
1663
|
+
var p = key.split(_this.formatSeparator);
|
|
1664
|
+
var k = p.shift().trim();
|
|
1665
|
+
var f = p.join(_this.formatSeparator).trim();
|
|
1666
|
+
return _this.format(deepFindWithDefaults(data, defaultData, k, _this.options.keySeparator, _this.options.ignoreJSONStructure), f, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
|
|
1667
|
+
interpolationkey: k
|
|
1668
|
+
}));
|
|
1669
|
+
};
|
|
1670
|
+
this.resetRegExp();
|
|
1671
|
+
var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
1672
|
+
var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
1673
|
+
var todos = [{
|
|
1674
|
+
regex: this.regexpUnescape,
|
|
1675
|
+
safeValue: function safeValue(val) {
|
|
1676
|
+
return regexSafe(val);
|
|
1677
|
+
}
|
|
1678
|
+
}, {
|
|
1679
|
+
regex: this.regexp,
|
|
1680
|
+
safeValue: function safeValue(val) {
|
|
1681
|
+
return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
|
|
1682
|
+
}
|
|
1683
|
+
}];
|
|
1684
|
+
todos.forEach(function (todo) {
|
|
1685
|
+
replaces = 0;
|
|
1686
|
+
while (match = todo.regex.exec(str)) {
|
|
1687
|
+
var matchedVar = match[1].trim();
|
|
1688
|
+
value = handleFormat(matchedVar);
|
|
1689
|
+
if (value === undefined) {
|
|
1690
|
+
if (typeof missingInterpolationHandler === 'function') {
|
|
1691
|
+
var temp = missingInterpolationHandler(str, match, options);
|
|
1692
|
+
value = typeof temp === 'string' ? temp : '';
|
|
1693
|
+
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
|
1694
|
+
value = '';
|
|
1695
|
+
} else if (skipOnVariables) {
|
|
1696
|
+
value = match[0];
|
|
1697
|
+
continue;
|
|
1698
|
+
} else {
|
|
1699
|
+
_this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
|
|
1700
|
+
value = '';
|
|
1701
|
+
}
|
|
1702
|
+
} else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
|
|
1703
|
+
value = makeString(value);
|
|
1704
|
+
}
|
|
1705
|
+
var safeValue = todo.safeValue(value);
|
|
1706
|
+
str = str.replace(match[0], safeValue);
|
|
1707
|
+
if (skipOnVariables) {
|
|
1708
|
+
todo.regex.lastIndex += value.length;
|
|
1709
|
+
todo.regex.lastIndex -= match[0].length;
|
|
1710
|
+
} else {
|
|
1711
|
+
todo.regex.lastIndex = 0;
|
|
1712
|
+
}
|
|
1713
|
+
replaces++;
|
|
1714
|
+
if (replaces >= _this.maxReplaces) {
|
|
1715
|
+
break;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
return str;
|
|
1720
|
+
}
|
|
1721
|
+
}, {
|
|
1722
|
+
key: "nest",
|
|
1723
|
+
value: function nest(str, fc) {
|
|
1724
|
+
var _this2 = this;
|
|
1725
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1726
|
+
var match;
|
|
1727
|
+
var value;
|
|
1728
|
+
var clonedOptions;
|
|
1729
|
+
function handleHasOptions(key, inheritedOptions) {
|
|
1730
|
+
var sep = this.nestingOptionsSeparator;
|
|
1731
|
+
if (key.indexOf(sep) < 0) return key;
|
|
1732
|
+
var c = key.split(new RegExp("".concat(sep, "[ ]*{")));
|
|
1733
|
+
var optionsString = "{".concat(c[1]);
|
|
1734
|
+
key = c[0];
|
|
1735
|
+
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
1736
|
+
var matchedSingleQuotes = optionsString.match(/'/g);
|
|
1737
|
+
var matchedDoubleQuotes = optionsString.match(/"/g);
|
|
1738
|
+
if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
|
|
1739
|
+
optionsString = optionsString.replace(/'/g, '"');
|
|
1740
|
+
}
|
|
1741
|
+
try {
|
|
1742
|
+
clonedOptions = JSON.parse(optionsString);
|
|
1743
|
+
if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);
|
|
1744
|
+
} catch (e) {
|
|
1745
|
+
this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
|
|
1746
|
+
return "".concat(key).concat(sep).concat(optionsString);
|
|
1747
|
+
}
|
|
1748
|
+
delete clonedOptions.defaultValue;
|
|
1749
|
+
return key;
|
|
1750
|
+
}
|
|
1751
|
+
while (match = this.nestingRegexp.exec(str)) {
|
|
1752
|
+
var formatters = [];
|
|
1753
|
+
clonedOptions = _objectSpread$3({}, options);
|
|
1754
|
+
clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
|
|
1755
|
+
clonedOptions.applyPostProcessor = false;
|
|
1756
|
+
delete clonedOptions.defaultValue;
|
|
1757
|
+
var doReduce = false;
|
|
1758
|
+
if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
|
|
1759
|
+
var r = match[1].split(this.formatSeparator).map(function (elem) {
|
|
1760
|
+
return elem.trim();
|
|
1761
|
+
});
|
|
1762
|
+
match[1] = r.shift();
|
|
1763
|
+
formatters = r;
|
|
1764
|
+
doReduce = true;
|
|
1765
|
+
}
|
|
1766
|
+
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
1767
|
+
if (value && match[0] === str && typeof value !== 'string') return value;
|
|
1768
|
+
if (typeof value !== 'string') value = makeString(value);
|
|
1769
|
+
if (!value) {
|
|
1770
|
+
this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
|
|
1771
|
+
value = '';
|
|
1772
|
+
}
|
|
1773
|
+
if (doReduce) {
|
|
1774
|
+
value = formatters.reduce(function (v, f) {
|
|
1775
|
+
return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {
|
|
1776
|
+
interpolationkey: match[1].trim()
|
|
1777
|
+
}));
|
|
1778
|
+
}, value.trim());
|
|
1779
|
+
}
|
|
1780
|
+
str = str.replace(match[0], value);
|
|
1781
|
+
this.regexp.lastIndex = 0;
|
|
1782
|
+
}
|
|
1783
|
+
return str;
|
|
1784
|
+
}
|
|
1785
|
+
}]);
|
|
1786
|
+
return Interpolator;
|
|
1787
|
+
}();
|
|
1788
|
+
|
|
1789
|
+
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; }
|
|
1790
|
+
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; }
|
|
1791
|
+
function parseFormatStr(formatStr) {
|
|
1792
|
+
var formatName = formatStr.toLowerCase().trim();
|
|
1793
|
+
var formatOptions = {};
|
|
1794
|
+
if (formatStr.indexOf('(') > -1) {
|
|
1795
|
+
var p = formatStr.split('(');
|
|
1796
|
+
formatName = p[0].toLowerCase().trim();
|
|
1797
|
+
var optStr = p[1].substring(0, p[1].length - 1);
|
|
1798
|
+
if (formatName === 'currency' && optStr.indexOf(':') < 0) {
|
|
1799
|
+
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
1800
|
+
} else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
|
|
1801
|
+
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
|
1802
|
+
} else {
|
|
1803
|
+
var opts = optStr.split(';');
|
|
1804
|
+
opts.forEach(function (opt) {
|
|
1805
|
+
if (!opt) return;
|
|
1806
|
+
var _opt$split = opt.split(':'),
|
|
1807
|
+
_opt$split2 = _toArray(_opt$split),
|
|
1808
|
+
key = _opt$split2[0],
|
|
1809
|
+
rest = _opt$split2.slice(1);
|
|
1810
|
+
var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
|
|
1811
|
+
if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
|
|
1812
|
+
if (val === 'false') formatOptions[key.trim()] = false;
|
|
1813
|
+
if (val === 'true') formatOptions[key.trim()] = true;
|
|
1814
|
+
if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
return {
|
|
1819
|
+
formatName: formatName,
|
|
1820
|
+
formatOptions: formatOptions
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
function createCachedFormatter(fn) {
|
|
1824
|
+
var cache = {};
|
|
1825
|
+
return function invokeFormatter(val, lng, options) {
|
|
1826
|
+
var key = lng + JSON.stringify(options);
|
|
1827
|
+
var formatter = cache[key];
|
|
1828
|
+
if (!formatter) {
|
|
1829
|
+
formatter = fn(lng, options);
|
|
1830
|
+
cache[key] = formatter;
|
|
1831
|
+
}
|
|
1832
|
+
return formatter(val);
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
var Formatter = function () {
|
|
1836
|
+
function Formatter() {
|
|
1837
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1838
|
+
_classCallCheck$1(this, Formatter);
|
|
1839
|
+
this.logger = baseLogger.create('formatter');
|
|
1840
|
+
this.options = options;
|
|
1841
|
+
this.formats = {
|
|
1842
|
+
number: createCachedFormatter(function (lng, opt) {
|
|
1843
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$2({}, opt));
|
|
1844
|
+
return function (val) {
|
|
1845
|
+
return formatter.format(val);
|
|
1846
|
+
};
|
|
1847
|
+
}),
|
|
1848
|
+
currency: createCachedFormatter(function (lng, opt) {
|
|
1849
|
+
var formatter = new Intl.NumberFormat(lng, _objectSpread$2(_objectSpread$2({}, opt), {}, {
|
|
1850
|
+
style: 'currency'
|
|
1851
|
+
}));
|
|
1852
|
+
return function (val) {
|
|
1853
|
+
return formatter.format(val);
|
|
1854
|
+
};
|
|
1855
|
+
}),
|
|
1856
|
+
datetime: createCachedFormatter(function (lng, opt) {
|
|
1857
|
+
var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2({}, opt));
|
|
1858
|
+
return function (val) {
|
|
1859
|
+
return formatter.format(val);
|
|
1860
|
+
};
|
|
1861
|
+
}),
|
|
1862
|
+
relativetime: createCachedFormatter(function (lng, opt) {
|
|
1863
|
+
var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2({}, opt));
|
|
1864
|
+
return function (val) {
|
|
1865
|
+
return formatter.format(val, opt.range || 'day');
|
|
1866
|
+
};
|
|
1867
|
+
}),
|
|
1868
|
+
list: createCachedFormatter(function (lng, opt) {
|
|
1869
|
+
var formatter = new Intl.ListFormat(lng, _objectSpread$2({}, opt));
|
|
1870
|
+
return function (val) {
|
|
1871
|
+
return formatter.format(val);
|
|
1872
|
+
};
|
|
1873
|
+
})
|
|
1874
|
+
};
|
|
1875
|
+
this.init(options);
|
|
1876
|
+
}
|
|
1877
|
+
_createClass$1(Formatter, [{
|
|
1878
|
+
key: "init",
|
|
1879
|
+
value: function init(services) {
|
|
1880
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
1881
|
+
interpolation: {}
|
|
1882
|
+
};
|
|
1883
|
+
var iOpts = options.interpolation;
|
|
1884
|
+
this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
|
|
1885
|
+
}
|
|
1886
|
+
}, {
|
|
1887
|
+
key: "add",
|
|
1888
|
+
value: function add(name, fc) {
|
|
1889
|
+
this.formats[name.toLowerCase().trim()] = fc;
|
|
1890
|
+
}
|
|
1891
|
+
}, {
|
|
1892
|
+
key: "addCached",
|
|
1893
|
+
value: function addCached(name, fc) {
|
|
1894
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1895
|
+
}
|
|
1896
|
+
}, {
|
|
1897
|
+
key: "format",
|
|
1898
|
+
value: function format(value, _format, lng) {
|
|
1899
|
+
var _this = this;
|
|
1900
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1901
|
+
var formats = _format.split(this.formatSeparator);
|
|
1902
|
+
var result = formats.reduce(function (mem, f) {
|
|
1903
|
+
var _parseFormatStr = parseFormatStr(f),
|
|
1904
|
+
formatName = _parseFormatStr.formatName,
|
|
1905
|
+
formatOptions = _parseFormatStr.formatOptions;
|
|
1906
|
+
if (_this.formats[formatName]) {
|
|
1907
|
+
var formatted = mem;
|
|
1908
|
+
try {
|
|
1909
|
+
var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
|
|
1910
|
+
var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1911
|
+
formatted = _this.formats[formatName](mem, l, _objectSpread$2(_objectSpread$2(_objectSpread$2({}, formatOptions), options), valOptions));
|
|
1912
|
+
} catch (error) {
|
|
1913
|
+
_this.logger.warn(error);
|
|
1914
|
+
}
|
|
1915
|
+
return formatted;
|
|
1916
|
+
} else {
|
|
1917
|
+
_this.logger.warn("there was no format function for ".concat(formatName));
|
|
1918
|
+
}
|
|
1919
|
+
return mem;
|
|
1920
|
+
}, value);
|
|
1921
|
+
return result;
|
|
1922
|
+
}
|
|
1923
|
+
}]);
|
|
1924
|
+
return Formatter;
|
|
1925
|
+
}();
|
|
1926
|
+
|
|
1927
|
+
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; }
|
|
1928
|
+
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; }
|
|
1929
|
+
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); }; }
|
|
1930
|
+
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; } }
|
|
1931
|
+
function removePending(q, name) {
|
|
1932
|
+
if (q.pending[name] !== undefined) {
|
|
1933
|
+
delete q.pending[name];
|
|
1934
|
+
q.pendingCount--;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
var Connector = function (_EventEmitter) {
|
|
1938
|
+
_inherits(Connector, _EventEmitter);
|
|
1939
|
+
var _super = _createSuper$1(Connector);
|
|
1940
|
+
function Connector(backend, store, services) {
|
|
1941
|
+
var _this;
|
|
1942
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1943
|
+
_classCallCheck$1(this, Connector);
|
|
1944
|
+
_this = _super.call(this);
|
|
1945
|
+
if (isIE10) {
|
|
1946
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
1947
|
+
}
|
|
1948
|
+
_this.backend = backend;
|
|
1949
|
+
_this.store = store;
|
|
1950
|
+
_this.services = services;
|
|
1951
|
+
_this.languageUtils = services.languageUtils;
|
|
1952
|
+
_this.options = options;
|
|
1953
|
+
_this.logger = baseLogger.create('backendConnector');
|
|
1954
|
+
_this.waitingReads = [];
|
|
1955
|
+
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
1956
|
+
_this.readingCalls = 0;
|
|
1957
|
+
_this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
1958
|
+
_this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
1959
|
+
_this.state = {};
|
|
1960
|
+
_this.queue = [];
|
|
1961
|
+
if (_this.backend && _this.backend.init) {
|
|
1962
|
+
_this.backend.init(services, options.backend, options);
|
|
1963
|
+
}
|
|
1964
|
+
return _this;
|
|
1965
|
+
}
|
|
1966
|
+
_createClass$1(Connector, [{
|
|
1967
|
+
key: "queueLoad",
|
|
1968
|
+
value: function queueLoad(languages, namespaces, options, callback) {
|
|
1969
|
+
var _this2 = this;
|
|
1970
|
+
var toLoad = {};
|
|
1971
|
+
var pending = {};
|
|
1972
|
+
var toLoadLanguages = {};
|
|
1973
|
+
var toLoadNamespaces = {};
|
|
1974
|
+
languages.forEach(function (lng) {
|
|
1975
|
+
var hasAllNamespaces = true;
|
|
1976
|
+
namespaces.forEach(function (ns) {
|
|
1977
|
+
var name = "".concat(lng, "|").concat(ns);
|
|
1978
|
+
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
1979
|
+
_this2.state[name] = 2;
|
|
1980
|
+
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
1981
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1982
|
+
} else {
|
|
1983
|
+
_this2.state[name] = 1;
|
|
1984
|
+
hasAllNamespaces = false;
|
|
1985
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1986
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
1987
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1990
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1991
|
+
});
|
|
1992
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
1993
|
+
this.queue.push({
|
|
1994
|
+
pending: pending,
|
|
1995
|
+
pendingCount: Object.keys(pending).length,
|
|
1996
|
+
loaded: {},
|
|
1997
|
+
errors: [],
|
|
1998
|
+
callback: callback
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
return {
|
|
2002
|
+
toLoad: Object.keys(toLoad),
|
|
2003
|
+
pending: Object.keys(pending),
|
|
2004
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
2005
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
}, {
|
|
2009
|
+
key: "loaded",
|
|
2010
|
+
value: function loaded(name, err, data) {
|
|
2011
|
+
var s = name.split('|');
|
|
2012
|
+
var lng = s[0];
|
|
2013
|
+
var ns = s[1];
|
|
2014
|
+
if (err) this.emit('failedLoading', lng, ns, err);
|
|
2015
|
+
if (data) {
|
|
2016
|
+
this.store.addResourceBundle(lng, ns, data);
|
|
2017
|
+
}
|
|
2018
|
+
this.state[name] = err ? -1 : 2;
|
|
2019
|
+
var loaded = {};
|
|
2020
|
+
this.queue.forEach(function (q) {
|
|
2021
|
+
pushPath(q.loaded, [lng], ns);
|
|
2022
|
+
removePending(q, name);
|
|
2023
|
+
if (err) q.errors.push(err);
|
|
2024
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
2025
|
+
Object.keys(q.loaded).forEach(function (l) {
|
|
2026
|
+
if (!loaded[l]) loaded[l] = {};
|
|
2027
|
+
var loadedKeys = q.loaded[l];
|
|
2028
|
+
if (loadedKeys.length) {
|
|
2029
|
+
loadedKeys.forEach(function (n) {
|
|
2030
|
+
if (loaded[l][n] === undefined) loaded[l][n] = true;
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
q.done = true;
|
|
2035
|
+
if (q.errors.length) {
|
|
2036
|
+
q.callback(q.errors);
|
|
2037
|
+
} else {
|
|
2038
|
+
q.callback();
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
this.emit('loaded', loaded);
|
|
2043
|
+
this.queue = this.queue.filter(function (q) {
|
|
2044
|
+
return !q.done;
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
}, {
|
|
2048
|
+
key: "read",
|
|
2049
|
+
value: function read(lng, ns, fcName) {
|
|
2050
|
+
var _this3 = this;
|
|
2051
|
+
var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
2052
|
+
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
|
|
2053
|
+
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
2054
|
+
if (!lng.length) return callback(null, {});
|
|
2055
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
2056
|
+
this.waitingReads.push({
|
|
2057
|
+
lng: lng,
|
|
2058
|
+
ns: ns,
|
|
2059
|
+
fcName: fcName,
|
|
2060
|
+
tried: tried,
|
|
2061
|
+
wait: wait,
|
|
2062
|
+
callback: callback
|
|
2063
|
+
});
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
this.readingCalls++;
|
|
2067
|
+
var resolver = function resolver(err, data) {
|
|
2068
|
+
_this3.readingCalls--;
|
|
2069
|
+
if (_this3.waitingReads.length > 0) {
|
|
2070
|
+
var next = _this3.waitingReads.shift();
|
|
2071
|
+
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
2072
|
+
}
|
|
2073
|
+
if (err && data && tried < _this3.maxRetries) {
|
|
2074
|
+
setTimeout(function () {
|
|
2075
|
+
_this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
2076
|
+
}, wait);
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
callback(err, data);
|
|
2080
|
+
};
|
|
2081
|
+
var fc = this.backend[fcName].bind(this.backend);
|
|
2082
|
+
if (fc.length === 2) {
|
|
2083
|
+
try {
|
|
2084
|
+
var r = fc(lng, ns);
|
|
2085
|
+
if (r && typeof r.then === 'function') {
|
|
2086
|
+
r.then(function (data) {
|
|
2087
|
+
return resolver(null, data);
|
|
2088
|
+
})["catch"](resolver);
|
|
2089
|
+
} else {
|
|
2090
|
+
resolver(null, r);
|
|
2091
|
+
}
|
|
2092
|
+
} catch (err) {
|
|
2093
|
+
resolver(err);
|
|
2094
|
+
}
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
return fc(lng, ns, resolver);
|
|
2098
|
+
}
|
|
2099
|
+
}, {
|
|
2100
|
+
key: "prepareLoading",
|
|
2101
|
+
value: function prepareLoading(languages, namespaces) {
|
|
2102
|
+
var _this4 = this;
|
|
2103
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2104
|
+
var callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
2105
|
+
if (!this.backend) {
|
|
2106
|
+
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
|
2107
|
+
return callback && callback();
|
|
2108
|
+
}
|
|
2109
|
+
if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
|
|
2110
|
+
if (typeof namespaces === 'string') namespaces = [namespaces];
|
|
2111
|
+
var toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
2112
|
+
if (!toLoad.toLoad.length) {
|
|
2113
|
+
if (!toLoad.pending.length) callback();
|
|
2114
|
+
return null;
|
|
2115
|
+
}
|
|
2116
|
+
toLoad.toLoad.forEach(function (name) {
|
|
2117
|
+
_this4.loadOne(name);
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
}, {
|
|
2121
|
+
key: "load",
|
|
2122
|
+
value: function load(languages, namespaces, callback) {
|
|
2123
|
+
this.prepareLoading(languages, namespaces, {}, callback);
|
|
2124
|
+
}
|
|
2125
|
+
}, {
|
|
2126
|
+
key: "reload",
|
|
2127
|
+
value: function reload(languages, namespaces, callback) {
|
|
2128
|
+
this.prepareLoading(languages, namespaces, {
|
|
2129
|
+
reload: true
|
|
2130
|
+
}, callback);
|
|
2131
|
+
}
|
|
2132
|
+
}, {
|
|
2133
|
+
key: "loadOne",
|
|
2134
|
+
value: function loadOne(name) {
|
|
2135
|
+
var _this5 = this;
|
|
2136
|
+
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2137
|
+
var s = name.split('|');
|
|
2138
|
+
var lng = s[0];
|
|
2139
|
+
var ns = s[1];
|
|
2140
|
+
this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
|
|
2141
|
+
if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
|
|
2142
|
+
if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
|
|
2143
|
+
_this5.loaded(name, err, data);
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
}, {
|
|
2147
|
+
key: "saveMissing",
|
|
2148
|
+
value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
|
2149
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
2150
|
+
var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};
|
|
2151
|
+
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
|
|
2152
|
+
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!!!');
|
|
2153
|
+
return;
|
|
2154
|
+
}
|
|
2155
|
+
if (key === undefined || key === null || key === '') return;
|
|
2156
|
+
if (this.backend && this.backend.create) {
|
|
2157
|
+
var opts = _objectSpread$1(_objectSpread$1({}, options), {}, {
|
|
2158
|
+
isUpdate: isUpdate
|
|
2159
|
+
});
|
|
2160
|
+
var fc = this.backend.create.bind(this.backend);
|
|
2161
|
+
if (fc.length < 6) {
|
|
2162
|
+
try {
|
|
2163
|
+
var r;
|
|
2164
|
+
if (fc.length === 5) {
|
|
2165
|
+
r = fc(languages, namespace, key, fallbackValue, opts);
|
|
2166
|
+
} else {
|
|
2167
|
+
r = fc(languages, namespace, key, fallbackValue);
|
|
2168
|
+
}
|
|
2169
|
+
if (r && typeof r.then === 'function') {
|
|
2170
|
+
r.then(function (data) {
|
|
2171
|
+
return clb(null, data);
|
|
2172
|
+
})["catch"](clb);
|
|
2173
|
+
} else {
|
|
2174
|
+
clb(null, r);
|
|
2175
|
+
}
|
|
2176
|
+
} catch (err) {
|
|
2177
|
+
clb(err);
|
|
2178
|
+
}
|
|
2179
|
+
} else {
|
|
2180
|
+
fc(languages, namespace, key, fallbackValue, clb, opts);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
if (!languages || !languages[0]) return;
|
|
2184
|
+
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
|
2185
|
+
}
|
|
2186
|
+
}]);
|
|
2187
|
+
return Connector;
|
|
2188
|
+
}(EventEmitter);
|
|
2189
|
+
|
|
2190
|
+
function get() {
|
|
2191
|
+
return {
|
|
2192
|
+
debug: false,
|
|
2193
|
+
initImmediate: true,
|
|
2194
|
+
ns: ['translation'],
|
|
2195
|
+
defaultNS: ['translation'],
|
|
2196
|
+
fallbackLng: ['dev'],
|
|
2197
|
+
fallbackNS: false,
|
|
2198
|
+
supportedLngs: false,
|
|
2199
|
+
nonExplicitSupportedLngs: false,
|
|
2200
|
+
load: 'all',
|
|
2201
|
+
preload: false,
|
|
2202
|
+
simplifyPluralSuffix: true,
|
|
2203
|
+
keySeparator: '.',
|
|
2204
|
+
nsSeparator: ':',
|
|
2205
|
+
pluralSeparator: '_',
|
|
2206
|
+
contextSeparator: '_',
|
|
2207
|
+
partialBundledLanguages: false,
|
|
2208
|
+
saveMissing: false,
|
|
2209
|
+
updateMissing: false,
|
|
2210
|
+
saveMissingTo: 'fallback',
|
|
2211
|
+
saveMissingPlurals: true,
|
|
2212
|
+
missingKeyHandler: false,
|
|
2213
|
+
missingInterpolationHandler: false,
|
|
2214
|
+
postProcess: false,
|
|
2215
|
+
postProcessPassResolved: false,
|
|
2216
|
+
returnNull: true,
|
|
2217
|
+
returnEmptyString: true,
|
|
2218
|
+
returnObjects: false,
|
|
2219
|
+
joinArrays: false,
|
|
2220
|
+
returnedObjectHandler: false,
|
|
2221
|
+
parseMissingKeyHandler: false,
|
|
2222
|
+
appendNamespaceToMissingKey: false,
|
|
2223
|
+
appendNamespaceToCIMode: false,
|
|
2224
|
+
overloadTranslationOptionHandler: function handle(args) {
|
|
2225
|
+
var ret = {};
|
|
2226
|
+
if (_typeof$1(args[1]) === 'object') ret = args[1];
|
|
2227
|
+
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
|
2228
|
+
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
|
2229
|
+
if (_typeof$1(args[2]) === 'object' || _typeof$1(args[3]) === 'object') {
|
|
2230
|
+
var options = args[3] || args[2];
|
|
2231
|
+
Object.keys(options).forEach(function (key) {
|
|
2232
|
+
ret[key] = options[key];
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
return ret;
|
|
2236
|
+
},
|
|
2237
|
+
interpolation: {
|
|
2238
|
+
escapeValue: true,
|
|
2239
|
+
format: function format(value, _format, lng, options) {
|
|
2240
|
+
return value;
|
|
2241
|
+
},
|
|
2242
|
+
prefix: '{{',
|
|
2243
|
+
suffix: '}}',
|
|
2244
|
+
formatSeparator: ',',
|
|
2245
|
+
unescapePrefix: '-',
|
|
2246
|
+
nestingPrefix: '$t(',
|
|
2247
|
+
nestingSuffix: ')',
|
|
2248
|
+
nestingOptionsSeparator: ',',
|
|
2249
|
+
maxReplaces: 1000,
|
|
2250
|
+
skipOnVariables: true
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
}
|
|
2254
|
+
function transformOptions(options) {
|
|
2255
|
+
if (typeof options.ns === 'string') options.ns = [options.ns];
|
|
2256
|
+
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
|
2257
|
+
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
|
|
2258
|
+
if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
|
|
2259
|
+
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
2260
|
+
}
|
|
2261
|
+
return options;
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
function ownKeys$7(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; }
|
|
2265
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2266
|
+
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); }; }
|
|
2267
|
+
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; } }
|
|
2268
|
+
function noop() {}
|
|
2269
|
+
function bindMemberFunctions(inst) {
|
|
2270
|
+
var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
2271
|
+
mems.forEach(function (mem) {
|
|
2272
|
+
if (typeof inst[mem] === 'function') {
|
|
2273
|
+
inst[mem] = inst[mem].bind(inst);
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
var I18n = function (_EventEmitter) {
|
|
2278
|
+
_inherits(I18n, _EventEmitter);
|
|
2279
|
+
var _super = _createSuper(I18n);
|
|
2280
|
+
function I18n() {
|
|
2281
|
+
var _this;
|
|
2282
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2283
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2284
|
+
_classCallCheck$1(this, I18n);
|
|
2285
|
+
_this = _super.call(this);
|
|
2286
|
+
if (isIE10) {
|
|
2287
|
+
EventEmitter.call(_assertThisInitialized(_this));
|
|
2288
|
+
}
|
|
2289
|
+
_this.options = transformOptions(options);
|
|
2290
|
+
_this.services = {};
|
|
2291
|
+
_this.logger = baseLogger;
|
|
2292
|
+
_this.modules = {
|
|
2293
|
+
external: []
|
|
2294
|
+
};
|
|
2295
|
+
bindMemberFunctions(_assertThisInitialized(_this));
|
|
2296
|
+
if (callback && !_this.isInitialized && !options.isClone) {
|
|
2297
|
+
if (!_this.options.initImmediate) {
|
|
2298
|
+
_this.init(options, callback);
|
|
2299
|
+
return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
|
|
2300
|
+
}
|
|
2301
|
+
setTimeout(function () {
|
|
2302
|
+
_this.init(options, callback);
|
|
2303
|
+
}, 0);
|
|
2304
|
+
}
|
|
2305
|
+
return _this;
|
|
2306
|
+
}
|
|
2307
|
+
_createClass$1(I18n, [{
|
|
2308
|
+
key: "init",
|
|
2309
|
+
value: function init() {
|
|
2310
|
+
var _this2 = this;
|
|
2311
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2312
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2313
|
+
if (typeof options === 'function') {
|
|
2314
|
+
callback = options;
|
|
2315
|
+
options = {};
|
|
2316
|
+
}
|
|
2317
|
+
if (!options.defaultNS && options.defaultNS !== false && options.ns) {
|
|
2318
|
+
if (typeof options.ns === 'string') {
|
|
2319
|
+
options.defaultNS = options.ns;
|
|
2320
|
+
} else if (options.ns.indexOf('translation') < 0) {
|
|
2321
|
+
options.defaultNS = options.ns[0];
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
var defOpts = get();
|
|
2325
|
+
this.options = _objectSpread$7(_objectSpread$7(_objectSpread$7({}, defOpts), this.options), transformOptions(options));
|
|
2326
|
+
if (this.options.compatibilityAPI !== 'v1') {
|
|
2327
|
+
this.options.interpolation = _objectSpread$7(_objectSpread$7({}, defOpts.interpolation), this.options.interpolation);
|
|
2328
|
+
}
|
|
2329
|
+
if (options.keySeparator !== undefined) {
|
|
2330
|
+
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
2331
|
+
}
|
|
2332
|
+
if (options.nsSeparator !== undefined) {
|
|
2333
|
+
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
2334
|
+
}
|
|
2335
|
+
function createClassOnDemand(ClassOrObject) {
|
|
2336
|
+
if (!ClassOrObject) return null;
|
|
2337
|
+
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
2338
|
+
return ClassOrObject;
|
|
2339
|
+
}
|
|
2340
|
+
if (!this.options.isClone) {
|
|
2341
|
+
if (this.modules.logger) {
|
|
2342
|
+
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
2343
|
+
} else {
|
|
2344
|
+
baseLogger.init(null, this.options);
|
|
2345
|
+
}
|
|
2346
|
+
var formatter;
|
|
2347
|
+
if (this.modules.formatter) {
|
|
2348
|
+
formatter = this.modules.formatter;
|
|
2349
|
+
} else if (typeof Intl !== 'undefined') {
|
|
2350
|
+
formatter = Formatter;
|
|
2351
|
+
}
|
|
2352
|
+
var lu = new LanguageUtil(this.options);
|
|
2353
|
+
this.store = new ResourceStore(this.options.resources, this.options);
|
|
2354
|
+
var s = this.services;
|
|
2355
|
+
s.logger = baseLogger;
|
|
2356
|
+
s.resourceStore = this.store;
|
|
2357
|
+
s.languageUtils = lu;
|
|
2358
|
+
s.pluralResolver = new PluralResolver(lu, {
|
|
2359
|
+
prepend: this.options.pluralSeparator,
|
|
2360
|
+
compatibilityJSON: this.options.compatibilityJSON,
|
|
2361
|
+
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
2362
|
+
});
|
|
2363
|
+
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
2364
|
+
s.formatter = createClassOnDemand(formatter);
|
|
2365
|
+
s.formatter.init(s, this.options);
|
|
2366
|
+
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
2367
|
+
}
|
|
2368
|
+
s.interpolator = new Interpolator(this.options);
|
|
2369
|
+
s.utils = {
|
|
2370
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
2371
|
+
};
|
|
2372
|
+
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
2373
|
+
s.backendConnector.on('*', function (event) {
|
|
2374
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2375
|
+
args[_key - 1] = arguments[_key];
|
|
2376
|
+
}
|
|
2377
|
+
_this2.emit.apply(_this2, [event].concat(args));
|
|
2378
|
+
});
|
|
2379
|
+
if (this.modules.languageDetector) {
|
|
2380
|
+
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
2381
|
+
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
|
2382
|
+
}
|
|
2383
|
+
if (this.modules.i18nFormat) {
|
|
2384
|
+
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
2385
|
+
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
|
2386
|
+
}
|
|
2387
|
+
this.translator = new Translator(this.services, this.options);
|
|
2388
|
+
this.translator.on('*', function (event) {
|
|
2389
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2390
|
+
args[_key2 - 1] = arguments[_key2];
|
|
2391
|
+
}
|
|
2392
|
+
_this2.emit.apply(_this2, [event].concat(args));
|
|
2393
|
+
});
|
|
2394
|
+
this.modules.external.forEach(function (m) {
|
|
2395
|
+
if (m.init) m.init(_this2);
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
this.format = this.options.interpolation.format;
|
|
2399
|
+
if (!callback) callback = noop;
|
|
2400
|
+
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
2401
|
+
var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2402
|
+
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
2403
|
+
}
|
|
2404
|
+
if (!this.services.languageDetector && !this.options.lng) {
|
|
2405
|
+
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
|
2406
|
+
}
|
|
2407
|
+
var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
|
2408
|
+
storeApi.forEach(function (fcName) {
|
|
2409
|
+
_this2[fcName] = function () {
|
|
2410
|
+
var _this2$store;
|
|
2411
|
+
return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
|
|
2412
|
+
};
|
|
2413
|
+
});
|
|
2414
|
+
var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
|
|
2415
|
+
storeApiChained.forEach(function (fcName) {
|
|
2416
|
+
_this2[fcName] = function () {
|
|
2417
|
+
var _this2$store2;
|
|
2418
|
+
(_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
|
|
2419
|
+
return _this2;
|
|
2420
|
+
};
|
|
2421
|
+
});
|
|
2422
|
+
var deferred = defer();
|
|
2423
|
+
var load = function load() {
|
|
2424
|
+
var finish = function finish(err, t) {
|
|
2425
|
+
if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
|
|
2426
|
+
_this2.isInitialized = true;
|
|
2427
|
+
if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
|
|
2428
|
+
_this2.emit('initialized', _this2.options);
|
|
2429
|
+
deferred.resolve(t);
|
|
2430
|
+
callback(err, t);
|
|
2431
|
+
};
|
|
2432
|
+
if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
|
|
2433
|
+
_this2.changeLanguage(_this2.options.lng, finish);
|
|
2434
|
+
};
|
|
2435
|
+
if (this.options.resources || !this.options.initImmediate) {
|
|
2436
|
+
load();
|
|
2437
|
+
} else {
|
|
2438
|
+
setTimeout(load, 0);
|
|
2439
|
+
}
|
|
2440
|
+
return deferred;
|
|
2441
|
+
}
|
|
2442
|
+
}, {
|
|
2443
|
+
key: "loadResources",
|
|
2444
|
+
value: function loadResources(language) {
|
|
2445
|
+
var _this3 = this;
|
|
2446
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2447
|
+
var usedCallback = callback;
|
|
2448
|
+
var usedLng = typeof language === 'string' ? language : this.language;
|
|
2449
|
+
if (typeof language === 'function') usedCallback = language;
|
|
2450
|
+
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
2451
|
+
if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
|
|
2452
|
+
var toLoad = [];
|
|
2453
|
+
var append = function append(lng) {
|
|
2454
|
+
if (!lng) return;
|
|
2455
|
+
var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
|
|
2456
|
+
lngs.forEach(function (l) {
|
|
2457
|
+
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
|
2458
|
+
});
|
|
2459
|
+
};
|
|
2460
|
+
if (!usedLng) {
|
|
2461
|
+
var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2462
|
+
fallbacks.forEach(function (l) {
|
|
2463
|
+
return append(l);
|
|
2464
|
+
});
|
|
2465
|
+
} else {
|
|
2466
|
+
append(usedLng);
|
|
2467
|
+
}
|
|
2468
|
+
if (this.options.preload) {
|
|
2469
|
+
this.options.preload.forEach(function (l) {
|
|
2470
|
+
return append(l);
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
|
|
2474
|
+
if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
|
|
2475
|
+
usedCallback(e);
|
|
2476
|
+
});
|
|
2477
|
+
} else {
|
|
2478
|
+
usedCallback(null);
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
}, {
|
|
2482
|
+
key: "reloadResources",
|
|
2483
|
+
value: function reloadResources(lngs, ns, callback) {
|
|
2484
|
+
var deferred = defer();
|
|
2485
|
+
if (!lngs) lngs = this.languages;
|
|
2486
|
+
if (!ns) ns = this.options.ns;
|
|
2487
|
+
if (!callback) callback = noop;
|
|
2488
|
+
this.services.backendConnector.reload(lngs, ns, function (err) {
|
|
2489
|
+
deferred.resolve();
|
|
2490
|
+
callback(err);
|
|
2491
|
+
});
|
|
2492
|
+
return deferred;
|
|
2493
|
+
}
|
|
2494
|
+
}, {
|
|
2495
|
+
key: "use",
|
|
2496
|
+
value: function use(module) {
|
|
2497
|
+
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
|
|
2498
|
+
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
|
|
2499
|
+
if (module.type === 'backend') {
|
|
2500
|
+
this.modules.backend = module;
|
|
2501
|
+
}
|
|
2502
|
+
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
|
2503
|
+
this.modules.logger = module;
|
|
2504
|
+
}
|
|
2505
|
+
if (module.type === 'languageDetector') {
|
|
2506
|
+
this.modules.languageDetector = module;
|
|
2507
|
+
}
|
|
2508
|
+
if (module.type === 'i18nFormat') {
|
|
2509
|
+
this.modules.i18nFormat = module;
|
|
2510
|
+
}
|
|
2511
|
+
if (module.type === 'postProcessor') {
|
|
2512
|
+
postProcessor.addPostProcessor(module);
|
|
2513
|
+
}
|
|
2514
|
+
if (module.type === 'formatter') {
|
|
2515
|
+
this.modules.formatter = module;
|
|
2516
|
+
}
|
|
2517
|
+
if (module.type === '3rdParty') {
|
|
2518
|
+
this.modules.external.push(module);
|
|
2519
|
+
}
|
|
2520
|
+
return this;
|
|
2521
|
+
}
|
|
2522
|
+
}, {
|
|
2523
|
+
key: "setResolvedLanguage",
|
|
2524
|
+
value: function setResolvedLanguage(l) {
|
|
2525
|
+
if (!l || !this.languages) return;
|
|
2526
|
+
if (['cimode', 'dev'].indexOf(l) > -1) return;
|
|
2527
|
+
for (var li = 0; li < this.languages.length; li++) {
|
|
2528
|
+
var lngInLngs = this.languages[li];
|
|
2529
|
+
if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
|
|
2530
|
+
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
2531
|
+
this.resolvedLanguage = lngInLngs;
|
|
2532
|
+
break;
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}, {
|
|
2537
|
+
key: "changeLanguage",
|
|
2538
|
+
value: function changeLanguage(lng, callback) {
|
|
2539
|
+
var _this4 = this;
|
|
2540
|
+
this.isLanguageChangingTo = lng;
|
|
2541
|
+
var deferred = defer();
|
|
2542
|
+
this.emit('languageChanging', lng);
|
|
2543
|
+
var setLngProps = function setLngProps(l) {
|
|
2544
|
+
_this4.language = l;
|
|
2545
|
+
_this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
|
|
2546
|
+
_this4.resolvedLanguage = undefined;
|
|
2547
|
+
_this4.setResolvedLanguage(l);
|
|
2548
|
+
};
|
|
2549
|
+
var done = function done(err, l) {
|
|
2550
|
+
if (l) {
|
|
2551
|
+
setLngProps(l);
|
|
2552
|
+
_this4.translator.changeLanguage(l);
|
|
2553
|
+
_this4.isLanguageChangingTo = undefined;
|
|
2554
|
+
_this4.emit('languageChanged', l);
|
|
2555
|
+
_this4.logger.log('languageChanged', l);
|
|
2556
|
+
} else {
|
|
2557
|
+
_this4.isLanguageChangingTo = undefined;
|
|
2558
|
+
}
|
|
2559
|
+
deferred.resolve(function () {
|
|
2560
|
+
return _this4.t.apply(_this4, arguments);
|
|
2561
|
+
});
|
|
2562
|
+
if (callback) callback(err, function () {
|
|
2563
|
+
return _this4.t.apply(_this4, arguments);
|
|
2564
|
+
});
|
|
2565
|
+
};
|
|
2566
|
+
var setLng = function setLng(lngs) {
|
|
2567
|
+
if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
|
|
2568
|
+
var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
|
|
2569
|
+
if (l) {
|
|
2570
|
+
if (!_this4.language) {
|
|
2571
|
+
setLngProps(l);
|
|
2572
|
+
}
|
|
2573
|
+
if (!_this4.translator.language) _this4.translator.changeLanguage(l);
|
|
2574
|
+
if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);
|
|
2575
|
+
}
|
|
2576
|
+
_this4.loadResources(l, function (err) {
|
|
2577
|
+
done(err, l);
|
|
2578
|
+
});
|
|
2579
|
+
};
|
|
2580
|
+
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
|
2581
|
+
setLng(this.services.languageDetector.detect());
|
|
2582
|
+
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
|
2583
|
+
if (this.services.languageDetector.detect.length === 0) {
|
|
2584
|
+
this.services.languageDetector.detect().then(setLng);
|
|
2585
|
+
} else {
|
|
2586
|
+
this.services.languageDetector.detect(setLng);
|
|
2587
|
+
}
|
|
2588
|
+
} else {
|
|
2589
|
+
setLng(lng);
|
|
2590
|
+
}
|
|
2591
|
+
return deferred;
|
|
2592
|
+
}
|
|
2593
|
+
}, {
|
|
2594
|
+
key: "getFixedT",
|
|
2595
|
+
value: function getFixedT(lng, ns, keyPrefix) {
|
|
2596
|
+
var _this5 = this;
|
|
2597
|
+
var fixedT = function fixedT(key, opts) {
|
|
2598
|
+
var options;
|
|
2599
|
+
if (_typeof$1(opts) !== 'object') {
|
|
2600
|
+
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
2601
|
+
rest[_key3 - 2] = arguments[_key3];
|
|
2602
|
+
}
|
|
2603
|
+
options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
2604
|
+
} else {
|
|
2605
|
+
options = _objectSpread$7({}, opts);
|
|
2606
|
+
}
|
|
2607
|
+
options.lng = options.lng || fixedT.lng;
|
|
2608
|
+
options.lngs = options.lngs || fixedT.lngs;
|
|
2609
|
+
options.ns = options.ns || fixedT.ns;
|
|
2610
|
+
options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
2611
|
+
var keySeparator = _this5.options.keySeparator || '.';
|
|
2612
|
+
var resultKey;
|
|
2613
|
+
if (options.keyPrefix && Array.isArray(key)) {
|
|
2614
|
+
resultKey = key.map(function (k) {
|
|
2615
|
+
return "".concat(options.keyPrefix).concat(keySeparator).concat(k);
|
|
2616
|
+
});
|
|
2617
|
+
} else {
|
|
2618
|
+
resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
|
|
2619
|
+
}
|
|
2620
|
+
return _this5.t(resultKey, options);
|
|
2621
|
+
};
|
|
2622
|
+
if (typeof lng === 'string') {
|
|
2623
|
+
fixedT.lng = lng;
|
|
2624
|
+
} else {
|
|
2625
|
+
fixedT.lngs = lng;
|
|
2626
|
+
}
|
|
2627
|
+
fixedT.ns = ns;
|
|
2628
|
+
fixedT.keyPrefix = keyPrefix;
|
|
2629
|
+
return fixedT;
|
|
2630
|
+
}
|
|
2631
|
+
}, {
|
|
2632
|
+
key: "t",
|
|
2633
|
+
value: function t() {
|
|
2634
|
+
var _this$translator;
|
|
2635
|
+
return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
|
|
2636
|
+
}
|
|
2637
|
+
}, {
|
|
2638
|
+
key: "exists",
|
|
2639
|
+
value: function exists() {
|
|
2640
|
+
var _this$translator2;
|
|
2641
|
+
return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
|
|
2642
|
+
}
|
|
2643
|
+
}, {
|
|
2644
|
+
key: "setDefaultNamespace",
|
|
2645
|
+
value: function setDefaultNamespace(ns) {
|
|
2646
|
+
this.options.defaultNS = ns;
|
|
2647
|
+
}
|
|
2648
|
+
}, {
|
|
2649
|
+
key: "hasLoadedNamespace",
|
|
2650
|
+
value: function hasLoadedNamespace(ns) {
|
|
2651
|
+
var _this6 = this;
|
|
2652
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2653
|
+
if (!this.isInitialized) {
|
|
2654
|
+
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
|
|
2655
|
+
return false;
|
|
2656
|
+
}
|
|
2657
|
+
if (!this.languages || !this.languages.length) {
|
|
2658
|
+
this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
|
|
2659
|
+
return false;
|
|
2660
|
+
}
|
|
2661
|
+
var lng = options.lng || this.resolvedLanguage || this.languages[0];
|
|
2662
|
+
var fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
2663
|
+
var lastLng = this.languages[this.languages.length - 1];
|
|
2664
|
+
if (lng.toLowerCase() === 'cimode') return true;
|
|
2665
|
+
var loadNotPending = function loadNotPending(l, n) {
|
|
2666
|
+
var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
|
|
2667
|
+
return loadState === -1 || loadState === 2;
|
|
2668
|
+
};
|
|
2669
|
+
if (options.precheck) {
|
|
2670
|
+
var preResult = options.precheck(this, loadNotPending);
|
|
2671
|
+
if (preResult !== undefined) return preResult;
|
|
2672
|
+
}
|
|
2673
|
+
if (this.hasResourceBundle(lng, ns)) return true;
|
|
2674
|
+
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
|
2675
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
2676
|
+
return false;
|
|
2677
|
+
}
|
|
2678
|
+
}, {
|
|
2679
|
+
key: "loadNamespaces",
|
|
2680
|
+
value: function loadNamespaces(ns, callback) {
|
|
2681
|
+
var _this7 = this;
|
|
2682
|
+
var deferred = defer();
|
|
2683
|
+
if (!this.options.ns) {
|
|
2684
|
+
if (callback) callback();
|
|
2685
|
+
return Promise.resolve();
|
|
2686
|
+
}
|
|
2687
|
+
if (typeof ns === 'string') ns = [ns];
|
|
2688
|
+
ns.forEach(function (n) {
|
|
2689
|
+
if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
|
|
2690
|
+
});
|
|
2691
|
+
this.loadResources(function (err) {
|
|
2692
|
+
deferred.resolve();
|
|
2693
|
+
if (callback) callback(err);
|
|
2694
|
+
});
|
|
2695
|
+
return deferred;
|
|
2696
|
+
}
|
|
2697
|
+
}, {
|
|
2698
|
+
key: "loadLanguages",
|
|
2699
|
+
value: function loadLanguages(lngs, callback) {
|
|
2700
|
+
var deferred = defer();
|
|
2701
|
+
if (typeof lngs === 'string') lngs = [lngs];
|
|
2702
|
+
var preloaded = this.options.preload || [];
|
|
2703
|
+
var newLngs = lngs.filter(function (lng) {
|
|
2704
|
+
return preloaded.indexOf(lng) < 0;
|
|
2705
|
+
});
|
|
2706
|
+
if (!newLngs.length) {
|
|
2707
|
+
if (callback) callback();
|
|
2708
|
+
return Promise.resolve();
|
|
2709
|
+
}
|
|
2710
|
+
this.options.preload = preloaded.concat(newLngs);
|
|
2711
|
+
this.loadResources(function (err) {
|
|
2712
|
+
deferred.resolve();
|
|
2713
|
+
if (callback) callback(err);
|
|
2714
|
+
});
|
|
2715
|
+
return deferred;
|
|
2716
|
+
}
|
|
2717
|
+
}, {
|
|
2718
|
+
key: "dir",
|
|
2719
|
+
value: function dir(lng) {
|
|
2720
|
+
if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
|
|
2721
|
+
if (!lng) return 'rtl';
|
|
2722
|
+
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'];
|
|
2723
|
+
var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
|
|
2724
|
+
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2725
|
+
}
|
|
2726
|
+
}, {
|
|
2727
|
+
key: "cloneInstance",
|
|
2728
|
+
value: function cloneInstance() {
|
|
2729
|
+
var _this8 = this;
|
|
2730
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2731
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2732
|
+
var mergedOptions = _objectSpread$7(_objectSpread$7(_objectSpread$7({}, this.options), options), {
|
|
2733
|
+
isClone: true
|
|
2734
|
+
});
|
|
2735
|
+
var clone = new I18n(mergedOptions);
|
|
2736
|
+
if (options.debug !== undefined || options.prefix !== undefined) {
|
|
2737
|
+
clone.logger = clone.logger.clone(options);
|
|
2738
|
+
}
|
|
2739
|
+
var membersToCopy = ['store', 'services', 'language'];
|
|
2740
|
+
membersToCopy.forEach(function (m) {
|
|
2741
|
+
clone[m] = _this8[m];
|
|
2742
|
+
});
|
|
2743
|
+
clone.services = _objectSpread$7({}, this.services);
|
|
2744
|
+
clone.services.utils = {
|
|
2745
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2746
|
+
};
|
|
2747
|
+
clone.translator = new Translator(clone.services, clone.options);
|
|
2748
|
+
clone.translator.on('*', function (event) {
|
|
2749
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
2750
|
+
args[_key4 - 1] = arguments[_key4];
|
|
2751
|
+
}
|
|
2752
|
+
clone.emit.apply(clone, [event].concat(args));
|
|
2753
|
+
});
|
|
2754
|
+
clone.init(mergedOptions, callback);
|
|
2755
|
+
clone.translator.options = clone.options;
|
|
2756
|
+
clone.translator.backendConnector.services.utils = {
|
|
2757
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2758
|
+
};
|
|
2759
|
+
return clone;
|
|
2760
|
+
}
|
|
2761
|
+
}, {
|
|
2762
|
+
key: "toJSON",
|
|
2763
|
+
value: function toJSON() {
|
|
2764
|
+
return {
|
|
2765
|
+
options: this.options,
|
|
2766
|
+
store: this.store,
|
|
2767
|
+
language: this.language,
|
|
2768
|
+
languages: this.languages,
|
|
2769
|
+
resolvedLanguage: this.resolvedLanguage
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
}]);
|
|
2773
|
+
return I18n;
|
|
2774
|
+
}(EventEmitter);
|
|
2775
|
+
_defineProperty$1(I18n, "createInstance", function () {
|
|
2776
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2777
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2778
|
+
return new I18n(options, callback);
|
|
2779
|
+
});
|
|
2780
|
+
var instance = I18n.createInstance();
|
|
2781
|
+
instance.createInstance = I18n.createInstance;
|
|
2782
|
+
|
|
2783
|
+
instance.createInstance;
|
|
2784
|
+
instance.dir;
|
|
2785
|
+
instance.init;
|
|
2786
|
+
instance.loadResources;
|
|
2787
|
+
instance.reloadResources;
|
|
2788
|
+
instance.use;
|
|
2789
|
+
instance.changeLanguage;
|
|
2790
|
+
instance.getFixedT;
|
|
2791
|
+
instance.t;
|
|
2792
|
+
instance.exists;
|
|
2793
|
+
instance.setDefaultNamespace;
|
|
2794
|
+
instance.hasLoadedNamespace;
|
|
2795
|
+
instance.loadNamespaces;
|
|
2796
|
+
instance.loadLanguages;
|
|
2797
|
+
|
|
2798
|
+
function _typeof(obj) {
|
|
2799
|
+
"@babel/helpers - typeof";
|
|
2800
|
+
|
|
2801
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
2802
|
+
return typeof obj;
|
|
2803
|
+
} : function (obj) {
|
|
2804
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
2805
|
+
}, _typeof(obj);
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
function _toPrimitive(input, hint) {
|
|
2809
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
2810
|
+
var prim = input[Symbol.toPrimitive];
|
|
2811
|
+
if (prim !== undefined) {
|
|
2812
|
+
var res = prim.call(input, hint || "default");
|
|
2813
|
+
if (_typeof(res) !== "object") return res;
|
|
2814
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2815
|
+
}
|
|
2816
|
+
return (hint === "string" ? String : Number)(input);
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
function _toPropertyKey(arg) {
|
|
2820
|
+
var key = _toPrimitive(arg, "string");
|
|
2821
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
function _defineProperty(obj, key, value) {
|
|
2825
|
+
key = _toPropertyKey(key);
|
|
2826
|
+
if (key in obj) {
|
|
2827
|
+
Object.defineProperty(obj, key, {
|
|
2828
|
+
value: value,
|
|
2829
|
+
enumerable: true,
|
|
2830
|
+
configurable: true,
|
|
2831
|
+
writable: true
|
|
2832
|
+
});
|
|
2833
|
+
} else {
|
|
2834
|
+
obj[key] = value;
|
|
2835
|
+
}
|
|
2836
|
+
return obj;
|
|
2837
|
+
}
|
|
2838
|
+
|
|
150
2839
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
151
2840
|
|
|
2841
|
+
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
2842
|
+
var htmlEntities = {
|
|
2843
|
+
'&': '&',
|
|
2844
|
+
'&': '&',
|
|
2845
|
+
'<': '<',
|
|
2846
|
+
'<': '<',
|
|
2847
|
+
'>': '>',
|
|
2848
|
+
'>': '>',
|
|
2849
|
+
''': "'",
|
|
2850
|
+
''': "'",
|
|
2851
|
+
'"': '"',
|
|
2852
|
+
'"': '"',
|
|
2853
|
+
' ': ' ',
|
|
2854
|
+
' ': ' ',
|
|
2855
|
+
'©': '©',
|
|
2856
|
+
'©': '©',
|
|
2857
|
+
'®': '®',
|
|
2858
|
+
'®': '®',
|
|
2859
|
+
'…': '…',
|
|
2860
|
+
'…': '…',
|
|
2861
|
+
'/': '/',
|
|
2862
|
+
'/': '/'
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2865
|
+
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
|
|
2866
|
+
return htmlEntities[m];
|
|
2867
|
+
};
|
|
2868
|
+
|
|
2869
|
+
var unescape = function unescape(text) {
|
|
2870
|
+
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
2871
|
+
};
|
|
2872
|
+
|
|
2873
|
+
function ownKeys(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; }
|
|
2874
|
+
|
|
2875
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2876
|
+
var defaultOptions = {
|
|
2877
|
+
bindI18n: 'languageChanged',
|
|
2878
|
+
bindI18nStore: '',
|
|
2879
|
+
transEmptyNodeValue: '',
|
|
2880
|
+
transSupportBasicHtmlNodes: true,
|
|
2881
|
+
transWrapTextNodes: '',
|
|
2882
|
+
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
|
|
2883
|
+
useSuspense: true,
|
|
2884
|
+
unescape: unescape
|
|
2885
|
+
};
|
|
2886
|
+
function setDefaults() {
|
|
2887
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2888
|
+
defaultOptions = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
function _classCallCheck(instance, Constructor) {
|
|
2892
|
+
if (!(instance instanceof Constructor)) {
|
|
2893
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
function _defineProperties(target, props) {
|
|
2898
|
+
for (var i = 0; i < props.length; i++) {
|
|
2899
|
+
var descriptor = props[i];
|
|
2900
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2901
|
+
descriptor.configurable = true;
|
|
2902
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2903
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
2907
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
2908
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
2909
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
2910
|
+
writable: false
|
|
2911
|
+
});
|
|
2912
|
+
return Constructor;
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
var initReactI18next = {
|
|
2916
|
+
type: '3rdParty',
|
|
2917
|
+
init: function init(instance) {
|
|
2918
|
+
setDefaults(instance.options.react);
|
|
2919
|
+
}
|
|
2920
|
+
};
|
|
2921
|
+
|
|
2922
|
+
React.createContext();
|
|
2923
|
+
(function () {
|
|
2924
|
+
function ReportNamespaces() {
|
|
2925
|
+
_classCallCheck(this, ReportNamespaces);
|
|
2926
|
+
|
|
2927
|
+
this.usedNamespaces = {};
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
_createClass(ReportNamespaces, [{
|
|
2931
|
+
key: "addUsedNamespaces",
|
|
2932
|
+
value: function addUsedNamespaces(namespaces) {
|
|
2933
|
+
var _this = this;
|
|
2934
|
+
|
|
2935
|
+
namespaces.forEach(function (ns) {
|
|
2936
|
+
if (!_this.usedNamespaces[ns]) _this.usedNamespaces[ns] = true;
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
}, {
|
|
2940
|
+
key: "getUsedNamespaces",
|
|
2941
|
+
value: function getUsedNamespaces() {
|
|
2942
|
+
return Object.keys(this.usedNamespaces);
|
|
2943
|
+
}
|
|
2944
|
+
}]);
|
|
2945
|
+
|
|
2946
|
+
return ReportNamespaces;
|
|
2947
|
+
})();
|
|
2948
|
+
|
|
152
2949
|
/** Detect free variable `global` from Node.js. */
|
|
153
2950
|
|
|
154
2951
|
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
@@ -570,7 +3367,7 @@ const amisRender = (root, schema, data = {}, env = {}, options) => {
|
|
|
570
3367
|
* @Author: baozhoutao@steedos.com
|
|
571
3368
|
* @Date: 2022-07-04 11:24:28
|
|
572
3369
|
* @LastEditors: baozhoutao@steedos.com
|
|
573
|
-
* @LastEditTime: 2023-
|
|
3370
|
+
* @LastEditTime: 2023-06-12 11:51:15
|
|
574
3371
|
* @Description:
|
|
575
3372
|
*/
|
|
576
3373
|
|
|
@@ -600,7 +3397,6 @@ async function fetchAPI(api, options = { credentials: 'include' }) {
|
|
|
600
3397
|
|
|
601
3398
|
options.headers = Object.assign({}, headers, options.headers);
|
|
602
3399
|
options.credentials = 'include';
|
|
603
|
-
|
|
604
3400
|
const res = await fetch(`${getRootUrl()}${api}`, options);
|
|
605
3401
|
|
|
606
3402
|
if(res.status === 401){
|
|
@@ -695,7 +3491,7 @@ function getRootUrl(defaultRootUrl){
|
|
|
695
3491
|
if(rootUrl){
|
|
696
3492
|
return rootUrl
|
|
697
3493
|
}
|
|
698
|
-
return defaultRootUrl;
|
|
3494
|
+
return defaultRootUrl || '';
|
|
699
3495
|
}
|
|
700
3496
|
|
|
701
3497
|
function setRootUrl(rootUrl){
|
|
@@ -1770,6 +4566,350 @@ const parseSingleExpression$1 = function (func, formData, dataPath, global, user
|
|
|
1770
4566
|
}
|
|
1771
4567
|
};
|
|
1772
4568
|
|
|
4569
|
+
var frontend_field_group_generalization$1 = "Generalization";
|
|
4570
|
+
var frontend_download$1 = "Download";
|
|
4571
|
+
var frontend_form_save$1 = "Save";
|
|
4572
|
+
var frontend_form_save_and_new$1 = "Save and New";
|
|
4573
|
+
var frontend_form_cancel$1 = "Cancel";
|
|
4574
|
+
var frontend_form_new$1 = "New";
|
|
4575
|
+
var frontend_form_edit$1 = "Edit";
|
|
4576
|
+
var frontend_form_select$1 = "Select";
|
|
4577
|
+
var frontend_form_confirm$1 = "Confirm";
|
|
4578
|
+
var frontend_form_delete$1 = "Delete";
|
|
4579
|
+
var frontend_form_view$1 = "view";
|
|
4580
|
+
var frontend_delete_confirm_text$1 = "Are you sure you want to delete this item?";
|
|
4581
|
+
var frontend_delete_many_selected_required$1 = "Please select the item to be deleted";
|
|
4582
|
+
var frontend_delete_many_confirm_text$1 = "Are you sure you want to delete?";
|
|
4583
|
+
var frontend_display_type_is_table$1 = "Table";
|
|
4584
|
+
var frontend_display_type_is_split$1 = "Split View";
|
|
4585
|
+
var frontend_display_as$1 = "Displayed as";
|
|
4586
|
+
var frontend_record_sum$1 = "items";
|
|
4587
|
+
var frontend_button_reload_tooltip$1 = "Refresh";
|
|
4588
|
+
var frontend_button_search_tooltip$1 = "Search";
|
|
4589
|
+
var frontend_fields_filter_button_search$1 = "Search";
|
|
4590
|
+
var frontend_fields_filter_button_settings$1 = "Set search options";
|
|
4591
|
+
var frontend_button_listview_control_tooltip$1 = "List View Controls";
|
|
4592
|
+
var frontend_button_listview_control_label$1 = "LIST VIEW CONTROLS";
|
|
4593
|
+
var frontend_listview_control_columns$1 = "Show List";
|
|
4594
|
+
var frontend_listview_control_columns_mobile_group$1 = "Mobile side";
|
|
4595
|
+
var frontend_listview_control_clone_label$1 = "Clone";
|
|
4596
|
+
var frontend_listview_control_clone_title$1 = "Clone List View";
|
|
4597
|
+
var frontend_listview_control_clone_defaultData_label_start$1 = "Copy of";
|
|
4598
|
+
var frontend_listview_control_clone_defaultData_label_end$1 = "";
|
|
4599
|
+
var frontend_listview_control_delete_label$1 = "Delete";
|
|
4600
|
+
var frontend_listview_control_delete_confirm_text$1 = "If you delete this list view it will be permanently removed for all users with access. Are you sure you want to delete?";
|
|
4601
|
+
var frontend_listview_control_delete_message_success$1 = "Deletion successful";
|
|
4602
|
+
var frontend_listview_control_filters$1 = "Filter settings";
|
|
4603
|
+
var frontend_listview_control_filters_fields_extend$1 = "Conditional component 1";
|
|
4604
|
+
var frontend_listview_control_new_label$1 = "New";
|
|
4605
|
+
var frontend_listview_control_new_title$1 = "New List View";
|
|
4606
|
+
var frontend_listview_control_new_message_success$1 = "Success";
|
|
4607
|
+
var frontend_listview_control_new_message_failed$1 = "Failure";
|
|
4608
|
+
var frontend_listview_control_rename_label$1 = "Rename";
|
|
4609
|
+
var frontend_listview_control_rename_title$1 = "Rename List View";
|
|
4610
|
+
var frontend_listview_control_share$1 = "Sharing Settings";
|
|
4611
|
+
var frontend_listview_control_sort$1 = "Default sorting rule";
|
|
4612
|
+
var frontend_export_excel$1 = "Export Excel";
|
|
4613
|
+
var frontend_ercord_operation$1 = "Operation";
|
|
4614
|
+
var frontend_import_data$1 = "Import data";
|
|
4615
|
+
var frontend_import_data_object_name$1 = "Import object";
|
|
4616
|
+
var frontend_import_data_queue_import$1 = "Data import";
|
|
4617
|
+
var frontend_import_data_queue_import_description$1 = "Import description";
|
|
4618
|
+
var frontend_import_data_queue_import_encoding$1 = "Character code";
|
|
4619
|
+
var frontend_import_data_queue_import_template_url$1 = "Import template";
|
|
4620
|
+
var frontend_import_data_file$1 = "Excel file";
|
|
4621
|
+
var frontend_import_data_message_success$1 = "Importing has started...";
|
|
4622
|
+
var frontend_import_data_message_failed$1 = "Import failed";
|
|
4623
|
+
var frontend_record_detail_tab_detailed$1 = "Details";
|
|
4624
|
+
var frontend_record_detail_tab_related$1 = "Related";
|
|
4625
|
+
var frontend_all_apps$1 = "All apps";
|
|
4626
|
+
var frontend_all_projects$1 = "All projects";
|
|
4627
|
+
var frontend_application_launcher$1 = "Application launcher";
|
|
4628
|
+
var frontend_menu$1 = "Menu";
|
|
4629
|
+
var frontend_help$1 = "Help";
|
|
4630
|
+
var frontend_setup$1 = "Setup";
|
|
4631
|
+
var frontend_notifications$1 = "Notifications";
|
|
4632
|
+
var frontend_notifications_allread$1 = "Mark all as read";
|
|
4633
|
+
var frontend_notifications_allread_message$1 = "All marked as read";
|
|
4634
|
+
var frontend_profile$1 = "Profile";
|
|
4635
|
+
var frontend_about$1 = "About";
|
|
4636
|
+
var frontend_log_out$1 = "Log out";
|
|
4637
|
+
var frontend_listview_warning_start$1 = "The current ";
|
|
4638
|
+
var frontend_listview_warning_end$1 = " view does not exist!";
|
|
4639
|
+
var frontend_record_detail_related_list_warning$1 = "Missing parent object, parent record, or related list object property!";
|
|
4640
|
+
var frontend_record_detail_related_lists_warning$1 = "Missing parent object, or parent record property!";
|
|
4641
|
+
var frontend_record_detail_related_lists_info$1 = "No related child tables found";
|
|
4642
|
+
var frontend_calendar_listWeek$1 = "List";
|
|
4643
|
+
var frontend_message_no_permission_to_edit$1 = "You don't have permission to edit this record!";
|
|
4644
|
+
var frontend_message_modification_successful$1 = "Modification successful!";
|
|
4645
|
+
var frontend_message_modification_failed$1 = "Modification failed!";
|
|
4646
|
+
var en_us = {
|
|
4647
|
+
frontend_field_group_generalization: frontend_field_group_generalization$1,
|
|
4648
|
+
frontend_download: frontend_download$1,
|
|
4649
|
+
frontend_form_save: frontend_form_save$1,
|
|
4650
|
+
frontend_form_save_and_new: frontend_form_save_and_new$1,
|
|
4651
|
+
frontend_form_cancel: frontend_form_cancel$1,
|
|
4652
|
+
frontend_form_new: frontend_form_new$1,
|
|
4653
|
+
frontend_form_edit: frontend_form_edit$1,
|
|
4654
|
+
frontend_form_select: frontend_form_select$1,
|
|
4655
|
+
frontend_form_confirm: frontend_form_confirm$1,
|
|
4656
|
+
frontend_form_delete: frontend_form_delete$1,
|
|
4657
|
+
frontend_form_view: frontend_form_view$1,
|
|
4658
|
+
frontend_delete_confirm_text: frontend_delete_confirm_text$1,
|
|
4659
|
+
frontend_delete_many_selected_required: frontend_delete_many_selected_required$1,
|
|
4660
|
+
frontend_delete_many_confirm_text: frontend_delete_many_confirm_text$1,
|
|
4661
|
+
frontend_display_type_is_table: frontend_display_type_is_table$1,
|
|
4662
|
+
frontend_display_type_is_split: frontend_display_type_is_split$1,
|
|
4663
|
+
frontend_display_as: frontend_display_as$1,
|
|
4664
|
+
frontend_record_sum: frontend_record_sum$1,
|
|
4665
|
+
frontend_button_reload_tooltip: frontend_button_reload_tooltip$1,
|
|
4666
|
+
frontend_button_search_tooltip: frontend_button_search_tooltip$1,
|
|
4667
|
+
frontend_fields_filter_button_search: frontend_fields_filter_button_search$1,
|
|
4668
|
+
frontend_fields_filter_button_settings: frontend_fields_filter_button_settings$1,
|
|
4669
|
+
frontend_button_listview_control_tooltip: frontend_button_listview_control_tooltip$1,
|
|
4670
|
+
frontend_button_listview_control_label: frontend_button_listview_control_label$1,
|
|
4671
|
+
frontend_listview_control_columns: frontend_listview_control_columns$1,
|
|
4672
|
+
frontend_listview_control_columns_mobile_group: frontend_listview_control_columns_mobile_group$1,
|
|
4673
|
+
frontend_listview_control_clone_label: frontend_listview_control_clone_label$1,
|
|
4674
|
+
frontend_listview_control_clone_title: frontend_listview_control_clone_title$1,
|
|
4675
|
+
frontend_listview_control_clone_defaultData_label_start: frontend_listview_control_clone_defaultData_label_start$1,
|
|
4676
|
+
frontend_listview_control_clone_defaultData_label_end: frontend_listview_control_clone_defaultData_label_end$1,
|
|
4677
|
+
frontend_listview_control_delete_label: frontend_listview_control_delete_label$1,
|
|
4678
|
+
frontend_listview_control_delete_confirm_text: frontend_listview_control_delete_confirm_text$1,
|
|
4679
|
+
frontend_listview_control_delete_message_success: frontend_listview_control_delete_message_success$1,
|
|
4680
|
+
frontend_listview_control_filters: frontend_listview_control_filters$1,
|
|
4681
|
+
frontend_listview_control_filters_fields_extend: frontend_listview_control_filters_fields_extend$1,
|
|
4682
|
+
frontend_listview_control_new_label: frontend_listview_control_new_label$1,
|
|
4683
|
+
frontend_listview_control_new_title: frontend_listview_control_new_title$1,
|
|
4684
|
+
frontend_listview_control_new_message_success: frontend_listview_control_new_message_success$1,
|
|
4685
|
+
frontend_listview_control_new_message_failed: frontend_listview_control_new_message_failed$1,
|
|
4686
|
+
frontend_listview_control_rename_label: frontend_listview_control_rename_label$1,
|
|
4687
|
+
frontend_listview_control_rename_title: frontend_listview_control_rename_title$1,
|
|
4688
|
+
frontend_listview_control_share: frontend_listview_control_share$1,
|
|
4689
|
+
frontend_listview_control_sort: frontend_listview_control_sort$1,
|
|
4690
|
+
frontend_export_excel: frontend_export_excel$1,
|
|
4691
|
+
frontend_ercord_operation: frontend_ercord_operation$1,
|
|
4692
|
+
frontend_import_data: frontend_import_data$1,
|
|
4693
|
+
frontend_import_data_object_name: frontend_import_data_object_name$1,
|
|
4694
|
+
frontend_import_data_queue_import: frontend_import_data_queue_import$1,
|
|
4695
|
+
frontend_import_data_queue_import_description: frontend_import_data_queue_import_description$1,
|
|
4696
|
+
frontend_import_data_queue_import_encoding: frontend_import_data_queue_import_encoding$1,
|
|
4697
|
+
frontend_import_data_queue_import_template_url: frontend_import_data_queue_import_template_url$1,
|
|
4698
|
+
frontend_import_data_file: frontend_import_data_file$1,
|
|
4699
|
+
frontend_import_data_message_success: frontend_import_data_message_success$1,
|
|
4700
|
+
frontend_import_data_message_failed: frontend_import_data_message_failed$1,
|
|
4701
|
+
frontend_record_detail_tab_detailed: frontend_record_detail_tab_detailed$1,
|
|
4702
|
+
frontend_record_detail_tab_related: frontend_record_detail_tab_related$1,
|
|
4703
|
+
frontend_all_apps: frontend_all_apps$1,
|
|
4704
|
+
frontend_all_projects: frontend_all_projects$1,
|
|
4705
|
+
frontend_application_launcher: frontend_application_launcher$1,
|
|
4706
|
+
frontend_menu: frontend_menu$1,
|
|
4707
|
+
frontend_help: frontend_help$1,
|
|
4708
|
+
frontend_setup: frontend_setup$1,
|
|
4709
|
+
frontend_notifications: frontend_notifications$1,
|
|
4710
|
+
frontend_notifications_allread: frontend_notifications_allread$1,
|
|
4711
|
+
frontend_notifications_allread_message: frontend_notifications_allread_message$1,
|
|
4712
|
+
frontend_profile: frontend_profile$1,
|
|
4713
|
+
frontend_about: frontend_about$1,
|
|
4714
|
+
frontend_log_out: frontend_log_out$1,
|
|
4715
|
+
frontend_listview_warning_start: frontend_listview_warning_start$1,
|
|
4716
|
+
frontend_listview_warning_end: frontend_listview_warning_end$1,
|
|
4717
|
+
frontend_record_detail_related_list_warning: frontend_record_detail_related_list_warning$1,
|
|
4718
|
+
frontend_record_detail_related_lists_warning: frontend_record_detail_related_lists_warning$1,
|
|
4719
|
+
frontend_record_detail_related_lists_info: frontend_record_detail_related_lists_info$1,
|
|
4720
|
+
frontend_calendar_listWeek: frontend_calendar_listWeek$1,
|
|
4721
|
+
frontend_message_no_permission_to_edit: frontend_message_no_permission_to_edit$1,
|
|
4722
|
+
frontend_message_modification_successful: frontend_message_modification_successful$1,
|
|
4723
|
+
frontend_message_modification_failed: frontend_message_modification_failed$1
|
|
4724
|
+
};
|
|
4725
|
+
|
|
4726
|
+
var frontend_field_group_generalization = "通用";
|
|
4727
|
+
var frontend_download = "下载";
|
|
4728
|
+
var frontend_form_save = "保存";
|
|
4729
|
+
var frontend_form_save_and_new = "保存并新建";
|
|
4730
|
+
var frontend_form_cancel = "取消";
|
|
4731
|
+
var frontend_form_new = "新建";
|
|
4732
|
+
var frontend_form_edit = "编辑";
|
|
4733
|
+
var frontend_form_select = "选择";
|
|
4734
|
+
var frontend_form_confirm = "确认";
|
|
4735
|
+
var frontend_form_delete = "删除";
|
|
4736
|
+
var frontend_form_view = "查看";
|
|
4737
|
+
var frontend_delete_confirm_text = "确定要删除此项目?";
|
|
4738
|
+
var frontend_delete_many_selected_required = "请选择要删除的项";
|
|
4739
|
+
var frontend_delete_many_confirm_text = "确定要删除吗?";
|
|
4740
|
+
var frontend_display_type_is_table = "表格";
|
|
4741
|
+
var frontend_display_type_is_split = "分栏视图";
|
|
4742
|
+
var frontend_display_as = "显示为";
|
|
4743
|
+
var frontend_record_sum = "个项目";
|
|
4744
|
+
var frontend_button_reload_tooltip = "刷新";
|
|
4745
|
+
var frontend_button_search_tooltip = "搜索";
|
|
4746
|
+
var frontend_fields_filter_button_search = "搜索";
|
|
4747
|
+
var frontend_fields_filter_button_settings = "设置搜索项";
|
|
4748
|
+
var frontend_button_listview_control_tooltip = "列表视图控制";
|
|
4749
|
+
var frontend_button_listview_control_label = "列表视图控制";
|
|
4750
|
+
var frontend_listview_control_columns = "显示的列";
|
|
4751
|
+
var frontend_listview_control_columns_mobile_group = "手机端";
|
|
4752
|
+
var frontend_listview_control_clone = "复制";
|
|
4753
|
+
var frontend_listview_control_clone_label = "复制";
|
|
4754
|
+
var frontend_listview_control_clone_title = "复制 列表视图";
|
|
4755
|
+
var frontend_listview_control_clone_defaultData_label_start = "";
|
|
4756
|
+
var frontend_listview_control_clone_defaultData_label_end = "的副本";
|
|
4757
|
+
var frontend_listview_control_delete_label = "删除";
|
|
4758
|
+
var frontend_listview_control_delete_confirm_text = "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?";
|
|
4759
|
+
var frontend_listview_control_delete_message_success = "删除成功";
|
|
4760
|
+
var frontend_listview_control_filters = "过滤设置";
|
|
4761
|
+
var frontend_listview_control_filters_fields_extend = "条件组件1";
|
|
4762
|
+
var frontend_listview_control_new_label = "新建";
|
|
4763
|
+
var frontend_listview_control_new_title = "新建 列表视图";
|
|
4764
|
+
var frontend_listview_control_new_message_success = "成功";
|
|
4765
|
+
var frontend_listview_control_new_message_failed = "失败";
|
|
4766
|
+
var frontend_listview_control_rename_label = "重命名";
|
|
4767
|
+
var frontend_listview_control_rename_title = "重命名 列表视图";
|
|
4768
|
+
var frontend_listview_control_share = "共享设置";
|
|
4769
|
+
var frontend_listview_control_sort = "默认排序规则";
|
|
4770
|
+
var frontend_export_excel = "导出";
|
|
4771
|
+
var frontend_ercord_operation = "操作";
|
|
4772
|
+
var frontend_import_data = "导入数据";
|
|
4773
|
+
var frontend_import_data_object_name = "导入对象";
|
|
4774
|
+
var frontend_import_data_queue_import = "数据导入";
|
|
4775
|
+
var frontend_import_data_queue_import_description = "导入描述";
|
|
4776
|
+
var frontend_import_data_queue_import_encoding = "字符代码";
|
|
4777
|
+
var frontend_import_data_queue_import_template_url = "导入模板";
|
|
4778
|
+
var frontend_import_data_file = "Excel文件";
|
|
4779
|
+
var frontend_import_data_message_success = "已开始导入...";
|
|
4780
|
+
var frontend_import_data_message_failed = "导入失败";
|
|
4781
|
+
var frontend_record_detail_tab_detailed = "详细";
|
|
4782
|
+
var frontend_record_detail_tab_related = "相关";
|
|
4783
|
+
var frontend_all_apps = "所有应用";
|
|
4784
|
+
var frontend_all_projects = "所有项目";
|
|
4785
|
+
var frontend_application_launcher = "应用程序启动器";
|
|
4786
|
+
var frontend_menu = "菜单";
|
|
4787
|
+
var frontend_help = "帮助";
|
|
4788
|
+
var frontend_setup = "设置";
|
|
4789
|
+
var frontend_notifications = "通知";
|
|
4790
|
+
var frontend_notifications_allread = "全部标记为已读";
|
|
4791
|
+
var frontend_notifications_allread_message = "已全部标记为已读";
|
|
4792
|
+
var frontend_profile = "个人资料";
|
|
4793
|
+
var frontend_about = "关于";
|
|
4794
|
+
var frontend_log_out = "注销";
|
|
4795
|
+
var frontend_listview_warning_start = "当前";
|
|
4796
|
+
var frontend_listview_warning_end = "视图不存在!";
|
|
4797
|
+
var frontend_record_detail_related_list_warning = "缺少父级对象、父级记录或相关列表对象属性!";
|
|
4798
|
+
var frontend_record_detail_related_lists_warning = "缺少父级对象或父级记录属性!";
|
|
4799
|
+
var frontend_record_detail_related_lists_info = "没有相关子表";
|
|
4800
|
+
var frontend_calendar_listWeek = "列表";
|
|
4801
|
+
var frontend_message_no_permission_to_edit = "您没有编辑该记录的权限!";
|
|
4802
|
+
var frontend_message_modification_successful = "修改成功!";
|
|
4803
|
+
var frontend_message_modification_failed = "修改失败!";
|
|
4804
|
+
var zh_cn = {
|
|
4805
|
+
frontend_field_group_generalization: frontend_field_group_generalization,
|
|
4806
|
+
frontend_download: frontend_download,
|
|
4807
|
+
frontend_form_save: frontend_form_save,
|
|
4808
|
+
frontend_form_save_and_new: frontend_form_save_and_new,
|
|
4809
|
+
frontend_form_cancel: frontend_form_cancel,
|
|
4810
|
+
frontend_form_new: frontend_form_new,
|
|
4811
|
+
frontend_form_edit: frontend_form_edit,
|
|
4812
|
+
frontend_form_select: frontend_form_select,
|
|
4813
|
+
frontend_form_confirm: frontend_form_confirm,
|
|
4814
|
+
frontend_form_delete: frontend_form_delete,
|
|
4815
|
+
frontend_form_view: frontend_form_view,
|
|
4816
|
+
frontend_delete_confirm_text: frontend_delete_confirm_text,
|
|
4817
|
+
frontend_delete_many_selected_required: frontend_delete_many_selected_required,
|
|
4818
|
+
frontend_delete_many_confirm_text: frontend_delete_many_confirm_text,
|
|
4819
|
+
frontend_display_type_is_table: frontend_display_type_is_table,
|
|
4820
|
+
frontend_display_type_is_split: frontend_display_type_is_split,
|
|
4821
|
+
frontend_display_as: frontend_display_as,
|
|
4822
|
+
frontend_record_sum: frontend_record_sum,
|
|
4823
|
+
frontend_button_reload_tooltip: frontend_button_reload_tooltip,
|
|
4824
|
+
frontend_button_search_tooltip: frontend_button_search_tooltip,
|
|
4825
|
+
frontend_fields_filter_button_search: frontend_fields_filter_button_search,
|
|
4826
|
+
frontend_fields_filter_button_settings: frontend_fields_filter_button_settings,
|
|
4827
|
+
frontend_button_listview_control_tooltip: frontend_button_listview_control_tooltip,
|
|
4828
|
+
frontend_button_listview_control_label: frontend_button_listview_control_label,
|
|
4829
|
+
frontend_listview_control_columns: frontend_listview_control_columns,
|
|
4830
|
+
frontend_listview_control_columns_mobile_group: frontend_listview_control_columns_mobile_group,
|
|
4831
|
+
frontend_listview_control_clone: frontend_listview_control_clone,
|
|
4832
|
+
frontend_listview_control_clone_label: frontend_listview_control_clone_label,
|
|
4833
|
+
frontend_listview_control_clone_title: frontend_listview_control_clone_title,
|
|
4834
|
+
frontend_listview_control_clone_defaultData_label_start: frontend_listview_control_clone_defaultData_label_start,
|
|
4835
|
+
frontend_listview_control_clone_defaultData_label_end: frontend_listview_control_clone_defaultData_label_end,
|
|
4836
|
+
frontend_listview_control_delete_label: frontend_listview_control_delete_label,
|
|
4837
|
+
frontend_listview_control_delete_confirm_text: frontend_listview_control_delete_confirm_text,
|
|
4838
|
+
frontend_listview_control_delete_message_success: frontend_listview_control_delete_message_success,
|
|
4839
|
+
frontend_listview_control_filters: frontend_listview_control_filters,
|
|
4840
|
+
frontend_listview_control_filters_fields_extend: frontend_listview_control_filters_fields_extend,
|
|
4841
|
+
frontend_listview_control_new_label: frontend_listview_control_new_label,
|
|
4842
|
+
frontend_listview_control_new_title: frontend_listview_control_new_title,
|
|
4843
|
+
frontend_listview_control_new_message_success: frontend_listview_control_new_message_success,
|
|
4844
|
+
frontend_listview_control_new_message_failed: frontend_listview_control_new_message_failed,
|
|
4845
|
+
frontend_listview_control_rename_label: frontend_listview_control_rename_label,
|
|
4846
|
+
frontend_listview_control_rename_title: frontend_listview_control_rename_title,
|
|
4847
|
+
frontend_listview_control_share: frontend_listview_control_share,
|
|
4848
|
+
frontend_listview_control_sort: frontend_listview_control_sort,
|
|
4849
|
+
frontend_export_excel: frontend_export_excel,
|
|
4850
|
+
frontend_ercord_operation: frontend_ercord_operation,
|
|
4851
|
+
frontend_import_data: frontend_import_data,
|
|
4852
|
+
frontend_import_data_object_name: frontend_import_data_object_name,
|
|
4853
|
+
frontend_import_data_queue_import: frontend_import_data_queue_import,
|
|
4854
|
+
frontend_import_data_queue_import_description: frontend_import_data_queue_import_description,
|
|
4855
|
+
frontend_import_data_queue_import_encoding: frontend_import_data_queue_import_encoding,
|
|
4856
|
+
frontend_import_data_queue_import_template_url: frontend_import_data_queue_import_template_url,
|
|
4857
|
+
frontend_import_data_file: frontend_import_data_file,
|
|
4858
|
+
frontend_import_data_message_success: frontend_import_data_message_success,
|
|
4859
|
+
frontend_import_data_message_failed: frontend_import_data_message_failed,
|
|
4860
|
+
frontend_record_detail_tab_detailed: frontend_record_detail_tab_detailed,
|
|
4861
|
+
frontend_record_detail_tab_related: frontend_record_detail_tab_related,
|
|
4862
|
+
frontend_all_apps: frontend_all_apps,
|
|
4863
|
+
frontend_all_projects: frontend_all_projects,
|
|
4864
|
+
frontend_application_launcher: frontend_application_launcher,
|
|
4865
|
+
frontend_menu: frontend_menu,
|
|
4866
|
+
frontend_help: frontend_help,
|
|
4867
|
+
frontend_setup: frontend_setup,
|
|
4868
|
+
frontend_notifications: frontend_notifications,
|
|
4869
|
+
frontend_notifications_allread: frontend_notifications_allread,
|
|
4870
|
+
frontend_notifications_allread_message: frontend_notifications_allread_message,
|
|
4871
|
+
frontend_profile: frontend_profile,
|
|
4872
|
+
frontend_about: frontend_about,
|
|
4873
|
+
frontend_log_out: frontend_log_out,
|
|
4874
|
+
frontend_listview_warning_start: frontend_listview_warning_start,
|
|
4875
|
+
frontend_listview_warning_end: frontend_listview_warning_end,
|
|
4876
|
+
frontend_record_detail_related_list_warning: frontend_record_detail_related_list_warning,
|
|
4877
|
+
frontend_record_detail_related_lists_warning: frontend_record_detail_related_lists_warning,
|
|
4878
|
+
frontend_record_detail_related_lists_info: frontend_record_detail_related_lists_info,
|
|
4879
|
+
frontend_calendar_listWeek: frontend_calendar_listWeek,
|
|
4880
|
+
frontend_message_no_permission_to_edit: frontend_message_no_permission_to_edit,
|
|
4881
|
+
frontend_message_modification_successful: frontend_message_modification_successful,
|
|
4882
|
+
frontend_message_modification_failed: frontend_message_modification_failed
|
|
4883
|
+
};
|
|
4884
|
+
|
|
4885
|
+
const resources = {
|
|
4886
|
+
"en-US": {
|
|
4887
|
+
translation: en_us
|
|
4888
|
+
},
|
|
4889
|
+
"zh-CN": {
|
|
4890
|
+
translation: zh_cn
|
|
4891
|
+
}
|
|
4892
|
+
};
|
|
4893
|
+
var locale = "zh-CN";
|
|
4894
|
+
if (typeof window != 'undefined') {
|
|
4895
|
+
if (window.Builder?.settings.locale == "en-us") {
|
|
4896
|
+
locale = "en-US";
|
|
4897
|
+
} else if (window.Builder?.settings.locale == "zh-cn") {
|
|
4898
|
+
locale = "zh-CN";
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
|
|
4902
|
+
|
|
4903
|
+
instance
|
|
4904
|
+
.use(initReactI18next)
|
|
4905
|
+
.init({
|
|
4906
|
+
resources,
|
|
4907
|
+
lng: locale,
|
|
4908
|
+
interpolation: {
|
|
4909
|
+
escapeValue: false
|
|
4910
|
+
}
|
|
4911
|
+
});
|
|
4912
|
+
|
|
1773
4913
|
/*
|
|
1774
4914
|
* @Author: baozhoutao@steedos.com
|
|
1775
4915
|
* @Date: 2022-11-01 15:51:00
|
|
@@ -1778,7 +4918,7 @@ const parseSingleExpression$1 = function (func, formData, dataPath, global, user
|
|
|
1778
4918
|
* @Description:
|
|
1779
4919
|
*/
|
|
1780
4920
|
|
|
1781
|
-
const getSchema$
|
|
4921
|
+
const getSchema$5 = async (uiSchema, ctx) => {
|
|
1782
4922
|
const schemaApiAdaptor = `
|
|
1783
4923
|
let formSchema = {
|
|
1784
4924
|
"type": "steedos-object-form",
|
|
@@ -1831,7 +4971,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1831
4971
|
"body": [
|
|
1832
4972
|
{
|
|
1833
4973
|
"type": "button",
|
|
1834
|
-
"label":
|
|
4974
|
+
"label": instance.t('frontend_form_new'),
|
|
1835
4975
|
"id": "u:standard_new",
|
|
1836
4976
|
"level": "default",
|
|
1837
4977
|
"onEvent": {
|
|
@@ -1857,7 +4997,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1857
4997
|
"isLookup": "${isLookup}",
|
|
1858
4998
|
"listName": "${listName}"
|
|
1859
4999
|
},
|
|
1860
|
-
"title": "
|
|
5000
|
+
"title":instance.t('frontend_form_new') + " ${uiSchema.label | raw}",
|
|
1861
5001
|
"body": [
|
|
1862
5002
|
{
|
|
1863
5003
|
"type": "service",
|
|
@@ -1890,11 +5030,11 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1890
5030
|
{
|
|
1891
5031
|
type: 'button',
|
|
1892
5032
|
actionType: 'cancel',
|
|
1893
|
-
label:
|
|
5033
|
+
label: instance.t('frontend_form_cancel')
|
|
1894
5034
|
},
|
|
1895
5035
|
{
|
|
1896
5036
|
type: 'button',
|
|
1897
|
-
label:
|
|
5037
|
+
label: instance.t('frontend_form_save_and_new'),
|
|
1898
5038
|
actionType: 'confirm',
|
|
1899
5039
|
close: false,
|
|
1900
5040
|
id: "confirmAndNew"
|
|
@@ -1902,7 +5042,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
|
|
|
1902
5042
|
{
|
|
1903
5043
|
type: 'button',
|
|
1904
5044
|
actionType: 'confirm',
|
|
1905
|
-
label:
|
|
5045
|
+
label: instance.t('frontend_form_save'),
|
|
1906
5046
|
primary: true
|
|
1907
5047
|
},
|
|
1908
5048
|
]
|
|
@@ -1952,8 +5092,8 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
|
|
|
1952
5092
|
* @Description:
|
|
1953
5093
|
*/
|
|
1954
5094
|
|
|
1955
|
-
const getSchema$
|
|
1956
|
-
const title = "
|
|
5095
|
+
const getSchema$4 = async (uiSchema, ctx) => {
|
|
5096
|
+
const title = instance.t('frontend_form_edit') + " " + uiSchema.label;
|
|
1957
5097
|
|
|
1958
5098
|
const defaultFormSchema = {
|
|
1959
5099
|
type: "steedos-object-form",
|
|
@@ -1983,7 +5123,7 @@ const getSchema$3 = async (uiSchema, ctx) => {
|
|
|
1983
5123
|
body: [
|
|
1984
5124
|
{
|
|
1985
5125
|
type: "button",
|
|
1986
|
-
label:
|
|
5126
|
+
label: instance.t('frontend_form_edit'),
|
|
1987
5127
|
id: "u:standard_edit",
|
|
1988
5128
|
onEvent: {
|
|
1989
5129
|
click: {
|
|
@@ -2020,15 +5160,15 @@ const getSchema$3 = async (uiSchema, ctx) => {
|
|
|
2020
5160
|
* @LastEditors: Please set LastEditors
|
|
2021
5161
|
* @LastEditTime: 2023-04-12 10:35:36
|
|
2022
5162
|
*/
|
|
2023
|
-
const getSchema$
|
|
5163
|
+
const getSchema$3 = (uiSchema)=>{
|
|
2024
5164
|
return {
|
|
2025
5165
|
"type": "service",
|
|
2026
5166
|
"className": "p-0",
|
|
2027
5167
|
"body": [
|
|
2028
5168
|
{
|
|
2029
5169
|
"type": "button",
|
|
2030
|
-
"label":
|
|
2031
|
-
"confirmText":
|
|
5170
|
+
"label": instance.t('frontend_form_delete'),
|
|
5171
|
+
"confirmText": instance.t('frontend_delete_many_confirm_text'),
|
|
2032
5172
|
"onEvent": {
|
|
2033
5173
|
"click": {
|
|
2034
5174
|
"actions": [
|
|
@@ -2089,13 +5229,13 @@ const getSchema$2 = (uiSchema)=>{
|
|
|
2089
5229
|
}
|
|
2090
5230
|
};
|
|
2091
5231
|
|
|
2092
|
-
const getSchema$
|
|
5232
|
+
const getSchema$2 = (uiSchema) => {
|
|
2093
5233
|
return {
|
|
2094
5234
|
type: "service",
|
|
2095
5235
|
body: [
|
|
2096
5236
|
{
|
|
2097
5237
|
type: "button",
|
|
2098
|
-
label:
|
|
5238
|
+
label: instance.t('frontend_import_data'),
|
|
2099
5239
|
id: "u:import_data",
|
|
2100
5240
|
onEvent: {
|
|
2101
5241
|
click: {
|
|
@@ -2108,7 +5248,7 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2108
5248
|
"object_name": "${objectName}"
|
|
2109
5249
|
},
|
|
2110
5250
|
type: "dialog",
|
|
2111
|
-
title:
|
|
5251
|
+
title: instance.t('frontend_import_data'),
|
|
2112
5252
|
body: [
|
|
2113
5253
|
{
|
|
2114
5254
|
type: "form",
|
|
@@ -2143,12 +5283,12 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2143
5283
|
body: [
|
|
2144
5284
|
{
|
|
2145
5285
|
type: "fieldSet",
|
|
2146
|
-
title:
|
|
5286
|
+
title: instance.t('frontend_field_group_generalization'),
|
|
2147
5287
|
collapsable: true,
|
|
2148
5288
|
body: [
|
|
2149
5289
|
{
|
|
2150
5290
|
name: "object_name",
|
|
2151
|
-
label:
|
|
5291
|
+
label: instance.t('frontend_import_data_object_name'),
|
|
2152
5292
|
required: false,
|
|
2153
5293
|
type: "select",
|
|
2154
5294
|
joinValues: false,
|
|
@@ -2184,7 +5324,7 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2184
5324
|
},
|
|
2185
5325
|
{
|
|
2186
5326
|
name: "queue_import",
|
|
2187
|
-
label:
|
|
5327
|
+
label: instance.t('frontend_import_data_queue_import'),
|
|
2188
5328
|
required: true,
|
|
2189
5329
|
type: "picker",
|
|
2190
5330
|
labelField: "description",
|
|
@@ -2230,7 +5370,7 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2230
5370
|
},
|
|
2231
5371
|
{
|
|
2232
5372
|
name: "description",
|
|
2233
|
-
label:
|
|
5373
|
+
label: instance.t('frontend_import_data_queue_import_description'),
|
|
2234
5374
|
type: "tpl",
|
|
2235
5375
|
tpl: '<a href="/app/undefined/undefined/view/${undefined}">${description}</a>',
|
|
2236
5376
|
className: "whitespace-nowrap",
|
|
@@ -2238,7 +5378,7 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2238
5378
|
},
|
|
2239
5379
|
{
|
|
2240
5380
|
name: "object_name",
|
|
2241
|
-
label:
|
|
5381
|
+
label: instance.t('frontend_import_data_object_name'),
|
|
2242
5382
|
type: "tpl",
|
|
2243
5383
|
tpl: '<a href="/app/undefined/${_display.object_name.objectName}/view/${_display.object_name.value}">${_display.object_name.label}</a>',
|
|
2244
5384
|
className: "whitespace-nowrap",
|
|
@@ -2246,7 +5386,7 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2246
5386
|
},
|
|
2247
5387
|
{
|
|
2248
5388
|
name: "encoding",
|
|
2249
|
-
label:
|
|
5389
|
+
label: instance.t('frontend_import_data_queue_import_encoding'),
|
|
2250
5390
|
type: "tpl",
|
|
2251
5391
|
tpl: "<div>${_display.encoding}</div>",
|
|
2252
5392
|
className: "whitespace-nowrap",
|
|
@@ -2254,12 +5394,12 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2254
5394
|
},
|
|
2255
5395
|
{
|
|
2256
5396
|
name: "template_url",
|
|
2257
|
-
label:
|
|
5397
|
+
label: instance.t('frontend_import_data_queue_import_template_url'),
|
|
2258
5398
|
type: "button-group",
|
|
2259
5399
|
buttons: [
|
|
2260
5400
|
{
|
|
2261
5401
|
type: "button",
|
|
2262
|
-
label:
|
|
5402
|
+
label: instance.t('frontend_download'),
|
|
2263
5403
|
visibleOn: "${template_url}",
|
|
2264
5404
|
level: "link",
|
|
2265
5405
|
actionType: "download",
|
|
@@ -2293,7 +5433,7 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2293
5433
|
},
|
|
2294
5434
|
{
|
|
2295
5435
|
name: "file",
|
|
2296
|
-
label:
|
|
5436
|
+
label: instance.t('frontend_import_data_file'),
|
|
2297
5437
|
required: true,
|
|
2298
5438
|
type: "input-file",
|
|
2299
5439
|
className: "m-1",
|
|
@@ -2349,8 +5489,8 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2349
5489
|
},
|
|
2350
5490
|
},
|
|
2351
5491
|
messages: {
|
|
2352
|
-
success:
|
|
2353
|
-
failed:
|
|
5492
|
+
success: instance.t('frontend_import_data_message_success'),
|
|
5493
|
+
failed: instance.t('frontend_import_data_message_failed'),
|
|
2354
5494
|
},
|
|
2355
5495
|
},
|
|
2356
5496
|
actionType: "ajax",
|
|
@@ -2389,14 +5529,15 @@ const getSchema$1 = (uiSchema) => {
|
|
|
2389
5529
|
* @LastEditTime: 2022-11-07 17:12:20
|
|
2390
5530
|
* @Description:
|
|
2391
5531
|
*/
|
|
2392
|
-
|
|
5532
|
+
|
|
5533
|
+
const getSchema$1 = (uiSchema)=>{
|
|
2393
5534
|
return {
|
|
2394
5535
|
"type": "service",
|
|
2395
5536
|
"className": "p-0",
|
|
2396
5537
|
"body": [
|
|
2397
5538
|
{
|
|
2398
5539
|
"type": "button",
|
|
2399
|
-
"label":
|
|
5540
|
+
"label": instance.t('frontend_form_view'),
|
|
2400
5541
|
"className": "border-none",
|
|
2401
5542
|
"onEvent": {
|
|
2402
5543
|
"click": {
|
|
@@ -2421,6 +5562,94 @@ const getSchema$5 = (uiSchema)=>{
|
|
|
2421
5562
|
}
|
|
2422
5563
|
};
|
|
2423
5564
|
|
|
5565
|
+
const getSchema$6 = async (uiSchema, ctx) => {
|
|
5566
|
+
const requestAdaptor = `
|
|
5567
|
+
// 获取列表视图的属性
|
|
5568
|
+
let uiSchema = api.body.uiSchema;
|
|
5569
|
+
let list_views = uiSchema.list_views;
|
|
5570
|
+
let list_views_name = api.body.listName;
|
|
5571
|
+
let col = list_views[list_views_name].columns;
|
|
5572
|
+
let sort_test = list_views[list_views_name].sort;
|
|
5573
|
+
|
|
5574
|
+
// 获取下载字段
|
|
5575
|
+
let select = [];
|
|
5576
|
+
_.each(col, (col) => {
|
|
5577
|
+
if (col.field == undefined)
|
|
5578
|
+
select.push(col);
|
|
5579
|
+
else select.push(col.field);
|
|
5580
|
+
});
|
|
5581
|
+
|
|
5582
|
+
// 获取排序字段
|
|
5583
|
+
|
|
5584
|
+
let sort = [];
|
|
5585
|
+
_.forEach(sort_test, (sortField) => {
|
|
5586
|
+
if (sortField.field_name == undefined)
|
|
5587
|
+
sort.push(sortField);
|
|
5588
|
+
else sort.push([sortField.field_name, sortField.order]);
|
|
5589
|
+
})
|
|
5590
|
+
|
|
5591
|
+
let orders = [];
|
|
5592
|
+
_.map(sort, (value) => {
|
|
5593
|
+
let order_tmp = [];
|
|
5594
|
+
if (value[1] == "desc")
|
|
5595
|
+
order_tmp = value[0] + ' desc';
|
|
5596
|
+
else
|
|
5597
|
+
order_tmp = value[0];
|
|
5598
|
+
orders.push(order_tmp);
|
|
5599
|
+
});
|
|
5600
|
+
let order = orders.join(',');
|
|
5601
|
+
|
|
5602
|
+
let filename = uiSchema.label + "-" + list_views[list_views_name].label;
|
|
5603
|
+
|
|
5604
|
+
url_tmp = api.url.split('?')[0];
|
|
5605
|
+
api.url = url_tmp + "?$select=" + select.toString() + "&filename=" + filename;
|
|
5606
|
+
|
|
5607
|
+
// 判断sort 和 filters
|
|
5608
|
+
if (sort.length > 0) {
|
|
5609
|
+
api.url += "&$orderby=" + order;
|
|
5610
|
+
}
|
|
5611
|
+
let filters = list_views[list_views_name].filters;
|
|
5612
|
+
if (filters && filters.length > 0) {
|
|
5613
|
+
api.url = api.url + "&filters=" + JSON.stringify(filters);
|
|
5614
|
+
}
|
|
5615
|
+
return api;
|
|
5616
|
+
`;
|
|
5617
|
+
return {
|
|
5618
|
+
"type": "service",
|
|
5619
|
+
"body": [{
|
|
5620
|
+
"type": "button",
|
|
5621
|
+
"label": instance.t('frontend_export_excel'),
|
|
5622
|
+
"id": "u:standard_export_excel",
|
|
5623
|
+
"level": "default",
|
|
5624
|
+
"onEvent": {
|
|
5625
|
+
"click": {
|
|
5626
|
+
"weight": 0,
|
|
5627
|
+
"actions": [
|
|
5628
|
+
{
|
|
5629
|
+
"args": {
|
|
5630
|
+
"api": {
|
|
5631
|
+
"url": "${context.rootUrl}/api/record/export/${objectName}",
|
|
5632
|
+
"method": "get",
|
|
5633
|
+
"messages": {},
|
|
5634
|
+
"requestAdaptor": requestAdaptor,
|
|
5635
|
+
"data": {
|
|
5636
|
+
"uiSchema": "${uiSchema}",
|
|
5637
|
+
"listName": "${listName}"
|
|
5638
|
+
},
|
|
5639
|
+
"headers": {
|
|
5640
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
5641
|
+
}
|
|
5642
|
+
}
|
|
5643
|
+
},
|
|
5644
|
+
"actionType": "download"
|
|
5645
|
+
}
|
|
5646
|
+
]
|
|
5647
|
+
}
|
|
5648
|
+
}
|
|
5649
|
+
}]
|
|
5650
|
+
}
|
|
5651
|
+
};
|
|
5652
|
+
|
|
2424
5653
|
/*
|
|
2425
5654
|
* @Author: baozhoutao@steedos.com
|
|
2426
5655
|
* @Date: 2022-11-01 15:53:07
|
|
@@ -2433,19 +5662,19 @@ const StandardButtons = {
|
|
|
2433
5662
|
getStandardNew: async (uiSchema, ctx)=>{
|
|
2434
5663
|
return {
|
|
2435
5664
|
type: 'amis_button',
|
|
2436
|
-
amis_schema: await getSchema$
|
|
5665
|
+
amis_schema: await getSchema$5(uiSchema)
|
|
2437
5666
|
}
|
|
2438
5667
|
},
|
|
2439
5668
|
getStandardEdit: async (uiSchema, ctx)=>{
|
|
2440
5669
|
return {
|
|
2441
5670
|
type: 'amis_button',
|
|
2442
|
-
amis_schema: await getSchema$
|
|
5671
|
+
amis_schema: await getSchema$4(uiSchema, ctx)
|
|
2443
5672
|
}
|
|
2444
5673
|
},
|
|
2445
5674
|
getStandardDelete: async (uiSchema, ctx)=>{
|
|
2446
5675
|
return {
|
|
2447
5676
|
type: 'amis_button',
|
|
2448
|
-
amis_schema: await getSchema$
|
|
5677
|
+
amis_schema: await getSchema$3(uiSchema)
|
|
2449
5678
|
}
|
|
2450
5679
|
},
|
|
2451
5680
|
getStandardDeleteMany: async (uiSchema, ctx)=>{
|
|
@@ -2467,7 +5696,7 @@ const StandardButtons = {
|
|
|
2467
5696
|
"items": [
|
|
2468
5697
|
{
|
|
2469
5698
|
"position": "top-right",
|
|
2470
|
-
"body":
|
|
5699
|
+
"body": instance.t('frontend_delete_many_selected_required')
|
|
2471
5700
|
}
|
|
2472
5701
|
]
|
|
2473
5702
|
}
|
|
@@ -2481,13 +5710,19 @@ const StandardButtons = {
|
|
|
2481
5710
|
getStandardImportData: async (uiSchema, ctx)=>{
|
|
2482
5711
|
return {
|
|
2483
5712
|
type: 'amis_button',
|
|
2484
|
-
amis_schema: await getSchema$
|
|
5713
|
+
amis_schema: await getSchema$2()
|
|
2485
5714
|
}
|
|
2486
5715
|
},
|
|
2487
5716
|
getStandardOpenView: async (uiSchema, ctx)=>{
|
|
2488
5717
|
return {
|
|
2489
5718
|
type: 'amis_button',
|
|
2490
|
-
amis_schema: await getSchema$
|
|
5719
|
+
amis_schema: await getSchema$1()
|
|
5720
|
+
}
|
|
5721
|
+
},
|
|
5722
|
+
getStandardExportExcel: async (uiSchema, ctx)=>{
|
|
5723
|
+
return {
|
|
5724
|
+
type: 'amis_button',
|
|
5725
|
+
amis_schema: await getSchema$6()
|
|
2491
5726
|
}
|
|
2492
5727
|
}
|
|
2493
5728
|
};
|
|
@@ -2749,6 +5984,16 @@ const getButton = async (objectName, buttonName, ctx)=>{
|
|
|
2749
5984
|
}
|
|
2750
5985
|
}
|
|
2751
5986
|
|
|
5987
|
+
if(button.name === 'standard_export_excel'){
|
|
5988
|
+
return {
|
|
5989
|
+
label: button.label,
|
|
5990
|
+
name: button.name,
|
|
5991
|
+
on: button.on,
|
|
5992
|
+
sort: button.sort,
|
|
5993
|
+
...await StandardButtons.getStandardExportExcel(uiSchema, ctx)
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
|
|
2752
5997
|
if(button.name === 'standard_open_view'){
|
|
2753
5998
|
return {
|
|
2754
5999
|
label: button.label,
|
|
@@ -3243,7 +6488,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3243
6488
|
if(_.isEmpty(defaultSearchableFields) && data.uiSchema){
|
|
3244
6489
|
defaultSearchableFields = _.map(
|
|
3245
6490
|
_.sortBy(_.filter(_.values(data.uiSchema.fields), (field) => {
|
|
3246
|
-
return field.
|
|
6491
|
+
return field.filterable;
|
|
3247
6492
|
}), "sort_no"),
|
|
3248
6493
|
"name"
|
|
3249
6494
|
);
|
|
@@ -3410,7 +6655,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3410
6655
|
{
|
|
3411
6656
|
"type": "button",
|
|
3412
6657
|
"id": btnSearchId,
|
|
3413
|
-
"label":
|
|
6658
|
+
"label": instance.t('frontend_fields_filter_button_search'),
|
|
3414
6659
|
"icon": "fa fa-search",
|
|
3415
6660
|
// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3416
6661
|
"onEvent": {
|
|
@@ -3426,7 +6671,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3426
6671
|
},
|
|
3427
6672
|
{
|
|
3428
6673
|
"type": "button",
|
|
3429
|
-
"label":
|
|
6674
|
+
"label": instance.t('frontend_form_cancel'),
|
|
3430
6675
|
"name": "btn_filter_form_cancel",
|
|
3431
6676
|
// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3432
6677
|
"onEvent": {
|
|
@@ -3442,7 +6687,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3442
6687
|
},
|
|
3443
6688
|
{
|
|
3444
6689
|
"type": "button",
|
|
3445
|
-
"label":
|
|
6690
|
+
"label": instance.t('frontend_fields_filter_button_settings'),
|
|
3446
6691
|
"onEvent": {
|
|
3447
6692
|
"click": {
|
|
3448
6693
|
"actions": [
|
|
@@ -3451,7 +6696,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3451
6696
|
"dialog": {
|
|
3452
6697
|
"type": "dialog",
|
|
3453
6698
|
"size": "md",
|
|
3454
|
-
"title":
|
|
6699
|
+
"title": instance.t('frontend_fields_filter_button_settings'),
|
|
3455
6700
|
"body": [
|
|
3456
6701
|
{
|
|
3457
6702
|
"type": "form",
|
|
@@ -3519,7 +6764,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3519
6764
|
"actions": [
|
|
3520
6765
|
{
|
|
3521
6766
|
"type": "button",
|
|
3522
|
-
"label":
|
|
6767
|
+
"label": instance.t('frontend_form_cancel'),
|
|
3523
6768
|
"onEvent": {
|
|
3524
6769
|
"click": {
|
|
3525
6770
|
"actions": [
|
|
@@ -3535,7 +6780,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3535
6780
|
},
|
|
3536
6781
|
{
|
|
3537
6782
|
"type": "button",
|
|
3538
|
-
"label":
|
|
6783
|
+
"label": instance.t('frontend_form_confirm'),
|
|
3539
6784
|
"onEvent": {
|
|
3540
6785
|
"click": {
|
|
3541
6786
|
"actions": [
|
|
@@ -4052,7 +7297,7 @@ const getExportExcelToolbarButtonSchema = ()=>{
|
|
|
4052
7297
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
4053
7298
|
"tooltipPlacement": "bottom",
|
|
4054
7299
|
"visibleOn": "${!isLookup && global.user.is_space_admin}",
|
|
4055
|
-
"tooltip":
|
|
7300
|
+
"tooltip": instance.t('frontend_export_excel'),
|
|
4056
7301
|
"onEvent": {
|
|
4057
7302
|
"click": {
|
|
4058
7303
|
"weight": 0,
|
|
@@ -4138,7 +7383,7 @@ function requestAdaptor$1(){
|
|
|
4138
7383
|
const getNewListviewButtonSchema = ()=>{
|
|
4139
7384
|
return {
|
|
4140
7385
|
"type": "button",
|
|
4141
|
-
"label":
|
|
7386
|
+
"label": instance.t('frontend_listview_control_new_label'),
|
|
4142
7387
|
"onEvent": {
|
|
4143
7388
|
"click": {
|
|
4144
7389
|
"weight": 0,
|
|
@@ -4146,7 +7391,7 @@ const getNewListviewButtonSchema = ()=>{
|
|
|
4146
7391
|
{
|
|
4147
7392
|
"dialog": {
|
|
4148
7393
|
"type": "dialog",
|
|
4149
|
-
"title":
|
|
7394
|
+
"title": instance.t('frontend_listview_control_new_title'),
|
|
4150
7395
|
"data": {
|
|
4151
7396
|
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4152
7397
|
"all": "${uiSchema.list_views.all}",
|
|
@@ -4188,8 +7433,8 @@ const getNewListviewButtonSchema = ()=>{
|
|
|
4188
7433
|
}
|
|
4189
7434
|
},
|
|
4190
7435
|
"messages": {
|
|
4191
|
-
"success":
|
|
4192
|
-
"failed":
|
|
7436
|
+
"success": instance.t('frontend_listview_control_new_message_success'),
|
|
7437
|
+
"failed": instance.t('frontend_listview_control_new_message_failed')
|
|
4193
7438
|
},
|
|
4194
7439
|
}
|
|
4195
7440
|
],
|
|
@@ -4288,7 +7533,7 @@ function fieldsExtend$4(){
|
|
|
4288
7533
|
const getCopyListviewButtonSchema = ()=>{
|
|
4289
7534
|
return {
|
|
4290
7535
|
"type": "button",
|
|
4291
|
-
"label":
|
|
7536
|
+
"label": instance.t('frontend_listview_control_clone_label'),
|
|
4292
7537
|
"onEvent": {
|
|
4293
7538
|
"click": {
|
|
4294
7539
|
"weight": 0,
|
|
@@ -4296,7 +7541,7 @@ const getCopyListviewButtonSchema = ()=>{
|
|
|
4296
7541
|
{
|
|
4297
7542
|
"dialog": {
|
|
4298
7543
|
"type": "dialog",
|
|
4299
|
-
"title":
|
|
7544
|
+
"title": instance.t('frontend_listview_control_clone_title'),
|
|
4300
7545
|
"data": {
|
|
4301
7546
|
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4302
7547
|
"listName": "${listName}",
|
|
@@ -4316,7 +7561,7 @@ const getCopyListviewButtonSchema = ()=>{
|
|
|
4316
7561
|
"defaultData": {
|
|
4317
7562
|
"&": "${list_view}",
|
|
4318
7563
|
"name":"",
|
|
4319
|
-
"label": "${list_view.label}
|
|
7564
|
+
"label": instance.t('frontend_listview_control_clone_defaultData_label_start') + " ${list_view.label} " + instance.t('frontend_listview_control_clone_defaultData_label_end'),
|
|
4320
7565
|
"shared":false
|
|
4321
7566
|
},
|
|
4322
7567
|
"fieldsExtend": fieldsExtend$3(),
|
|
@@ -4433,7 +7678,7 @@ function fieldsExtend$3(){
|
|
|
4433
7678
|
const getRenameListviewButtonSchema = ()=>{
|
|
4434
7679
|
return {
|
|
4435
7680
|
"type": "button",
|
|
4436
|
-
"label":
|
|
7681
|
+
"label": instance.t('frontend_listview_control_rename_label'),
|
|
4437
7682
|
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4438
7683
|
"onEvent": {
|
|
4439
7684
|
"click": {
|
|
@@ -4442,7 +7687,7 @@ const getRenameListviewButtonSchema = ()=>{
|
|
|
4442
7687
|
{
|
|
4443
7688
|
"dialog": {
|
|
4444
7689
|
"type": "dialog",
|
|
4445
|
-
"title":
|
|
7690
|
+
"title": instance.t('frontend_listview_control_rename_title'),
|
|
4446
7691
|
"data": {
|
|
4447
7692
|
"targetObjectName": "${objectName}",
|
|
4448
7693
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
@@ -4492,7 +7737,7 @@ const getRenameListviewButtonSchema = ()=>{
|
|
|
4492
7737
|
const getSetListviewShareButtonSchema = ()=>{
|
|
4493
7738
|
return {
|
|
4494
7739
|
"type": "button",
|
|
4495
|
-
"label":
|
|
7740
|
+
"label": instance.t('frontend_listview_control_share'),
|
|
4496
7741
|
"disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
|
|
4497
7742
|
"onEvent": {
|
|
4498
7743
|
"click": {
|
|
@@ -4501,7 +7746,7 @@ const getSetListviewShareButtonSchema = ()=>{
|
|
|
4501
7746
|
{
|
|
4502
7747
|
"dialog": {
|
|
4503
7748
|
"type": "dialog",
|
|
4504
|
-
"title":
|
|
7749
|
+
"title": instance.t('frontend_listview_control_share'),
|
|
4505
7750
|
"data": {
|
|
4506
7751
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4507
7752
|
"context": "${context}"
|
|
@@ -4536,7 +7781,7 @@ const getSetListviewShareButtonSchema = ()=>{
|
|
|
4536
7781
|
const getSetListviewFiltersButtonSchema = ()=>{
|
|
4537
7782
|
return {
|
|
4538
7783
|
"type": "button",
|
|
4539
|
-
"label":
|
|
7784
|
+
"label": instance.t('frontend_listview_control_filters'),
|
|
4540
7785
|
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4541
7786
|
"onEvent": {
|
|
4542
7787
|
"click": {
|
|
@@ -4545,7 +7790,7 @@ const getSetListviewFiltersButtonSchema = ()=>{
|
|
|
4545
7790
|
{
|
|
4546
7791
|
"dialog": {
|
|
4547
7792
|
"type": "dialog",
|
|
4548
|
-
"title":
|
|
7793
|
+
"title": instance.t('frontend_listview_control_filters'),
|
|
4549
7794
|
"data": {
|
|
4550
7795
|
"targetObjectName": "${objectName}",
|
|
4551
7796
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
@@ -4666,7 +7911,7 @@ function fieldsExtend$2(){
|
|
|
4666
7911
|
"visible_on": "true",
|
|
4667
7912
|
"amis": {
|
|
4668
7913
|
"type": "condition-builder",
|
|
4669
|
-
"label":
|
|
7914
|
+
"label": instance.t('frontend_listview_control_filters_fields_extend'),
|
|
4670
7915
|
"source": {
|
|
4671
7916
|
"method": "get",
|
|
4672
7917
|
"url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
|
|
@@ -4683,7 +7928,7 @@ function fieldsExtend$2(){
|
|
|
4683
7928
|
const getSetListviewColumnsButtonSchema = ()=>{
|
|
4684
7929
|
return {
|
|
4685
7930
|
"type": "button",
|
|
4686
|
-
"label":
|
|
7931
|
+
"label": instance.t('frontend_listview_control_columns'),
|
|
4687
7932
|
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4688
7933
|
"onEvent": {
|
|
4689
7934
|
"click": {
|
|
@@ -4693,7 +7938,7 @@ const getSetListviewColumnsButtonSchema = ()=>{
|
|
|
4693
7938
|
"args": {},
|
|
4694
7939
|
"dialog": {
|
|
4695
7940
|
"type": "dialog",
|
|
4696
|
-
"title":
|
|
7941
|
+
"title": instance.t('frontend_listview_control_columns'),
|
|
4697
7942
|
"data": {
|
|
4698
7943
|
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4699
7944
|
"targetObjectName": "${objectName}",
|
|
@@ -4763,7 +8008,7 @@ function fieldsExtend$1(){
|
|
|
4763
8008
|
}
|
|
4764
8009
|
},
|
|
4765
8010
|
"mobile_columns": {
|
|
4766
|
-
"group":
|
|
8011
|
+
"group": instance.t('frontend_listview_control_columns_mobile_group'),
|
|
4767
8012
|
"amis": {
|
|
4768
8013
|
"type": "transfer",
|
|
4769
8014
|
"sortable": true,
|
|
@@ -4838,7 +8083,7 @@ function apiRequestAdaptor$1(){
|
|
|
4838
8083
|
const getSetListviewSortButtonSchema = ()=>{
|
|
4839
8084
|
return {
|
|
4840
8085
|
"type": "button",
|
|
4841
|
-
"label":
|
|
8086
|
+
"label": instance.t('frontend_listview_control_sort'),
|
|
4842
8087
|
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4843
8088
|
"onEvent": {
|
|
4844
8089
|
"click": {
|
|
@@ -4847,7 +8092,7 @@ const getSetListviewSortButtonSchema = ()=>{
|
|
|
4847
8092
|
{
|
|
4848
8093
|
"dialog": {
|
|
4849
8094
|
"type": "dialog",
|
|
4850
|
-
"title":
|
|
8095
|
+
"title": instance.t('frontend_listview_control_sort'),
|
|
4851
8096
|
"data": {
|
|
4852
8097
|
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4853
8098
|
"targetObjectName": "${objectName}",
|
|
@@ -4963,9 +8208,9 @@ function apiRequestAdaptor(){
|
|
|
4963
8208
|
const getDeleteListviewButtonSchema = ()=>{
|
|
4964
8209
|
return {
|
|
4965
8210
|
"type": "button",
|
|
4966
|
-
"label":
|
|
8211
|
+
"label": instance.t('frontend_listview_control_delete_label'),
|
|
4967
8212
|
"disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
|
|
4968
|
-
"confirmText":
|
|
8213
|
+
"confirmText": instance.t('frontend_listview_control_delete_confirm_text'),
|
|
4969
8214
|
"onEvent": {
|
|
4970
8215
|
"click": {
|
|
4971
8216
|
"actions": [
|
|
@@ -4984,7 +8229,7 @@ const getDeleteListviewButtonSchema = ()=>{
|
|
|
4984
8229
|
"recordId": "${uiSchema.list_views[listName]._id}"
|
|
4985
8230
|
},
|
|
4986
8231
|
"messages": {
|
|
4987
|
-
"success":
|
|
8232
|
+
"success": instance.t('frontend_listview_control_delete_message_success')
|
|
4988
8233
|
},
|
|
4989
8234
|
"requestAdaptor": requestAdaptor(),
|
|
4990
8235
|
"adaptor": adaptor(),
|
|
@@ -5031,13 +8276,13 @@ const getSettingListviewToolbarButtonSchema = ()=>{
|
|
|
5031
8276
|
"type": "dropdown-button",
|
|
5032
8277
|
"trigger": "click",
|
|
5033
8278
|
"icon": "fa fa-cog",
|
|
5034
|
-
"tooltip":
|
|
8279
|
+
"tooltip": instance.t('frontend_button_listview_control_tooltip'),
|
|
5035
8280
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5036
8281
|
"align": "right",
|
|
5037
8282
|
"visibleOn": "${!isLookup}",
|
|
5038
8283
|
"buttons": [
|
|
5039
8284
|
{
|
|
5040
|
-
"label":
|
|
8285
|
+
"label": instance.t('frontend_button_listview_control_label'),
|
|
5041
8286
|
"children": [
|
|
5042
8287
|
getNewListviewButtonSchema(),
|
|
5043
8288
|
getCopyListviewButtonSchema(),
|
|
@@ -5058,30 +8303,30 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
5058
8303
|
let buttons = [
|
|
5059
8304
|
{
|
|
5060
8305
|
"type": "button",
|
|
5061
|
-
"label":
|
|
8306
|
+
"label": instance.t('frontend_display_type_is_table'),
|
|
5062
8307
|
"onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
|
|
5063
8308
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
5064
8309
|
"rightIconClassName": "m-l-sm"
|
|
5065
8310
|
},
|
|
5066
8311
|
{
|
|
5067
8312
|
"type": "button",
|
|
5068
|
-
"label":
|
|
8313
|
+
"label": instance.t('frontend_display_type_is_split'),
|
|
5069
8314
|
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
5070
8315
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
5071
8316
|
"rightIconClassName": "m-l-sm"
|
|
5072
8317
|
}
|
|
5073
8318
|
];
|
|
5074
|
-
const displayAsLabel = displayAs === 'split'?
|
|
8319
|
+
const displayAsLabel = displayAs === 'split'? instance.t('frontend_display_type_is_split') : instance.t('frontend_display_type_is_table');
|
|
5075
8320
|
return {
|
|
5076
8321
|
"type": "dropdown-button",
|
|
5077
8322
|
"icon": "fa fa-table-columns",
|
|
5078
|
-
"tooltip":
|
|
8323
|
+
"tooltip": `${instance.t('frontend_display_as')} ${displayAsLabel}`,
|
|
5079
8324
|
"btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5080
8325
|
"align": "right",
|
|
5081
8326
|
"visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
|
|
5082
8327
|
"buttons": [
|
|
5083
8328
|
{
|
|
5084
|
-
"label":
|
|
8329
|
+
"label": instance.t('frontend_display_as'),
|
|
5085
8330
|
"children": buttons
|
|
5086
8331
|
}
|
|
5087
8332
|
]
|
|
@@ -5149,13 +8394,13 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5149
8394
|
...(headerToolbarItems || []),
|
|
5150
8395
|
hiddenCount ? {} :{
|
|
5151
8396
|
"type": "tpl",
|
|
5152
|
-
"tpl": "${count}
|
|
8397
|
+
"tpl": "${count} " + instance.t('frontend_record_sum')
|
|
5153
8398
|
},
|
|
5154
8399
|
{
|
|
5155
8400
|
// "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
|
|
5156
8401
|
"type": "button",
|
|
5157
8402
|
"align": "right",
|
|
5158
|
-
"tooltip":
|
|
8403
|
+
"tooltip": instance.t('frontend_button_reload_tooltip'),
|
|
5159
8404
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5160
8405
|
"label": "",
|
|
5161
8406
|
"icon": "fa fa-sync",
|
|
@@ -5175,7 +8420,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5175
8420
|
"label": "",
|
|
5176
8421
|
"icon": "fa fa-search",
|
|
5177
8422
|
"type": "button",
|
|
5178
|
-
"tooltip":
|
|
8423
|
+
"tooltip": instance.t('frontend_button_search_tooltip'),
|
|
5179
8424
|
"badge": {
|
|
5180
8425
|
"offset": [
|
|
5181
8426
|
-5,
|
|
@@ -5215,12 +8460,12 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5215
8460
|
// },
|
|
5216
8461
|
hiddenCount ? {} : {
|
|
5217
8462
|
"type": "tpl",
|
|
5218
|
-
"tpl": "${count}
|
|
8463
|
+
"tpl": "${count} " + instance.t('frontend_record_sum')
|
|
5219
8464
|
},
|
|
5220
8465
|
{
|
|
5221
8466
|
"type": "reload",
|
|
5222
8467
|
"align": "right",
|
|
5223
|
-
"tooltip":
|
|
8468
|
+
"tooltip": instance.t('frontend_button_reload_tooltip'),
|
|
5224
8469
|
"tooltipPlacement": "bottom",
|
|
5225
8470
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5226
8471
|
},
|
|
@@ -5228,7 +8473,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5228
8473
|
filterVisible ? {
|
|
5229
8474
|
"label": "",
|
|
5230
8475
|
"icon": "fa fa-search",
|
|
5231
|
-
"tooltip":
|
|
8476
|
+
"tooltip": instance.t('frontend_button_search_tooltip'),
|
|
5232
8477
|
"tooltipPlacement": "bottom",
|
|
5233
8478
|
"type": "button",
|
|
5234
8479
|
"align": "right",
|
|
@@ -5848,7 +9093,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5848
9093
|
pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, ctx.formFactor, { headerToolbarItems });
|
|
5849
9094
|
const isAllowCreate = refObjectConfig.permissions.allowCreate;
|
|
5850
9095
|
if (isAllowCreate) {
|
|
5851
|
-
const new_button = await getSchema$
|
|
9096
|
+
const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
|
|
5852
9097
|
new_button.align = "right";
|
|
5853
9098
|
pickerSchema.headerToolbar.push(new_button);
|
|
5854
9099
|
}
|
|
@@ -7731,7 +10976,7 @@ async function getTableOperation(ctx){
|
|
|
7731
10976
|
}
|
|
7732
10977
|
return {
|
|
7733
10978
|
type: 'operation',
|
|
7734
|
-
label: '
|
|
10979
|
+
label: instance.t('frontend_ercord_operation'),
|
|
7735
10980
|
fixed: 'right',
|
|
7736
10981
|
labelClassName: 'text-center',
|
|
7737
10982
|
className: 'text-center steedos-listview-operation w-20',
|
|
@@ -8780,7 +12025,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
8780
12025
|
// ObjectForm会认作用域下的变量值
|
|
8781
12026
|
// TODO: 待组件支持initValues属性后应该改掉,不应该通过data直接传值
|
|
8782
12027
|
// TODO: 全天事件属性传入doc了但是没有生效,需要手动在ObjectForm中勾选全天事件
|
|
8783
|
-
const title = "
|
|
12028
|
+
const title = "${instance.t('frontend_form_new')} ${objectSchema.label}";
|
|
8784
12029
|
doAction(
|
|
8785
12030
|
{
|
|
8786
12031
|
"actionType": "dialog",
|
|
@@ -8814,33 +12059,6 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
8814
12059
|
});
|
|
8815
12060
|
`;
|
|
8816
12061
|
|
|
8817
|
-
const onEventClickScript = `
|
|
8818
|
-
const data = event.data;
|
|
8819
|
-
const eventData = data.event;
|
|
8820
|
-
const appId = data.appId;
|
|
8821
|
-
const objectName = data.objectName;
|
|
8822
|
-
const eventId = data.event && data.event.id;
|
|
8823
|
-
doAction({
|
|
8824
|
-
"actionType": "dialog",
|
|
8825
|
-
"dialog": {
|
|
8826
|
-
"type": "dialog",
|
|
8827
|
-
"title": "",
|
|
8828
|
-
"body": [
|
|
8829
|
-
{
|
|
8830
|
-
"type": "steedos-record-detail",
|
|
8831
|
-
"objectApiName": "\${objectName}",
|
|
8832
|
-
"recordId": data.event && data.event.id
|
|
8833
|
-
}
|
|
8834
|
-
],
|
|
8835
|
-
"closeOnEsc": false,
|
|
8836
|
-
"closeOnOutside": false,
|
|
8837
|
-
"showCloseButton": true,
|
|
8838
|
-
"size": "lg",
|
|
8839
|
-
"actions": []
|
|
8840
|
-
}
|
|
8841
|
-
});
|
|
8842
|
-
`;
|
|
8843
|
-
|
|
8844
12062
|
const recordId = "${event.id}";
|
|
8845
12063
|
const recordPermissionsApi = getCalendarRecordPermissionsApi(objectSchema, recordId);
|
|
8846
12064
|
const recordSaveApi = getCalendarRecordSaveApi(objectSchema, calendarOptions);
|
|
@@ -8886,11 +12104,10 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
8886
12104
|
"weight": 0,
|
|
8887
12105
|
"actions": [
|
|
8888
12106
|
{
|
|
8889
|
-
"
|
|
12107
|
+
"actionType": "link",
|
|
8890
12108
|
"args": {
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
"script": onEventClickScript
|
|
12109
|
+
"link": "/app/${appId}/${objectName}/view/${event.id}"
|
|
12110
|
+
}
|
|
8894
12111
|
}
|
|
8895
12112
|
]
|
|
8896
12113
|
},
|
|
@@ -8920,7 +12137,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
8920
12137
|
"expression": "!event.data.editable",
|
|
8921
12138
|
"args": {
|
|
8922
12139
|
"msgType": "error",
|
|
8923
|
-
"msg":
|
|
12140
|
+
"msg": instance.t('frontend_message_no_permission_to_edit'),
|
|
8924
12141
|
"position": "top-center"
|
|
8925
12142
|
}
|
|
8926
12143
|
},
|
|
@@ -8930,8 +12147,8 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
8930
12147
|
"args": {
|
|
8931
12148
|
"api": recordSaveApi,
|
|
8932
12149
|
"messages": {
|
|
8933
|
-
"success": objectSchema.label +
|
|
8934
|
-
"failed": objectSchema.label +
|
|
12150
|
+
"success": objectSchema.label + instance.t('frontend_message_modification_successful'),
|
|
12151
|
+
"failed": objectSchema.label + instance.t('frontend_message_modification_successful')
|
|
8935
12152
|
}
|
|
8936
12153
|
}
|
|
8937
12154
|
}
|
|
@@ -9003,7 +12220,12 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
9003
12220
|
"initialView": initialView,
|
|
9004
12221
|
"businessHours": businessHours,
|
|
9005
12222
|
...config,
|
|
9006
|
-
"onEvent": onEvent
|
|
12223
|
+
"onEvent": onEvent,
|
|
12224
|
+
"views":{
|
|
12225
|
+
listWeek: {
|
|
12226
|
+
buttonText: instance.t('frontend_calendar_listWeek')
|
|
12227
|
+
}
|
|
12228
|
+
}
|
|
9007
12229
|
};
|
|
9008
12230
|
return amisSchema;
|
|
9009
12231
|
}
|
|
@@ -9022,7 +12244,7 @@ const getFieldSchemaArray = (formFields) => {
|
|
|
9022
12244
|
|
|
9023
12245
|
___default__namespace.forEach(formFields, (field) => {
|
|
9024
12246
|
if (!field.group || field.group == 'null' || field.group == '-')
|
|
9025
|
-
field.group = '
|
|
12247
|
+
field.group = instance.t('frontend_field_group_generalization');
|
|
9026
12248
|
const fieldName = field.name;
|
|
9027
12249
|
let isObjectField = /\w+\.\w+/.test(fieldName);
|
|
9028
12250
|
if (field.type == 'grid' || field.type == 'object') {
|
|
@@ -9187,7 +12409,7 @@ function getBulkActions(objectSchema){
|
|
|
9187
12409
|
"level": "danger",
|
|
9188
12410
|
"label": "批量删除",
|
|
9189
12411
|
"actionType": "ajax",
|
|
9190
|
-
"confirmText":
|
|
12412
|
+
"confirmText": instance.t('frontend_delete_many_confirm_text'),
|
|
9191
12413
|
"className": "hidden",
|
|
9192
12414
|
"id": "batchDelete",
|
|
9193
12415
|
"api": getBatchDelete(objectSchema.name),
|
|
@@ -10466,7 +13688,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
10466
13688
|
const uiSchema = await getUISchema(objectName);
|
|
10467
13689
|
const relatedLists = await getObjectRelatedList(objectName);
|
|
10468
13690
|
const detailed = {
|
|
10469
|
-
"title":
|
|
13691
|
+
"title": instance.t('frontend_record_detail_tab_detailed'),
|
|
10470
13692
|
"className": "px-0 py-4",
|
|
10471
13693
|
"body": [
|
|
10472
13694
|
{
|
|
@@ -10481,7 +13703,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
10481
13703
|
"id": "u:5d4e7e3f6ecc"
|
|
10482
13704
|
};
|
|
10483
13705
|
const related = {
|
|
10484
|
-
"title":
|
|
13706
|
+
"title": instance.t('frontend_record_detail_tab_related'),
|
|
10485
13707
|
"className": "px-0 pt-4",
|
|
10486
13708
|
"body": [
|
|
10487
13709
|
{
|
|
@@ -13538,7 +16760,8 @@ var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
|
13538
16760
|
setSteedosAuth: setSteedosAuth,
|
|
13539
16761
|
setUISchemaFunction: setUISchemaFunction,
|
|
13540
16762
|
setVariable: setVariable,
|
|
13541
|
-
standardButtonsTodo: standardButtonsTodo
|
|
16763
|
+
standardButtonsTodo: standardButtonsTodo,
|
|
16764
|
+
i18next: instance
|
|
13542
16765
|
});
|
|
13543
16766
|
|
|
13544
16767
|
var getSchema = function (field, value, ctx) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -14072,7 +17295,7 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
|
|
|
14072
17295
|
if (!listView) {
|
|
14073
17296
|
return [2 /*return*/, {
|
|
14074
17297
|
"type": "alert",
|
|
14075
|
-
"body": "
|
|
17298
|
+
"body": "".concat(instance.t('frontend_listview_warning_start')).concat(listName).concat(instance.t('frontend_listview_warning_end')),
|
|
14076
17299
|
"level": "warning",
|
|
14077
17300
|
"showIcon": true,
|
|
14078
17301
|
"className": "mb-3"
|
|
@@ -14401,7 +17624,7 @@ var AmisRecordDetailRelatedList = function (props) { return __awaiter(void 0, vo
|
|
|
14401
17624
|
// if(!objectApiName || !relatedObjectApiName || !recordId){
|
|
14402
17625
|
return [2 /*return*/, {
|
|
14403
17626
|
"type": "alert",
|
|
14404
|
-
"body":
|
|
17627
|
+
"body": instance.t('frontend_record_detail_related_list_warning'),
|
|
14405
17628
|
"level": "warning",
|
|
14406
17629
|
"showIcon": true,
|
|
14407
17630
|
"className": "mb-3"
|
|
@@ -14439,7 +17662,7 @@ var AmisRecordDetailRelatedLists = function (props) { return __awaiter(void 0, v
|
|
|
14439
17662
|
// if(!objectApiName || !recordId){
|
|
14440
17663
|
return [2 /*return*/, {
|
|
14441
17664
|
"type": "alert",
|
|
14442
|
-
"body":
|
|
17665
|
+
"body": instance.t('frontend_record_detail_related_lists_warning'),
|
|
14443
17666
|
"level": "warning",
|
|
14444
17667
|
"showIcon": true,
|
|
14445
17668
|
"className": "mb-3"
|
|
@@ -14452,7 +17675,7 @@ var AmisRecordDetailRelatedLists = function (props) { return __awaiter(void 0, v
|
|
|
14452
17675
|
if (!relatedLists || !relatedLists.length) {
|
|
14453
17676
|
return [2 /*return*/, {
|
|
14454
17677
|
"type": "alert",
|
|
14455
|
-
"body":
|
|
17678
|
+
"body": instance.t('frontend_record_detail_related_lists_info'),
|
|
14456
17679
|
"level": "info",
|
|
14457
17680
|
"showIcon": true,
|
|
14458
17681
|
"className": "mb-3"
|
|
@@ -14671,7 +17894,7 @@ var AmisAppLauncher = function (props) { return __awaiter(void 0, void 0, void 0
|
|
|
14671
17894
|
{
|
|
14672
17895
|
"type": "collapse",
|
|
14673
17896
|
"key": "1",
|
|
14674
|
-
"header":
|
|
17897
|
+
"header": instance.t('frontend_all_apps'),
|
|
14675
17898
|
"body": [
|
|
14676
17899
|
{
|
|
14677
17900
|
"type": "each",
|
|
@@ -14740,7 +17963,7 @@ var AmisAppLauncher = function (props) { return __awaiter(void 0, void 0, void 0
|
|
|
14740
17963
|
{
|
|
14741
17964
|
"type": "collapse",
|
|
14742
17965
|
"key": "2",
|
|
14743
|
-
"header":
|
|
17966
|
+
"header": instance.t('frontend_all_projects'),
|
|
14744
17967
|
"body": [
|
|
14745
17968
|
{
|
|
14746
17969
|
"type": "each",
|
|
@@ -14848,7 +18071,7 @@ var AmisAppLauncher = function (props) { return __awaiter(void 0, void 0, void 0
|
|
|
14848
18071
|
"size": "xl",
|
|
14849
18072
|
"title": {
|
|
14850
18073
|
"type": "tpl",
|
|
14851
|
-
"tpl":
|
|
18074
|
+
"tpl": instance.t('frontend_application_launcher'),
|
|
14852
18075
|
"className": "block text-xl text-center"
|
|
14853
18076
|
},
|
|
14854
18077
|
"actions": [],
|
|
@@ -14963,7 +18186,7 @@ var AmisGlobalFooter = function (props) { return __awaiter(void 0, void 0, void
|
|
|
14963
18186
|
schemaApi: {
|
|
14964
18187
|
"method": "get",
|
|
14965
18188
|
"url": "${context.rootUrl}/service/api/apps/".concat(appId, "/menus?mobile=true"),
|
|
14966
|
-
"adaptor": "\n try {\n\n if(payload.children.length == 0){\n payload.data = {};\n return payload\n }\n const data = { nav: [] };\n const stacked = ".concat(stacked, ";\n const showIcon = ").concat(showIcon, ";\n const selectedId = '").concat(selectedId, "';\n let sum = 0;\n _.each(payload.children, (tab)=>{\n sum++;\n const classIcon = tab.icon.replace(/_/g,\"-\");\n if(sum >= 5){\n data.nav.push({\n \"label\": {\n type: 'tpl',\n tpl: `<span class='fill-slate-500 text-slate-700 block -ml-px no-underline group flex items-center text-[12px] font-medium rounded-md flex-col leading-3 nav-label'><svg class=\"slds-icon slds-icon_container slds-icon-standard-`+classIcon+` flex-shrink-0 h-10 w-10\"><use xlink:href=\"/assets/icons/standard-sprite/svg/symbols.svg#${tab.icon || 'account'}\"></use></svg><span>${tab.name}</span><i class=\"fa fa-angle-right\" aria-hidden=\"true\" style=\"position: absolute;right: 20px;color: #bababa;\"></i></span>`,\n className:'h-full flex items-center'\n },\n \"to\": tab.path,\n \"target\":tab.target\n });\n }else{\n data.nav.push({\n \"label\": {\n type: 'tpl',\n tpl: `<span class='fill-slate-500 text-slate-700 block -ml-px no-underline group flex items-center text-[12px] font-medium rounded-md flex-col leading-3 nav-label'><svg class=\"slds-icon slds-icon_container slds-icon-standard-`+classIcon+` flex-shrink-0 h-10 w-10\"><use xlink:href=\"/assets/icons/standard-sprite/svg/symbols.svg#${tab.icon || 'account'}\"></use></svg>${tab.name}</span>`,\n className:'h-full flex items-center'\n },\n \"to\": tab.path,\n \"target\":tab.target\n });\n }\n \n })\n\n payload.data = {\n \"type\": \"nav\",\n className: payload.children.length ==1 ? '").concat(className1, "' : '").concat(className, "',\n \"stacked\": ").concat(stacked, ",\n \"overflow\": {\n \"enable\": true,\n \"maxVisibleCount\": 4,\n \"overflowPopoverClassName\": \"steedos-global-footer-popup\",\n \"overflowLabel\":{\n \"type\": 'tpl',\n \"tpl\": `<span class='fill-slate-500 text-slate-700 block -ml-px no-underline group flex items-center text-[12px] font-medium rounded-md flex-col leading-3 nav-label'><svg class=\" flex-shrink-0 h-10 w-10\" style=\"padding:7px\"><use xlink:href=\"/assets/icons/utility-sprite/svg/symbols.svg#rows\"></use></svg
|
|
18189
|
+
"adaptor": "\n try {\n\n if(payload.children.length == 0){\n payload.data = {};\n return payload\n }\n const data = { nav: [] };\n const stacked = ".concat(stacked, ";\n const showIcon = ").concat(showIcon, ";\n const selectedId = '").concat(selectedId, "';\n let sum = 0;\n _.each(payload.children, (tab)=>{\n sum++;\n const classIcon = tab.icon.replace(/_/g,\"-\");\n if(sum >= 5){\n data.nav.push({\n \"label\": {\n type: 'tpl',\n tpl: `<span class='fill-slate-500 text-slate-700 block -ml-px no-underline group flex items-center text-[12px] font-medium rounded-md flex-col leading-3 nav-label'><svg class=\"slds-icon slds-icon_container slds-icon-standard-`+classIcon+` flex-shrink-0 h-10 w-10\"><use xlink:href=\"/assets/icons/standard-sprite/svg/symbols.svg#${tab.icon || 'account'}\"></use></svg><span>${tab.name}</span><i class=\"fa fa-angle-right\" aria-hidden=\"true\" style=\"position: absolute;right: 20px;color: #bababa;\"></i></span>`,\n className:'h-full flex items-center'\n },\n \"to\": tab.path,\n \"target\":tab.target\n });\n }else{\n data.nav.push({\n \"label\": {\n type: 'tpl',\n tpl: `<span class='fill-slate-500 text-slate-700 block -ml-px no-underline group flex items-center text-[12px] font-medium rounded-md flex-col leading-3 nav-label'><svg class=\"slds-icon slds-icon_container slds-icon-standard-`+classIcon+` flex-shrink-0 h-10 w-10\"><use xlink:href=\"/assets/icons/standard-sprite/svg/symbols.svg#${tab.icon || 'account'}\"></use></svg>${tab.name}</span>`,\n className:'h-full flex items-center'\n },\n \"to\": tab.path,\n \"target\":tab.target\n });\n }\n \n })\n\n payload.data = {\n \"type\": \"nav\",\n className: payload.children.length ==1 ? '").concat(className1, "' : '").concat(className, "',\n \"stacked\": ").concat(stacked, ",\n \"overflow\": {\n \"enable\": true,\n \"maxVisibleCount\": 4,\n \"overflowPopoverClassName\": \"steedos-global-footer-popup\",\n \"overflowLabel\":{\n \"type\": 'tpl',\n \"tpl\": `<span class='fill-slate-500 text-slate-700 block -ml-px no-underline group flex items-center text-[12px] font-medium rounded-md flex-col leading-3 nav-label'><svg class=\" flex-shrink-0 h-10 w-10\" style=\"padding:7px\"><use xlink:href=\"/assets/icons/utility-sprite/svg/symbols.svg#rows\"></use></svg>").concat(instance.t('Menu'), "</span>`,\n \"className\":'h-full flex items-center'\n },\n \"overflowIndicator\":\"\"\n },\n \"indentSize\": ").concat(indentSize, ",\n \"links\": data.nav,\n };\n } catch (error) {\n console.log(`error`, error)\n }\n return payload;\n "),
|
|
14967
18190
|
"headers": {
|
|
14968
18191
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
14969
18192
|
}
|
|
@@ -15023,7 +18246,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15023
18246
|
"className": "slds-button_icon slds-global-header__icon"
|
|
15024
18247
|
}
|
|
15025
18248
|
],
|
|
15026
|
-
"label":
|
|
18249
|
+
"label": instance.t('frontend_help')
|
|
15027
18250
|
},
|
|
15028
18251
|
{
|
|
15029
18252
|
"type": "button",
|
|
@@ -15052,7 +18275,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15052
18275
|
"className": "slds-button_icon slds-global-header__icon"
|
|
15053
18276
|
}
|
|
15054
18277
|
],
|
|
15055
|
-
"label":
|
|
18278
|
+
"label": instance.t('frontend_setup')
|
|
15056
18279
|
},
|
|
15057
18280
|
{
|
|
15058
18281
|
"type": "steedos-dropdown",
|
|
@@ -15114,7 +18337,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15114
18337
|
"body": [
|
|
15115
18338
|
{
|
|
15116
18339
|
"type": "panel",
|
|
15117
|
-
"title":
|
|
18340
|
+
"title": instance.t('frontend_notifications'),
|
|
15118
18341
|
"className": "min-w-[300px] max-w-md",
|
|
15119
18342
|
"body": [
|
|
15120
18343
|
{
|
|
@@ -15162,7 +18385,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15162
18385
|
actions: [
|
|
15163
18386
|
{
|
|
15164
18387
|
"type": "button",
|
|
15165
|
-
"label":
|
|
18388
|
+
"label": instance.t('frontend_notifications_allread'),
|
|
15166
18389
|
"id": "u:5530f3779e3a",
|
|
15167
18390
|
"onEvent": {
|
|
15168
18391
|
"click": {
|
|
@@ -15178,7 +18401,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15178
18401
|
}
|
|
15179
18402
|
},
|
|
15180
18403
|
"messages": {
|
|
15181
|
-
"success":
|
|
18404
|
+
"success": instance.t('frontend_notifications_allread_message')
|
|
15182
18405
|
}
|
|
15183
18406
|
},
|
|
15184
18407
|
"actionType": "ajax"
|
|
@@ -15292,7 +18515,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15292
18515
|
},
|
|
15293
18516
|
{
|
|
15294
18517
|
"type": "button",
|
|
15295
|
-
"label":
|
|
18518
|
+
"label": instance.t('frontend_profile'),
|
|
15296
18519
|
"className": "flex",
|
|
15297
18520
|
"onEvent": {
|
|
15298
18521
|
"click": {
|
|
@@ -15311,7 +18534,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15311
18534
|
},
|
|
15312
18535
|
{
|
|
15313
18536
|
"type": "button",
|
|
15314
|
-
"label":
|
|
18537
|
+
"label": instance.t('frontend_about'),
|
|
15315
18538
|
"className": "flex",
|
|
15316
18539
|
"onEvent": {
|
|
15317
18540
|
"click": {
|
|
@@ -15330,7 +18553,7 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
|
|
|
15330
18553
|
},
|
|
15331
18554
|
{
|
|
15332
18555
|
"type": "button",
|
|
15333
|
-
"label":
|
|
18556
|
+
"label": instance.t('frontend_log_out'),
|
|
15334
18557
|
"className": "flex",
|
|
15335
18558
|
"onEvent": {
|
|
15336
18559
|
"click": {
|
|
@@ -15909,7 +19132,7 @@ var PageObject = function (props) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
15909
19132
|
});
|
|
15910
19133
|
}); };
|
|
15911
19134
|
|
|
15912
|
-
var __assign=function(){return (__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},StandardObjects={Base:{Actions:{standard_query:{visible:function(e,t,r){return !1}},standard_new:{visible:function(e,t,r){return "cms_files"!==e&&"instances"!==e&&(r?r.allowCreate:void 0)}},standard_edit:{visible:function(e,t,r){if(r)return r.allowEdit}},standard_delete:{visible:function(e,t,r){if(r)return r.allowDelete}},standard_import_data:{visible:function(e,t,r){var n=this.object;if(r)return r.allowCreate&&n.hasImportTemplates}},standard_approve:{visible:function(e,t,r){return !1}},standard_view_instance:{visible:function(e,t,r){return !1}},standard_submit_for_approval:{visible:function(e,t,r){return window.Steedos.ProcessManager.allowSubmit.apply(this,[e,t])},todo:function(e,t){return window.Steedos.ProcessManager.submit.apply(this,[e,t])}},standard_follow:{visible:function(e,t,r){return !1}},standard_delete_many:{visible:function(e,t,r){return !RegExp("\\w+/view/\\w+").test(location.pathname)&&(r?r.allowDelete:void 0)}}}}},authRequest=function(e,t){var i=null;e=Steedos.absoluteUrl(e);try{var r=[{name:"Content-Type",value:"application/json"},{name:"Authorization",value:Steedos.getAuthorization()}],n={type:"get",url:e,dataType:"json",contentType:"application/json",beforeSend:function(t){if(r&&r.length)return r.forEach(function(e){return t.setRequestHeader(e.name,e.value)})},success:function(e){i=e;},error:function(e,t,r){var n,o;e.responseJSON&&e.responseJSON.error?(n=e.responseJSON.error,o=void(i={error:n}),o=n.reason||n.message||n,console.error(o)):console.error(e.responseJSON);}};return $.ajax(Object.assign({},n,t)),i}catch(e){console.error(e);}};function _extends(){return (_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);}return e}).apply(this,arguments)}const newFunctionComponent=o=>e=>{const[t,r]=React.useState(!0);var n=()=>{r(!1);};return ___default.has(e,"ref")||(window.SteedosUI.refs[e.name]={show:()=>{r(!0);},close:n}),React__default["default"].createElement(o,_extends({visible:t,onCancel:n,onClose:n},{width:"70%",style:{width:"70%",maxWidth:"950px",minWidth:"480px"}},e))},newComponentRender=(r,n)=>(e,t)=>{e.name||(e.name=r+"-"+(e.name||"default")),(t=t||document.getElementById(`steedos-${r}-root-`+e.name))||((t=document.createElement("div")).setAttribute("id",`steedos-${r}-root-`+e.name),document.body.appendChild(t));e=React__default["default"].createElement(newFunctionComponent(n),e);ReactDOM.createRoot(t).render(e);},Modal=___default.assign(newComponentRender("modal",antd.Modal),{info:antd.Modal.info,success:antd.Modal.success,error:antd.Modal.error,warning:antd.Modal.warning,confirm:antd.Modal.confirm}),Drawer=newComponentRender("drawer",antd.Drawer),getGraphqlFieldsQuery=e=>{const t=["_id"];return e.push("record_permissions"),___default.each(e,e=>{-1<e.indexOf(".")&&(e=e.split(".")[0]),t.push(""+e);}),""+t.join(" ")},getFindOneQuery=(e,t,r)=>{e=e.replace(/\./g,"_");r=getGraphqlFieldsQuery(r);let n="";t=[`id: "${t}"`];return `{record:${e}__findOne${n=0<t.length?`(${t.join(",")})`:n}{${r}}}`},SObject={getRecord:async(e,t,r)=>{return (await fetchAPI("/graphql",{method:"post",body:JSON.stringify({query:getFindOneQuery(e,t,r)})})).data.record},getUISchema:async(e,t)=>getUISchema(e,t)},canSaveFilter=e=>!(!e._id||e.owner!==getSteedosAuth()?.userId),ListView={showFilter:(e,{listView:t,data:r})=>{canSaveFilter(t);r.filters&&(r.filters=filtersToConditions(r.filters));},getVisibleFilter:(e,t)=>{return t||(canSaveFilter(e)?e.filters:void 0)},getQueryFilter:(e,t)=>{return canSaveFilter(e)?ListView.getVisibleFilter(e,t):___default.isEmpty(t)?e.filters:[e.filters,"and",t]},getFirstListView:async e=>{e=await window.getUISchema(e);return _.first(_.sortBy(_.values(e.list_views),"sort_no"))}},Router={getAppPath({appId:e}){return "/app/"+e},getPagePath(){},getObjectListViewPath({appId:e,objectName:t,listViewName:r}){return `/app/${e}/${t}/grid/`+r},getObjectDetailPath({appId:e,objectName:t,recordId:r}){return `/app/${e}/${t}/view/`+r},getObjectRelatedViewPath({appId:e,masterObjectName:t,masterRecordId:r,objectName:n,foreignKey:o}){return `/app/${e}/${t}/${r}/${n}/grid?related_field_name=`+o}};var withModalWrap=function(t,e){return function(e){return React.createElement(t,e)}},render=function(e,t,r,n){e=withModalWrap(e),e=React.createElement(e,__assign({},t));return ReactDOM__default["default"].render(e,r)};const safeRunFunction=(t,r,n,o)=>{try{var i=window.Creator;if(!!(!i||!i.getObjectUrl)&&/\bSteedos\b|\bCreator\b|\bMeteor\b|\bSession\b/.test(t))return console.info("调用了Creator|Steedos|Meteor|Session变量的脚本不执行,直接按空值处理。"),"";let e=[];return ___default.isNil(r)||(e=___default.isArray(r)?r:[r]),t.bind(o||{})(...e)}catch(e){return console.log(e),n}};function safeEval(js){try{return eval(js)}catch(e){console.error(e,js);}}const isExpression=function(e){var t,r;return "string"==typeof e&&(t=/^{{(function.+)}}$/,r=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(r)))},parseSingleExpression=function(t,e,r,n){var o,i=function(e,t){return "#"!==t&&t?"string"==typeof t?_.get(e,t):void console.error("path has to be a string"):e||{}}(e=void 0===e?{}:e,function(e){return "string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))}(r))||{};if("string"!=typeof t)return t;o="__G_L_O_B_A_L__",e="\n return "+t.substring(2,t.length-2).replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,o)).replace(/\bglobal\b/g,JSON.stringify(n)).replace(new RegExp("\\b"+o+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(i));try{return Function(e)()}catch(e){return console.log(e,t,r),t}};var Expression=Object.freeze({__proto__:null,isExpression:isExpression,parseSingleExpression:parseSingleExpression});const getCompatibleDefaultValueExpression=(e,t)=>{let r=e;return /^\{\w+(\.*\w+)*\}$/.test(e)&&(r=-1<e.indexOf("userId")||-1<e.indexOf("spaceId")||-1<e.indexOf("user.")||-1<e.indexOf("now")?`{${e}}`.replace("{{","{{global."):`{${e}}`.replace("{{","{{formData."),t&&(r=r.replace(/\{\{(.+)\}\}/,"{{[$1]}}"))),r},getFieldDefaultValue=(e,t)=>{if(!e)return null;let r=e.defaultValue;e._defaultValue&&(r=safeEval(`(${e._defaultValue})`)),___default.isFunction(r)&&(r=safeRunFunction(r,[],null,{name:e.name})),___default.isString(r)&&(r=getCompatibleDefaultValueExpression(r,e.multiple));var n=isExpression(r);return n&&(r=parseSingleExpression(r,{},"#",t)),"select"===e.type&&(t=e.data_type||"text",!r||n||e.multiple||("text"!==t||___default.isString(r)?"number"!==t||___default.isNumber(r)?"boolean"!==t||___default.isBoolean(r)||(r="true"===r):r=Number(r):r=String(r))),r};function getTreeOptions(t,e){const o=e?.valueField||"value";e?.labelField;const r=e?.unfoldedNum||1,n=[],i=(t,r,n)=>{var e;if(r)return e=_.filter(t,e=>_.includes(r,e[o])),_.each(e,e=>{1<=n?(e.unfolded=!0,e.children&&(e.children=i(t,e.children,n-1))):e.children&&(e.children=i(t,e.children,n));}),e};for(var a=t,s=0;s<a.length;s++)if(a[s].noParent=0,a[s].unfolded=!1,a[s].parent){let e=1;for(var l=0;l<a.length;l++)a[s].parent==a[l][o]&&(e=0);1==e&&(a[s].noParent=1);}else a[s].noParent=1;return _.each(t,e=>{1==e.noParent&&(1<=r?(e.unfolded=!0,n.push(Object.assign({},e,{children:i(t,e.children,r-1)}))):n.push(Object.assign({},e,{children:i(t,e.children,r)})));}),n}function getClosestAmisComponentByType(t,r,n){let o=(n=n||{}).name;var e=n.direction||"up";let i=t.getComponents().find(function(e){return e.props.type===r&&(!o||e.props.name===o)});if(i)return i;if("down"===e){if(t.children&&t.children.length){for(let e=0;e<t.children.length&&!(i=getClosestAmisComponentByType(t.children[e],r,n));e++);return i}}else if("up"===e&&t.parent)return getClosestAmisComponentByType(t.parent,r,n)}function isFilterFormValuesEmpty(e){let t=!0;var e=_.pickBy(e,function(e,t){return /^__searchable__/g.test(t)});return _.isEmpty(e)||(e=_.omitBy(e,function(e){return _.isNil(e)||_.isObject(e)&&_.isEmpty(e)||_.isArray(e)&&_.isEmpty(e.filter(function(e){return !_.isNil(e)}))||_.isString(e)&&0===e.length}),_.isEmpty(e)||(t=!1)),t}const SteedosUI$1=Object.assign({},{render:render,Router:Router,ListView:ListView,Object:SObject,Modal:Modal,Drawer:Drawer,refs:{},getRef(e){return SteedosUI$1.refs[e]},router:{go:(e,t)=>{var r=window.FlowRouter;if(t)return r?r.go(t):window.open(t);r?r.reload():console.warn("暂不支持自动跳转",e);},reload:()=>{console.log("reload");}},message:antd.message,notification:antd.notification,components:{Button:antd.Button,Space:antd.Space},getRefId:({type:e,appId:t,name:r})=>{switch(e){case"listview":return `amis-${t}-${r}-listview`;case"form":return `amis-${t}-${r}-form`;case"detail":return `amis-${t}-${r}-detail`;default:return `amis-${t}-${r}-`+e}},reloadRecord:()=>{if(window.FlowRouter)return window.FlowRouter.reload()},getFieldDefaultValue:getFieldDefaultValue,getTreeOptions:getTreeOptions,getClosestAmisComponentByType:getClosestAmisComponentByType,isFilterFormValuesEmpty:isFilterFormValuesEmpty,getSearchFilter:e=>{var r=[];return _.each(e,(e,t)=>{_.isEmpty(e)&&!_.isBoolean(e)||(_.startsWith(t,"__searchable__between__")?r.push([""+t.replace("__searchable__between__",""),"between",e]):_.startsWith(t,"__searchable__")&&(_.isString(e)?r.push([""+t.replace("__searchable__",""),"contains",e]):r.push([""+t.replace("__searchable__",""),"=",e])));}),r}});var getBuilderContext=function(){return "undefined"==typeof window?{}:Builder.settings.context||Builder.settings},Steedos$1=__assign({getRootUrl:function(e){var t=getBuilderContext();return t.rootUrl||("undefined"!=typeof window?window.localStorage.getItem("steedos:rootUrl"):"")||e},absoluteUrl:function(e){return void 0===e&&(e=""),"".concat(Steedos$1.getRootUrl()).concat(e)},getTenantId:function(){try{var e=getBuilderContext().tenantId;return (e=window.location.search&&!e?new URLSearchParams(window.location.search).get("X-Space-Id"):e)?e:null}catch(e){console.error(e);}},getAuthorization:function(){try{var e=getBuilderContext(),t=e.tenantId,r=e.authToken;return t&&r?"Bearer ".concat(t,",").concat(r):null}catch(e){console.error(e);}},authRequest:authRequest,StandardObjects:StandardObjects},Expression);"undefined"==typeof window||window.Steedos||(window.Steedos=Steedos$1),"undefined"==typeof window||window.SteedosUI||(window.SteedosUI=SteedosUI$1);
|
|
19135
|
+
var __assign=function(){return (__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},StandardObjects={Base:{Actions:{standard_query:{visible:function(e,t,r){return !1}},standard_new:{visible:function(e,t,r){return "cms_files"!==e&&"instances"!==e&&(r?r.allowCreate:void 0)}},standard_edit:{visible:function(e,t,r){if(r)return r.allowEdit}},standard_delete:{visible:function(e,t,r){if(r)return r.allowDelete}},standard_import_data:{visible:function(e,t,r){var n=this.object;if(r)return r.allowCreate&&n.hasImportTemplates}},standard_approve:{visible:function(e,t,r){return !1}},standard_view_instance:{visible:function(e,t,r){return !1}},standard_submit_for_approval:{visible:function(e,t,r){return window.Steedos.ProcessManager.allowSubmit.apply(this,[e,t])},todo:function(e,t){return window.Steedos.ProcessManager.submit.apply(this,[e,t])}},standard_follow:{visible:function(e,t,r){return !1}},standard_delete_many:{visible:function(e,t,r){return !RegExp("\\w+/view/\\w+").test(location.pathname)&&(r?r.allowDelete:void 0)}},standard_export_excel:{visible:function(e,t,r){return !1}}}}},authRequest=function(e,t){var i=null;e=Steedos.absoluteUrl(e);try{var r=[{name:"Content-Type",value:"application/json"},{name:"Authorization",value:Steedos.getAuthorization()}],n={type:"get",url:e,dataType:"json",contentType:"application/json",beforeSend:function(t){if(r&&r.length)return r.forEach(function(e){return t.setRequestHeader(e.name,e.value)})},success:function(e){i=e;},error:function(e,t,r){var n,o;e.responseJSON&&e.responseJSON.error?(n=e.responseJSON.error,o=void(i={error:n}),o=n.reason||n.message||n,console.error(o)):console.error(e.responseJSON);}};return $.ajax(Object.assign({},n,t)),i}catch(e){console.error(e);}};function _extends(){return (_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);}return e}).apply(this,arguments)}const newFunctionComponent=o=>e=>{const[t,r]=React.useState(!0);var n=()=>{r(!1);};return ___default.has(e,"ref")||(window.SteedosUI.refs[e.name]={show:()=>{r(!0);},close:n}),React__default["default"].createElement(o,_extends({visible:t,onCancel:n,onClose:n},{width:"70%",style:{width:"70%",maxWidth:"950px",minWidth:"480px"}},e))},newComponentRender=(r,n)=>(e,t)=>{e.name||(e.name=r+"-"+(e.name||"default")),(t=t||document.getElementById(`steedos-${r}-root-`+e.name))||((t=document.createElement("div")).setAttribute("id",`steedos-${r}-root-`+e.name),document.body.appendChild(t));e=React__default["default"].createElement(newFunctionComponent(n),e);ReactDOM.createRoot(t).render(e);},Modal=___default.assign(newComponentRender("modal",antd.Modal),{info:antd.Modal.info,success:antd.Modal.success,error:antd.Modal.error,warning:antd.Modal.warning,confirm:antd.Modal.confirm}),Drawer=newComponentRender("drawer",antd.Drawer),getGraphqlFieldsQuery=e=>{const t=["_id"];return e.push("record_permissions"),___default.each(e,e=>{-1<e.indexOf(".")&&(e=e.split(".")[0]),t.push(""+e);}),""+t.join(" ")},getFindOneQuery=(e,t,r)=>{e=e.replace(/\./g,"_");r=getGraphqlFieldsQuery(r);let n="";t=[`id: "${t}"`];return `{record:${e}__findOne${n=0<t.length?`(${t.join(",")})`:n}{${r}}}`},SObject={getRecord:async(e,t,r)=>{return (await fetchAPI("/graphql",{method:"post",body:JSON.stringify({query:getFindOneQuery(e,t,r)})})).data.record},getUISchema:async(e,t)=>getUISchema(e,t)},canSaveFilter=e=>!(!e._id||e.owner!==getSteedosAuth()?.userId),ListView={showFilter:(e,{listView:t,data:r})=>{canSaveFilter(t);r.filters&&(r.filters=filtersToConditions(r.filters));},getVisibleFilter:(e,t)=>{return t||(canSaveFilter(e)?e.filters:void 0)},getQueryFilter:(e,t)=>{return canSaveFilter(e)?ListView.getVisibleFilter(e,t):___default.isEmpty(t)?e.filters:[e.filters,"and",t]},getFirstListView:async e=>{e=await window.getUISchema(e);return _.first(_.sortBy(_.values(e.list_views),"sort_no"))}},Router={getAppPath({appId:e}){return "/app/"+e},getPagePath(){},getObjectListViewPath({appId:e,objectName:t,listViewName:r}){return `/app/${e}/${t}/grid/`+r},getObjectDetailPath({appId:e,objectName:t,recordId:r}){return `/app/${e}/${t}/view/`+r},getObjectRelatedViewPath({appId:e,masterObjectName:t,masterRecordId:r,objectName:n,foreignKey:o}){return `/app/${e}/${t}/${r}/${n}/grid?related_field_name=`+o}};var withModalWrap=function(t,e){return function(e){return React.createElement(t,e)}},render=function(e,t,r,n){e=withModalWrap(e),e=React.createElement(e,__assign({},t));return ReactDOM__default["default"].render(e,r)};const safeRunFunction=(t,r,n,o)=>{try{var i=window.Creator;if(!!(!i||!i.getObjectUrl)&&/\bSteedos\b|\bCreator\b|\bMeteor\b|\bSession\b/.test(t))return console.info("调用了Creator|Steedos|Meteor|Session变量的脚本不执行,直接按空值处理。"),"";let e=[];return ___default.isNil(r)||(e=___default.isArray(r)?r:[r]),t.bind(o||{})(...e)}catch(e){return console.log(e),n}};function safeEval(js){try{return eval(js)}catch(e){console.error(e,js);}}const isExpression=function(e){var t,r;return "string"==typeof e&&(t=/^{{(function.+)}}$/,r=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(r)))},parseSingleExpression=function(t,e,r,n){var o,i=function(e,t){return "#"!==t&&t?"string"==typeof t?_.get(e,t):void console.error("path has to be a string"):e||{}}(e=void 0===e?{}:e,function(e){return "string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))}(r))||{};if("string"!=typeof t)return t;o="__G_L_O_B_A_L__",e="\n return "+t.substring(2,t.length-2).replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,o)).replace(/\bglobal\b/g,JSON.stringify(n)).replace(new RegExp("\\b"+o+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(i));try{return Function(e)()}catch(e){return console.log(e,t,r),t}};var Expression=Object.freeze({__proto__:null,isExpression:isExpression,parseSingleExpression:parseSingleExpression});const getCompatibleDefaultValueExpression=(e,t)=>{let r=e;return /^\{\w+(\.*\w+)*\}$/.test(e)&&(r=-1<e.indexOf("userId")||-1<e.indexOf("spaceId")||-1<e.indexOf("user.")||-1<e.indexOf("now")?`{${e}}`.replace("{{","{{global."):`{${e}}`.replace("{{","{{formData."),t&&(r=r.replace(/\{\{(.+)\}\}/,"{{[$1]}}"))),r},getFieldDefaultValue=(e,t)=>{if(!e)return null;let r=e.defaultValue;e._defaultValue&&(r=safeEval(`(${e._defaultValue})`)),___default.isFunction(r)&&(r=safeRunFunction(r,[],null,{name:e.name})),___default.isString(r)&&(r=getCompatibleDefaultValueExpression(r,e.multiple));var n=isExpression(r);return n&&(r=parseSingleExpression(r,{},"#",t)),"select"===e.type&&(t=e.data_type||"text",!r||n||e.multiple||("text"!==t||___default.isString(r)?"number"!==t||___default.isNumber(r)?"boolean"!==t||___default.isBoolean(r)||(r="true"===r):r=Number(r):r=String(r))),r};function getTreeOptions(t,e){const o=e?.valueField||"value";e?.labelField;const r=e?.unfoldedNum||1,n=[],i=(t,r,n)=>{var e;if(r)return e=_.filter(t,e=>_.includes(r,e[o])),_.each(e,e=>{1<=n?(e.unfolded=!0,e.children&&(e.children=i(t,e.children,n-1))):e.children&&(e.children=i(t,e.children,n));}),e};for(var a=t,s=0;s<a.length;s++)if(a[s].noParent=0,a[s].unfolded=!1,a[s].parent){let e=1;for(var l=0;l<a.length;l++)a[s].parent==a[l][o]&&(e=0);1==e&&(a[s].noParent=1);}else a[s].noParent=1;return _.each(t,e=>{1==e.noParent&&(1<=r?(e.unfolded=!0,n.push(Object.assign({},e,{children:i(t,e.children,r-1)}))):n.push(Object.assign({},e,{children:i(t,e.children,r)})));}),n}function getClosestAmisComponentByType(t,r,n){let o=(n=n||{}).name;var e=n.direction||"up";let i=t.getComponents().find(function(e){return e.props.type===r&&(!o||e.props.name===o)});if(i)return i;if("down"===e){if(t.children&&t.children.length){for(let e=0;e<t.children.length&&!(i=getClosestAmisComponentByType(t.children[e],r,n));e++);return i}}else if("up"===e&&t.parent)return getClosestAmisComponentByType(t.parent,r,n)}function isFilterFormValuesEmpty(e){let t=!0;var e=_.pickBy(e,function(e,t){return /^__searchable__/g.test(t)});return _.isEmpty(e)||(e=_.omitBy(e,function(e){return _.isNil(e)||_.isObject(e)&&_.isEmpty(e)||_.isArray(e)&&_.isEmpty(e.filter(function(e){return !_.isNil(e)}))||_.isString(e)&&0===e.length}),_.isEmpty(e)||(t=!1)),t}const SteedosUI$1=Object.assign({},{render:render,Router:Router,ListView:ListView,Object:SObject,Modal:Modal,Drawer:Drawer,refs:{},getRef(e){return SteedosUI$1.refs[e]},router:{go:(e,t)=>{var r=window.FlowRouter;if(t)return r?r.go(t):window.open(t);r?r.reload():console.warn("暂不支持自动跳转",e);},reload:()=>{console.log("reload");}},message:antd.message,notification:antd.notification,components:{Button:antd.Button,Space:antd.Space},getRefId:({type:e,appId:t,name:r})=>{switch(e){case"listview":return `amis-${t}-${r}-listview`;case"form":return `amis-${t}-${r}-form`;case"detail":return `amis-${t}-${r}-detail`;default:return `amis-${t}-${r}-`+e}},reloadRecord:()=>{if(window.FlowRouter)return window.FlowRouter.reload()},getFieldDefaultValue:getFieldDefaultValue,getTreeOptions:getTreeOptions,getClosestAmisComponentByType:getClosestAmisComponentByType,isFilterFormValuesEmpty:isFilterFormValuesEmpty,getSearchFilter:e=>{var o=[];return _.each(e,(e,t)=>{var r,n;_.isEmpty(e)&&!_.isBoolean(e)||(_.startsWith(t,"__searchable__between__")?o.push([""+t.replace("__searchable__between__",""),"between",e]):_.startsWith(t,"__searchable__")&&(_.isString(e)?o.push([""+t.replace("__searchable__",""),"contains",e]):_.isObject(e)&&e.o?(n=[[(r=""+t.replace("__searchable__",""))+"/o","=",e.o]],e.ids.length&&n.push([r+"/ids","=",e.ids]),o.push(n)):o.push([""+t.replace("__searchable__",""),"=",e])));}),o}});var getBuilderContext=function(){return "undefined"==typeof window?{}:Builder.settings.context||Builder.settings},Steedos$1=__assign({getRootUrl:function(e){var t=getBuilderContext();return t.rootUrl||("undefined"!=typeof window?window.localStorage.getItem("steedos:rootUrl"):"")||e},absoluteUrl:function(e){return void 0===e&&(e=""),"".concat(Steedos$1.getRootUrl()).concat(e)},getTenantId:function(){try{var e=getBuilderContext().tenantId;return (e=window.location.search&&!e?new URLSearchParams(window.location.search).get("X-Space-Id"):e)?e:null}catch(e){console.error(e);}},getAuthorization:function(){try{var e=getBuilderContext(),t=e.tenantId,r=e.authToken;return t&&r?"Bearer ".concat(t,",").concat(r):null}catch(e){console.error(e);}},authRequest:authRequest,StandardObjects:StandardObjects},Expression);"undefined"==typeof window||window.Steedos||(window.Steedos=Steedos$1),"undefined"==typeof window||window.SteedosUI||(window.SteedosUI=SteedosUI$1);
|
|
15913
19136
|
|
|
15914
19137
|
var index_esm = /*#__PURE__*/Object.freeze({
|
|
15915
19138
|
__proto__: null,
|