@littlebox/strapi-suite 1.0.51 → 1.0.54
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/README.md +29 -0
- package/dist/_chunks/{App-C7RgdLC-.js → App-B7_8BaVG.js} +557 -35
- package/dist/_chunks/{App-b_1MuDrk.mjs → App-BfGB2pF_.mjs} +550 -28
- package/dist/_chunks/{SlugInput-DlOanbzA.mjs → SlugInput-CvgVtZza.mjs} +1 -2
- package/dist/_chunks/{SlugInput-DvQWzpBu.js → SlugInput-eCwgqJtH.js} +3 -4
- package/dist/_chunks/{en-CGJcJfk1.js → en-D89cXiov.js} +46 -1
- package/dist/_chunks/{en-CRSiVe4w.mjs → en-knG97mCH.mjs} +46 -1
- package/dist/_chunks/{index-C3MUddO-.mjs → index-97f0S4q6.mjs} +2270 -73
- package/dist/_chunks/{index-UZTUyNY3.js → index-DnXsi_Ar.js} +2292 -78
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/src/components/DocumentTranslateBox.d.ts +5 -0
- package/dist/admin/src/components/DocumentTranslateModal.d.ts +11 -0
- package/dist/admin/src/components/TranslationAiModal.d.ts +8 -0
- package/dist/admin/src/components/TranslationSettingsModal.d.ts +6 -0
- package/dist/admin/src/contexts/settings.d.ts +1 -0
- package/dist/admin/src/core/config.d.ts +1 -0
- package/dist/admin/src/core/gateways/aiGateway.d.ts +19 -0
- package/dist/admin/src/core/gateways/documentGateway.d.ts +15 -0
- package/dist/admin/src/core/gateways/translationGateway.d.ts +13 -0
- package/dist/admin/src/core/usecases/translateDocument.d.ts +33 -0
- package/dist/admin/src/core/usecases/translateWithAi.d.ts +17 -0
- package/dist/admin/src/core/utils/documentFields.d.ts +23 -0
- package/dist/admin/src/core/utils/tabs.d.ts +53 -0
- package/dist/admin/src/ctb/TabSelect.d.ts +31 -0
- package/dist/admin/src/ctb/TabsEditor.d.ts +21 -0
- package/dist/admin/src/ctb/registerTabsInContentTypeBuilder.d.ts +1 -0
- package/dist/admin/src/ctb/tabBadges.d.ts +14 -0
- package/dist/admin/src/editView/TabSection.d.ts +6 -0
- package/dist/admin/src/editView/TabsBar.d.ts +10 -0
- package/dist/admin/src/editView/mutateEditViewLayout.d.ts +12 -0
- package/dist/admin/src/editView/sectionVisibility.d.ts +7 -0
- package/dist/admin/src/editView/tabsStore.d.ts +13 -0
- package/dist/server/index.js +812 -392
- package/dist/server/index.mjs +812 -392
- package/dist/server/src/config/index.d.ts +4 -0
- package/dist/server/src/controllers/index.d.ts +6 -0
- package/dist/server/src/controllers/modules/ai-translation.d.ts +7 -0
- package/dist/server/src/controllers/modules/translation.d.ts +1 -0
- package/dist/server/src/index.d.ts +22 -1
- package/dist/server/src/middlewares/tabs.d.ts +4 -0
- package/dist/server/src/services/app/setting.d.ts +3 -1
- package/dist/server/src/services/index.d.ts +16 -1
- package/dist/server/src/services/modules/ai-translation.d.ts +35 -0
- package/dist/server/src/utils/groupByContentTypeTabs.d.ts +7 -0
- package/dist/server/src/utils/tabs.d.ts +17 -0
- package/package.json +6 -3
- package/dist/_chunks/convertToSlug-DmgViUjP.mjs +0 -84
- package/dist/_chunks/convertToSlug-DqHa9ej4.js +0 -83
|
@@ -6,8 +6,31 @@ const reactRouterDom = require("react-router-dom");
|
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
|
7
7
|
const reactIntl = require("react-intl");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
|
+
const styled = require("styled-components");
|
|
10
|
+
const core = require("@dnd-kit/core");
|
|
11
|
+
const modifiers = require("@dnd-kit/modifiers");
|
|
12
|
+
const sortable = require("@dnd-kit/sortable");
|
|
13
|
+
const utilities = require("@dnd-kit/utilities");
|
|
9
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
-
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
17
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
18
|
+
if (e) {
|
|
19
|
+
for (const k in e) {
|
|
20
|
+
if (k !== "default") {
|
|
21
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: () => e[k]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
n.default = e;
|
|
30
|
+
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
33
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
11
34
|
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
12
35
|
const v = glob[path];
|
|
13
36
|
if (v) {
|
|
@@ -73,7 +96,7 @@ function baseClone(src, circulars, clones) {
|
|
|
73
96
|
function clone(src) {
|
|
74
97
|
return baseClone(src, [], []);
|
|
75
98
|
}
|
|
76
|
-
const toString$
|
|
99
|
+
const toString$6 = Object.prototype.toString;
|
|
77
100
|
const errorToString = Error.prototype.toString;
|
|
78
101
|
const regExpToString = RegExp.prototype.toString;
|
|
79
102
|
const symbolToString$1 = typeof Symbol !== "undefined" ? Symbol.prototype.toString : () => "";
|
|
@@ -90,7 +113,7 @@ function printSimpleValue(val, quoteStrings = false) {
|
|
|
90
113
|
if (typeOf === "string") return quoteStrings ? `"${val}"` : val;
|
|
91
114
|
if (typeOf === "function") return "[Function " + (val.name || "anonymous") + "]";
|
|
92
115
|
if (typeOf === "symbol") return symbolToString$1.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
|
93
|
-
const tag = toString$
|
|
116
|
+
const tag = toString$6.call(val).slice(8, -1);
|
|
94
117
|
if (tag === "Date") return isNaN(val.getTime()) ? "" + val : val.toISOString(val);
|
|
95
118
|
if (tag === "Error" || val instanceof Error) return "[" + errorToString.call(val) + "]";
|
|
96
119
|
if (tag === "RegExp") return regExpToString.call(val);
|
|
@@ -254,15 +277,15 @@ function isKey$3(value, object2) {
|
|
|
254
277
|
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object2 != null && value in Object(object2);
|
|
255
278
|
}
|
|
256
279
|
var _isKey = isKey$3;
|
|
257
|
-
function isObject$
|
|
280
|
+
function isObject$4(value) {
|
|
258
281
|
var type = typeof value;
|
|
259
282
|
return value != null && (type == "object" || type == "function");
|
|
260
283
|
}
|
|
261
|
-
var isObject_1 = isObject$
|
|
262
|
-
var baseGetTag$3 = _baseGetTag, isObject$
|
|
284
|
+
var isObject_1 = isObject$4;
|
|
285
|
+
var baseGetTag$3 = _baseGetTag, isObject$3 = isObject_1;
|
|
263
286
|
var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
264
287
|
function isFunction$2(value) {
|
|
265
|
-
if (!isObject$
|
|
288
|
+
if (!isObject$3(value)) {
|
|
266
289
|
return false;
|
|
267
290
|
}
|
|
268
291
|
var tag = baseGetTag$3(value);
|
|
@@ -297,7 +320,7 @@ function toSource$2(func) {
|
|
|
297
320
|
return "";
|
|
298
321
|
}
|
|
299
322
|
var _toSource = toSource$2;
|
|
300
|
-
var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$
|
|
323
|
+
var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$2 = isObject_1, toSource$1 = _toSource;
|
|
301
324
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
302
325
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
303
326
|
var funcProto = Function.prototype, objectProto$9 = Object.prototype;
|
|
@@ -307,7 +330,7 @@ var reIsNative = RegExp(
|
|
|
307
330
|
"^" + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
308
331
|
);
|
|
309
332
|
function baseIsNative$1(value) {
|
|
310
|
-
if (!isObject$
|
|
333
|
+
if (!isObject$2(value) || isMasked(value)) {
|
|
311
334
|
return false;
|
|
312
335
|
}
|
|
313
336
|
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
@@ -596,16 +619,16 @@ function baseToString$1(value) {
|
|
|
596
619
|
}
|
|
597
620
|
var _baseToString = baseToString$1;
|
|
598
621
|
var baseToString = _baseToString;
|
|
599
|
-
function toString$
|
|
622
|
+
function toString$5(value) {
|
|
600
623
|
return value == null ? "" : baseToString(value);
|
|
601
624
|
}
|
|
602
|
-
var toString_1 = toString$
|
|
603
|
-
var isArray$5 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString = toString_1;
|
|
625
|
+
var toString_1 = toString$5;
|
|
626
|
+
var isArray$5 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString$4 = toString_1;
|
|
604
627
|
function castPath$2(value, object2) {
|
|
605
628
|
if (isArray$5(value)) {
|
|
606
629
|
return value;
|
|
607
630
|
}
|
|
608
|
-
return isKey$2(value, object2) ? [value] : stringToPath(toString(value));
|
|
631
|
+
return isKey$2(value, object2) ? [value] : stringToPath(toString$4(value));
|
|
609
632
|
}
|
|
610
633
|
var _castPath = castPath$2;
|
|
611
634
|
var baseGetTag$2 = _baseGetTag, isObjectLike$3 = isObjectLike_1;
|
|
@@ -707,8 +730,8 @@ class Condition {
|
|
|
707
730
|
function toArray(value) {
|
|
708
731
|
return value == null ? [] : [].concat(value);
|
|
709
732
|
}
|
|
710
|
-
function _extends$
|
|
711
|
-
_extends$
|
|
733
|
+
function _extends$4() {
|
|
734
|
+
_extends$4 = Object.assign || function(target) {
|
|
712
735
|
for (var i = 1; i < arguments.length; i++) {
|
|
713
736
|
var source = arguments[i];
|
|
714
737
|
for (var key in source) {
|
|
@@ -719,13 +742,13 @@ function _extends$2() {
|
|
|
719
742
|
}
|
|
720
743
|
return target;
|
|
721
744
|
};
|
|
722
|
-
return _extends$
|
|
745
|
+
return _extends$4.apply(this, arguments);
|
|
723
746
|
}
|
|
724
747
|
let strReg = /\$\{\s*(\w+)\s*\}/g;
|
|
725
748
|
class ValidationError extends Error {
|
|
726
749
|
static formatError(message, params) {
|
|
727
750
|
const path = params.label || params.path || "this";
|
|
728
|
-
if (path !== params.path) params = _extends$
|
|
751
|
+
if (path !== params.path) params = _extends$4({}, params, {
|
|
729
752
|
path
|
|
730
753
|
});
|
|
731
754
|
if (typeof message === "string") return message.replace(strReg, (_, key) => printValue(params[key]));
|
|
@@ -817,7 +840,7 @@ var defineProperty$1 = function() {
|
|
|
817
840
|
}();
|
|
818
841
|
var _defineProperty = defineProperty$1;
|
|
819
842
|
var defineProperty = _defineProperty;
|
|
820
|
-
function baseAssignValue$
|
|
843
|
+
function baseAssignValue$2(object2, key, value) {
|
|
821
844
|
if (key == "__proto__" && defineProperty) {
|
|
822
845
|
defineProperty(object2, key, {
|
|
823
846
|
"configurable": true,
|
|
@@ -829,7 +852,7 @@ function baseAssignValue$1(object2, key, value) {
|
|
|
829
852
|
object2[key] = value;
|
|
830
853
|
}
|
|
831
854
|
}
|
|
832
|
-
var _baseAssignValue = baseAssignValue$
|
|
855
|
+
var _baseAssignValue = baseAssignValue$2;
|
|
833
856
|
function createBaseFor$1(fromRight) {
|
|
834
857
|
return function(object2, iteratee, keysFunc) {
|
|
835
858
|
var index2 = -1, iterable = Object(object2), props = keysFunc(object2), length = props.length;
|
|
@@ -971,10 +994,10 @@ function keys$3(object2) {
|
|
|
971
994
|
}
|
|
972
995
|
var keys_1 = keys$3;
|
|
973
996
|
var baseFor = _baseFor, keys$2 = keys_1;
|
|
974
|
-
function baseForOwn$
|
|
997
|
+
function baseForOwn$2(object2, iteratee) {
|
|
975
998
|
return object2 && baseFor(object2, iteratee, keys$2);
|
|
976
999
|
}
|
|
977
|
-
var _baseForOwn = baseForOwn$
|
|
1000
|
+
var _baseForOwn = baseForOwn$2;
|
|
978
1001
|
var ListCache$2 = _ListCache;
|
|
979
1002
|
function stackClear$1() {
|
|
980
1003
|
this.__data__ = new ListCache$2();
|
|
@@ -1391,9 +1414,9 @@ function baseIsMatch$1(object2, source, matchData, customizer) {
|
|
|
1391
1414
|
return true;
|
|
1392
1415
|
}
|
|
1393
1416
|
var _baseIsMatch = baseIsMatch$1;
|
|
1394
|
-
var isObject = isObject_1;
|
|
1417
|
+
var isObject$1 = isObject_1;
|
|
1395
1418
|
function isStrictComparable$2(value) {
|
|
1396
|
-
return value === value && !isObject(value);
|
|
1419
|
+
return value === value && !isObject$1(value);
|
|
1397
1420
|
}
|
|
1398
1421
|
var _isStrictComparable = isStrictComparable$2;
|
|
1399
1422
|
var isStrictComparable$1 = _isStrictComparable, keys = keys_1;
|
|
@@ -1486,7 +1509,7 @@ function property$1(path) {
|
|
|
1486
1509
|
}
|
|
1487
1510
|
var property_1 = property$1;
|
|
1488
1511
|
var baseMatches = _baseMatches, baseMatchesProperty = _baseMatchesProperty, identity = identity_1, isArray = isArray_1, property = property_1;
|
|
1489
|
-
function baseIteratee$
|
|
1512
|
+
function baseIteratee$2(value) {
|
|
1490
1513
|
if (typeof value == "function") {
|
|
1491
1514
|
return value;
|
|
1492
1515
|
}
|
|
@@ -1498,13 +1521,13 @@ function baseIteratee$1(value) {
|
|
|
1498
1521
|
}
|
|
1499
1522
|
return property(value);
|
|
1500
1523
|
}
|
|
1501
|
-
var _baseIteratee = baseIteratee$
|
|
1502
|
-
var baseAssignValue = _baseAssignValue, baseForOwn = _baseForOwn, baseIteratee = _baseIteratee;
|
|
1524
|
+
var _baseIteratee = baseIteratee$2;
|
|
1525
|
+
var baseAssignValue$1 = _baseAssignValue, baseForOwn$1 = _baseForOwn, baseIteratee$1 = _baseIteratee;
|
|
1503
1526
|
function mapValues(object2, iteratee) {
|
|
1504
1527
|
var result = {};
|
|
1505
|
-
iteratee = baseIteratee(iteratee);
|
|
1506
|
-
baseForOwn(object2, function(value, key, object3) {
|
|
1507
|
-
baseAssignValue(result, key, iteratee(value, key, object3));
|
|
1528
|
+
iteratee = baseIteratee$1(iteratee);
|
|
1529
|
+
baseForOwn$1(object2, function(value, key, object3) {
|
|
1530
|
+
baseAssignValue$1(result, key, iteratee(value, key, object3));
|
|
1508
1531
|
});
|
|
1509
1532
|
return result;
|
|
1510
1533
|
}
|
|
@@ -1655,8 +1678,8 @@ class Reference {
|
|
|
1655
1678
|
}
|
|
1656
1679
|
}
|
|
1657
1680
|
Reference.prototype.__isYupRef = true;
|
|
1658
|
-
function _extends$
|
|
1659
|
-
_extends$
|
|
1681
|
+
function _extends$3() {
|
|
1682
|
+
_extends$3 = Object.assign || function(target) {
|
|
1660
1683
|
for (var i = 1; i < arguments.length; i++) {
|
|
1661
1684
|
var source = arguments[i];
|
|
1662
1685
|
for (var key in source) {
|
|
@@ -1667,7 +1690,7 @@ function _extends$1() {
|
|
|
1667
1690
|
}
|
|
1668
1691
|
return target;
|
|
1669
1692
|
};
|
|
1670
|
-
return _extends$
|
|
1693
|
+
return _extends$3.apply(this, arguments);
|
|
1671
1694
|
}
|
|
1672
1695
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
1673
1696
|
if (source == null) return {};
|
|
@@ -1705,7 +1728,7 @@ function createValidation(config2) {
|
|
|
1705
1728
|
return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
|
|
1706
1729
|
}
|
|
1707
1730
|
function createError(overrides = {}) {
|
|
1708
|
-
const nextParams = mapValues$1(_extends$
|
|
1731
|
+
const nextParams = mapValues$1(_extends$3({
|
|
1709
1732
|
value,
|
|
1710
1733
|
originalValue,
|
|
1711
1734
|
label,
|
|
@@ -1715,7 +1738,7 @@ function createValidation(config2) {
|
|
|
1715
1738
|
error.params = nextParams;
|
|
1716
1739
|
return error;
|
|
1717
1740
|
}
|
|
1718
|
-
let ctx = _extends$
|
|
1741
|
+
let ctx = _extends$3({
|
|
1719
1742
|
path,
|
|
1720
1743
|
parent,
|
|
1721
1744
|
type: name,
|
|
@@ -1837,8 +1860,8 @@ class ReferenceSet {
|
|
|
1837
1860
|
return next;
|
|
1838
1861
|
}
|
|
1839
1862
|
}
|
|
1840
|
-
function _extends() {
|
|
1841
|
-
_extends = Object.assign || function(target) {
|
|
1863
|
+
function _extends$2() {
|
|
1864
|
+
_extends$2 = Object.assign || function(target) {
|
|
1842
1865
|
for (var i = 1; i < arguments.length; i++) {
|
|
1843
1866
|
var source = arguments[i];
|
|
1844
1867
|
for (var key in source) {
|
|
@@ -1849,7 +1872,7 @@ function _extends() {
|
|
|
1849
1872
|
}
|
|
1850
1873
|
return target;
|
|
1851
1874
|
};
|
|
1852
|
-
return _extends.apply(this, arguments);
|
|
1875
|
+
return _extends$2.apply(this, arguments);
|
|
1853
1876
|
}
|
|
1854
1877
|
class BaseSchema {
|
|
1855
1878
|
constructor(options) {
|
|
@@ -1864,7 +1887,7 @@ class BaseSchema {
|
|
|
1864
1887
|
this.typeError(mixed.notType);
|
|
1865
1888
|
});
|
|
1866
1889
|
this.type = (options == null ? void 0 : options.type) || "mixed";
|
|
1867
|
-
this.spec = _extends({
|
|
1890
|
+
this.spec = _extends$2({
|
|
1868
1891
|
strip: false,
|
|
1869
1892
|
strict: false,
|
|
1870
1893
|
abortEarly: true,
|
|
@@ -1892,12 +1915,12 @@ class BaseSchema {
|
|
|
1892
1915
|
next._blacklistError = this._blacklistError;
|
|
1893
1916
|
next._whitelist = this._whitelist.clone();
|
|
1894
1917
|
next._blacklist = this._blacklist.clone();
|
|
1895
|
-
next.exclusiveTests = _extends({}, this.exclusiveTests);
|
|
1918
|
+
next.exclusiveTests = _extends$2({}, this.exclusiveTests);
|
|
1896
1919
|
next.deps = [...this.deps];
|
|
1897
1920
|
next.conditions = [...this.conditions];
|
|
1898
1921
|
next.tests = [...this.tests];
|
|
1899
1922
|
next.transforms = [...this.transforms];
|
|
1900
|
-
next.spec = clone(_extends({}, this.spec, spec));
|
|
1923
|
+
next.spec = clone(_extends$2({}, this.spec, spec));
|
|
1901
1924
|
return next;
|
|
1902
1925
|
}
|
|
1903
1926
|
label(label) {
|
|
@@ -1930,7 +1953,7 @@ class BaseSchema {
|
|
|
1930
1953
|
if (schema.type !== this.type && this.type !== "mixed") throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
|
|
1931
1954
|
let base = this;
|
|
1932
1955
|
let combined = schema.clone();
|
|
1933
|
-
const mergedSpec = _extends({}, base.spec, combined.spec);
|
|
1956
|
+
const mergedSpec = _extends$2({}, base.spec, combined.spec);
|
|
1934
1957
|
combined.spec = mergedSpec;
|
|
1935
1958
|
combined._typeError || (combined._typeError = base._typeError);
|
|
1936
1959
|
combined._whitelistError || (combined._whitelistError = base._whitelistError);
|
|
@@ -1969,7 +1992,7 @@ class BaseSchema {
|
|
|
1969
1992
|
* @param {*=} options.context
|
|
1970
1993
|
*/
|
|
1971
1994
|
cast(value, options = {}) {
|
|
1972
|
-
let resolvedSchema = this.resolve(_extends({
|
|
1995
|
+
let resolvedSchema = this.resolve(_extends$2({
|
|
1973
1996
|
value
|
|
1974
1997
|
}, options));
|
|
1975
1998
|
let result = resolvedSchema._cast(value, options);
|
|
@@ -2001,7 +2024,7 @@ attempted value: ${formattedValue}
|
|
|
2001
2024
|
} = options;
|
|
2002
2025
|
let value = _value;
|
|
2003
2026
|
if (!strict) {
|
|
2004
|
-
value = this._cast(value, _extends({
|
|
2027
|
+
value = this._cast(value, _extends$2({
|
|
2005
2028
|
assert: false
|
|
2006
2029
|
}, options));
|
|
2007
2030
|
}
|
|
@@ -2038,7 +2061,7 @@ attempted value: ${formattedValue}
|
|
|
2038
2061
|
});
|
|
2039
2062
|
}
|
|
2040
2063
|
validate(value, options, maybeCb) {
|
|
2041
|
-
let schema = this.resolve(_extends({}, options, {
|
|
2064
|
+
let schema = this.resolve(_extends$2({}, options, {
|
|
2042
2065
|
value
|
|
2043
2066
|
}));
|
|
2044
2067
|
return typeof maybeCb === "function" ? schema._validate(value, options, maybeCb) : new Promise((resolve, reject) => schema._validate(value, options, (err, value2) => {
|
|
@@ -2047,11 +2070,11 @@ attempted value: ${formattedValue}
|
|
|
2047
2070
|
}));
|
|
2048
2071
|
}
|
|
2049
2072
|
validateSync(value, options) {
|
|
2050
|
-
let schema = this.resolve(_extends({}, options, {
|
|
2073
|
+
let schema = this.resolve(_extends$2({}, options, {
|
|
2051
2074
|
value
|
|
2052
2075
|
}));
|
|
2053
2076
|
let result;
|
|
2054
|
-
schema._validate(value, _extends({}, options, {
|
|
2077
|
+
schema._validate(value, _extends$2({}, options, {
|
|
2055
2078
|
sync: true
|
|
2056
2079
|
}), (err, value2) => {
|
|
2057
2080
|
if (err) throw err;
|
|
@@ -2299,7 +2322,7 @@ for (const method of ["validate", "validateSync"]) BaseSchema.prototype[`${metho
|
|
|
2299
2322
|
parentPath,
|
|
2300
2323
|
schema
|
|
2301
2324
|
} = getIn(this, path, value, options.context);
|
|
2302
|
-
return schema[method](parent && parent[parentPath], _extends({}, options, {
|
|
2325
|
+
return schema[method](parent && parent[parentPath], _extends$2({}, options, {
|
|
2303
2326
|
parent,
|
|
2304
2327
|
path
|
|
2305
2328
|
}));
|
|
@@ -2313,7 +2336,7 @@ let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFD
|
|
|
2313
2336
|
let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
2314
2337
|
let isTrimmed = (value) => isAbsent(value) || value === value.trim();
|
|
2315
2338
|
let objStringTag = {}.toString();
|
|
2316
|
-
function create() {
|
|
2339
|
+
function create$2() {
|
|
2317
2340
|
return new StringSchema();
|
|
2318
2341
|
}
|
|
2319
2342
|
class StringSchema extends BaseSchema {
|
|
@@ -2450,7 +2473,7 @@ class StringSchema extends BaseSchema {
|
|
|
2450
2473
|
});
|
|
2451
2474
|
}
|
|
2452
2475
|
}
|
|
2453
|
-
create.prototype = StringSchema.prototype;
|
|
2476
|
+
create$2.prototype = StringSchema.prototype;
|
|
2454
2477
|
var isoReg = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;
|
|
2455
2478
|
function parseIsoDate(date2) {
|
|
2456
2479
|
var numericKeys = [1, 4, 5, 6, 7, 10, 11], minutesOffset = 0, timestamp, struct;
|
|
@@ -2529,11 +2552,373 @@ class DateSchema extends BaseSchema {
|
|
|
2529
2552
|
}
|
|
2530
2553
|
}
|
|
2531
2554
|
DateSchema.INVALID_DATE = invalidDate;
|
|
2532
|
-
|
|
2533
|
-
|
|
2555
|
+
function arrayReduce$1(array2, iteratee, accumulator, initAccum) {
|
|
2556
|
+
var index2 = -1, length = array2 == null ? 0 : array2.length;
|
|
2557
|
+
if (initAccum && length) {
|
|
2558
|
+
accumulator = array2[++index2];
|
|
2559
|
+
}
|
|
2560
|
+
while (++index2 < length) {
|
|
2561
|
+
accumulator = iteratee(accumulator, array2[index2], index2, array2);
|
|
2562
|
+
}
|
|
2563
|
+
return accumulator;
|
|
2564
|
+
}
|
|
2565
|
+
var _arrayReduce = arrayReduce$1;
|
|
2566
|
+
function basePropertyOf$1(object2) {
|
|
2567
|
+
return function(key) {
|
|
2568
|
+
return object2 == null ? void 0 : object2[key];
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2571
|
+
var _basePropertyOf = basePropertyOf$1;
|
|
2572
|
+
var basePropertyOf = _basePropertyOf;
|
|
2573
|
+
var deburredLetters = {
|
|
2574
|
+
// Latin-1 Supplement block.
|
|
2575
|
+
"À": "A",
|
|
2576
|
+
"Á": "A",
|
|
2577
|
+
"Â": "A",
|
|
2578
|
+
"Ã": "A",
|
|
2579
|
+
"Ä": "A",
|
|
2580
|
+
"Å": "A",
|
|
2581
|
+
"à": "a",
|
|
2582
|
+
"á": "a",
|
|
2583
|
+
"â": "a",
|
|
2584
|
+
"ã": "a",
|
|
2585
|
+
"ä": "a",
|
|
2586
|
+
"å": "a",
|
|
2587
|
+
"Ç": "C",
|
|
2588
|
+
"ç": "c",
|
|
2589
|
+
"Ð": "D",
|
|
2590
|
+
"ð": "d",
|
|
2591
|
+
"È": "E",
|
|
2592
|
+
"É": "E",
|
|
2593
|
+
"Ê": "E",
|
|
2594
|
+
"Ë": "E",
|
|
2595
|
+
"è": "e",
|
|
2596
|
+
"é": "e",
|
|
2597
|
+
"ê": "e",
|
|
2598
|
+
"ë": "e",
|
|
2599
|
+
"Ì": "I",
|
|
2600
|
+
"Í": "I",
|
|
2601
|
+
"Î": "I",
|
|
2602
|
+
"Ï": "I",
|
|
2603
|
+
"ì": "i",
|
|
2604
|
+
"í": "i",
|
|
2605
|
+
"î": "i",
|
|
2606
|
+
"ï": "i",
|
|
2607
|
+
"Ñ": "N",
|
|
2608
|
+
"ñ": "n",
|
|
2609
|
+
"Ò": "O",
|
|
2610
|
+
"Ó": "O",
|
|
2611
|
+
"Ô": "O",
|
|
2612
|
+
"Õ": "O",
|
|
2613
|
+
"Ö": "O",
|
|
2614
|
+
"Ø": "O",
|
|
2615
|
+
"ò": "o",
|
|
2616
|
+
"ó": "o",
|
|
2617
|
+
"ô": "o",
|
|
2618
|
+
"õ": "o",
|
|
2619
|
+
"ö": "o",
|
|
2620
|
+
"ø": "o",
|
|
2621
|
+
"Ù": "U",
|
|
2622
|
+
"Ú": "U",
|
|
2623
|
+
"Û": "U",
|
|
2624
|
+
"Ü": "U",
|
|
2625
|
+
"ù": "u",
|
|
2626
|
+
"ú": "u",
|
|
2627
|
+
"û": "u",
|
|
2628
|
+
"ü": "u",
|
|
2629
|
+
"Ý": "Y",
|
|
2630
|
+
"ý": "y",
|
|
2631
|
+
"ÿ": "y",
|
|
2632
|
+
"Æ": "Ae",
|
|
2633
|
+
"æ": "ae",
|
|
2634
|
+
"Þ": "Th",
|
|
2635
|
+
"þ": "th",
|
|
2636
|
+
"ß": "ss",
|
|
2637
|
+
// Latin Extended-A block.
|
|
2638
|
+
"Ā": "A",
|
|
2639
|
+
"Ă": "A",
|
|
2640
|
+
"Ą": "A",
|
|
2641
|
+
"ā": "a",
|
|
2642
|
+
"ă": "a",
|
|
2643
|
+
"ą": "a",
|
|
2644
|
+
"Ć": "C",
|
|
2645
|
+
"Ĉ": "C",
|
|
2646
|
+
"Ċ": "C",
|
|
2647
|
+
"Č": "C",
|
|
2648
|
+
"ć": "c",
|
|
2649
|
+
"ĉ": "c",
|
|
2650
|
+
"ċ": "c",
|
|
2651
|
+
"č": "c",
|
|
2652
|
+
"Ď": "D",
|
|
2653
|
+
"Đ": "D",
|
|
2654
|
+
"ď": "d",
|
|
2655
|
+
"đ": "d",
|
|
2656
|
+
"Ē": "E",
|
|
2657
|
+
"Ĕ": "E",
|
|
2658
|
+
"Ė": "E",
|
|
2659
|
+
"Ę": "E",
|
|
2660
|
+
"Ě": "E",
|
|
2661
|
+
"ē": "e",
|
|
2662
|
+
"ĕ": "e",
|
|
2663
|
+
"ė": "e",
|
|
2664
|
+
"ę": "e",
|
|
2665
|
+
"ě": "e",
|
|
2666
|
+
"Ĝ": "G",
|
|
2667
|
+
"Ğ": "G",
|
|
2668
|
+
"Ġ": "G",
|
|
2669
|
+
"Ģ": "G",
|
|
2670
|
+
"ĝ": "g",
|
|
2671
|
+
"ğ": "g",
|
|
2672
|
+
"ġ": "g",
|
|
2673
|
+
"ģ": "g",
|
|
2674
|
+
"Ĥ": "H",
|
|
2675
|
+
"Ħ": "H",
|
|
2676
|
+
"ĥ": "h",
|
|
2677
|
+
"ħ": "h",
|
|
2678
|
+
"Ĩ": "I",
|
|
2679
|
+
"Ī": "I",
|
|
2680
|
+
"Ĭ": "I",
|
|
2681
|
+
"Į": "I",
|
|
2682
|
+
"İ": "I",
|
|
2683
|
+
"ĩ": "i",
|
|
2684
|
+
"ī": "i",
|
|
2685
|
+
"ĭ": "i",
|
|
2686
|
+
"į": "i",
|
|
2687
|
+
"ı": "i",
|
|
2688
|
+
"Ĵ": "J",
|
|
2689
|
+
"ĵ": "j",
|
|
2690
|
+
"Ķ": "K",
|
|
2691
|
+
"ķ": "k",
|
|
2692
|
+
"ĸ": "k",
|
|
2693
|
+
"Ĺ": "L",
|
|
2694
|
+
"Ļ": "L",
|
|
2695
|
+
"Ľ": "L",
|
|
2696
|
+
"Ŀ": "L",
|
|
2697
|
+
"Ł": "L",
|
|
2698
|
+
"ĺ": "l",
|
|
2699
|
+
"ļ": "l",
|
|
2700
|
+
"ľ": "l",
|
|
2701
|
+
"ŀ": "l",
|
|
2702
|
+
"ł": "l",
|
|
2703
|
+
"Ń": "N",
|
|
2704
|
+
"Ņ": "N",
|
|
2705
|
+
"Ň": "N",
|
|
2706
|
+
"Ŋ": "N",
|
|
2707
|
+
"ń": "n",
|
|
2708
|
+
"ņ": "n",
|
|
2709
|
+
"ň": "n",
|
|
2710
|
+
"ŋ": "n",
|
|
2711
|
+
"Ō": "O",
|
|
2712
|
+
"Ŏ": "O",
|
|
2713
|
+
"Ő": "O",
|
|
2714
|
+
"ō": "o",
|
|
2715
|
+
"ŏ": "o",
|
|
2716
|
+
"ő": "o",
|
|
2717
|
+
"Ŕ": "R",
|
|
2718
|
+
"Ŗ": "R",
|
|
2719
|
+
"Ř": "R",
|
|
2720
|
+
"ŕ": "r",
|
|
2721
|
+
"ŗ": "r",
|
|
2722
|
+
"ř": "r",
|
|
2723
|
+
"Ś": "S",
|
|
2724
|
+
"Ŝ": "S",
|
|
2725
|
+
"Ş": "S",
|
|
2726
|
+
"Š": "S",
|
|
2727
|
+
"ś": "s",
|
|
2728
|
+
"ŝ": "s",
|
|
2729
|
+
"ş": "s",
|
|
2730
|
+
"š": "s",
|
|
2731
|
+
"Ţ": "T",
|
|
2732
|
+
"Ť": "T",
|
|
2733
|
+
"Ŧ": "T",
|
|
2734
|
+
"ţ": "t",
|
|
2735
|
+
"ť": "t",
|
|
2736
|
+
"ŧ": "t",
|
|
2737
|
+
"Ũ": "U",
|
|
2738
|
+
"Ū": "U",
|
|
2739
|
+
"Ŭ": "U",
|
|
2740
|
+
"Ů": "U",
|
|
2741
|
+
"Ű": "U",
|
|
2742
|
+
"Ų": "U",
|
|
2743
|
+
"ũ": "u",
|
|
2744
|
+
"ū": "u",
|
|
2745
|
+
"ŭ": "u",
|
|
2746
|
+
"ů": "u",
|
|
2747
|
+
"ű": "u",
|
|
2748
|
+
"ų": "u",
|
|
2749
|
+
"Ŵ": "W",
|
|
2750
|
+
"ŵ": "w",
|
|
2751
|
+
"Ŷ": "Y",
|
|
2752
|
+
"ŷ": "y",
|
|
2753
|
+
"Ÿ": "Y",
|
|
2754
|
+
"Ź": "Z",
|
|
2755
|
+
"Ż": "Z",
|
|
2756
|
+
"Ž": "Z",
|
|
2757
|
+
"ź": "z",
|
|
2758
|
+
"ż": "z",
|
|
2759
|
+
"ž": "z",
|
|
2760
|
+
"IJ": "IJ",
|
|
2761
|
+
"ij": "ij",
|
|
2762
|
+
"Œ": "Oe",
|
|
2763
|
+
"œ": "oe",
|
|
2764
|
+
"ʼn": "'n",
|
|
2765
|
+
"ſ": "s"
|
|
2766
|
+
};
|
|
2767
|
+
var deburrLetter$1 = basePropertyOf(deburredLetters);
|
|
2768
|
+
var _deburrLetter = deburrLetter$1;
|
|
2769
|
+
var deburrLetter = _deburrLetter, toString$3 = toString_1;
|
|
2770
|
+
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
2771
|
+
var rsComboMarksRange$3 = "\\u0300-\\u036f", reComboHalfMarksRange$3 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$3 = "\\u20d0-\\u20ff", rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3;
|
|
2772
|
+
var rsCombo$2 = "[" + rsComboRange$3 + "]";
|
|
2773
|
+
var reComboMark = RegExp(rsCombo$2, "g");
|
|
2774
|
+
function deburr$1(string2) {
|
|
2775
|
+
string2 = toString$3(string2);
|
|
2776
|
+
return string2 && string2.replace(reLatin, deburrLetter).replace(reComboMark, "");
|
|
2777
|
+
}
|
|
2778
|
+
var deburr_1 = deburr$1;
|
|
2779
|
+
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
2780
|
+
function asciiWords$1(string2) {
|
|
2781
|
+
return string2.match(reAsciiWord) || [];
|
|
2782
|
+
}
|
|
2783
|
+
var _asciiWords = asciiWords$1;
|
|
2784
|
+
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
|
2785
|
+
function hasUnicodeWord$1(string2) {
|
|
2786
|
+
return reHasUnicodeWord.test(string2);
|
|
2787
|
+
}
|
|
2788
|
+
var _hasUnicodeWord = hasUnicodeWord$1;
|
|
2789
|
+
var rsAstralRange$2 = "\\ud800-\\udfff", rsComboMarksRange$2 = "\\u0300-\\u036f", reComboHalfMarksRange$2 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$2 = "\\u20d0-\\u20ff", rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2, rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange$2 = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
|
2790
|
+
var rsApos$1 = "['’]", rsBreak = "[" + rsBreakRange + "]", rsCombo$1 = "[" + rsComboRange$2 + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange$2 + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsFitz$1 = "\\ud83c[\\udffb-\\udfff]", rsModifier$1 = "(?:" + rsCombo$1 + "|" + rsFitz$1 + ")", rsNonAstral$1 = "[^" + rsAstralRange$2 + "]", rsRegional$1 = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair$1 = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ$2 = "\\u200d";
|
|
2791
|
+
var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos$1 + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos$1 + "(?:D|LL|M|RE|S|T|VE))?", reOptMod$1 = rsModifier$1 + "?", rsOptVar$1 = "[" + rsVarRange$2 + "]?", rsOptJoin$1 = "(?:" + rsZWJ$2 + "(?:" + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join("|") + ")" + rsOptVar$1 + reOptMod$1 + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1, rsEmoji = "(?:" + [rsDingbat, rsRegional$1, rsSurrPair$1].join("|") + ")" + rsSeq$1;
|
|
2792
|
+
var reUnicodeWord = RegExp([
|
|
2793
|
+
rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
|
|
2794
|
+
rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
|
|
2795
|
+
rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
|
|
2796
|
+
rsUpper + "+" + rsOptContrUpper,
|
|
2797
|
+
rsOrdUpper,
|
|
2798
|
+
rsOrdLower,
|
|
2799
|
+
rsDigits,
|
|
2800
|
+
rsEmoji
|
|
2801
|
+
].join("|"), "g");
|
|
2802
|
+
function unicodeWords$1(string2) {
|
|
2803
|
+
return string2.match(reUnicodeWord) || [];
|
|
2804
|
+
}
|
|
2805
|
+
var _unicodeWords = unicodeWords$1;
|
|
2806
|
+
var asciiWords = _asciiWords, hasUnicodeWord = _hasUnicodeWord, toString$2 = toString_1, unicodeWords = _unicodeWords;
|
|
2807
|
+
function words$1(string2, pattern, guard) {
|
|
2808
|
+
string2 = toString$2(string2);
|
|
2809
|
+
pattern = guard ? void 0 : pattern;
|
|
2810
|
+
if (pattern === void 0) {
|
|
2811
|
+
return hasUnicodeWord(string2) ? unicodeWords(string2) : asciiWords(string2);
|
|
2812
|
+
}
|
|
2813
|
+
return string2.match(pattern) || [];
|
|
2814
|
+
}
|
|
2815
|
+
var words_1 = words$1;
|
|
2816
|
+
var arrayReduce = _arrayReduce, deburr = deburr_1, words = words_1;
|
|
2817
|
+
var rsApos = "['’]";
|
|
2818
|
+
var reApos = RegExp(rsApos, "g");
|
|
2819
|
+
function createCompounder$2(callback) {
|
|
2820
|
+
return function(string2) {
|
|
2821
|
+
return arrayReduce(words(deburr(string2).replace(reApos, "")), callback, "");
|
|
2822
|
+
};
|
|
2823
|
+
}
|
|
2824
|
+
var _createCompounder = createCompounder$2;
|
|
2825
|
+
var createCompounder$1 = _createCompounder;
|
|
2826
|
+
var snakeCase = createCompounder$1(function(result, word, index2) {
|
|
2827
|
+
return result + (index2 ? "_" : "") + word.toLowerCase();
|
|
2828
|
+
});
|
|
2829
|
+
var snakeCase_1 = snakeCase;
|
|
2830
|
+
const snakeCase$1 = /* @__PURE__ */ getDefaultExportFromCjs(snakeCase_1);
|
|
2831
|
+
function baseSlice$1(array2, start, end) {
|
|
2832
|
+
var index2 = -1, length = array2.length;
|
|
2833
|
+
if (start < 0) {
|
|
2834
|
+
start = -start > length ? 0 : length + start;
|
|
2835
|
+
}
|
|
2836
|
+
end = end > length ? length : end;
|
|
2837
|
+
if (end < 0) {
|
|
2838
|
+
end += length;
|
|
2839
|
+
}
|
|
2840
|
+
length = start > end ? 0 : end - start >>> 0;
|
|
2841
|
+
start >>>= 0;
|
|
2842
|
+
var result = Array(length);
|
|
2843
|
+
while (++index2 < length) {
|
|
2844
|
+
result[index2] = array2[index2 + start];
|
|
2845
|
+
}
|
|
2846
|
+
return result;
|
|
2847
|
+
}
|
|
2848
|
+
var _baseSlice = baseSlice$1;
|
|
2849
|
+
var baseSlice = _baseSlice;
|
|
2850
|
+
function castSlice$1(array2, start, end) {
|
|
2851
|
+
var length = array2.length;
|
|
2852
|
+
end = end === void 0 ? length : end;
|
|
2853
|
+
return !start && end >= length ? array2 : baseSlice(array2, start, end);
|
|
2854
|
+
}
|
|
2855
|
+
var _castSlice = castSlice$1;
|
|
2856
|
+
var rsAstralRange$1 = "\\ud800-\\udfff", rsComboMarksRange$1 = "\\u0300-\\u036f", reComboHalfMarksRange$1 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$1 = "\\u20d0-\\u20ff", rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1, rsVarRange$1 = "\\ufe0e\\ufe0f";
|
|
2857
|
+
var rsZWJ$1 = "\\u200d";
|
|
2858
|
+
var reHasUnicode = RegExp("[" + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + "]");
|
|
2859
|
+
function hasUnicode$2(string2) {
|
|
2860
|
+
return reHasUnicode.test(string2);
|
|
2861
|
+
}
|
|
2862
|
+
var _hasUnicode = hasUnicode$2;
|
|
2863
|
+
function asciiToArray$1(string2) {
|
|
2864
|
+
return string2.split("");
|
|
2865
|
+
}
|
|
2866
|
+
var _asciiToArray = asciiToArray$1;
|
|
2867
|
+
var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f";
|
|
2868
|
+
var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d";
|
|
2869
|
+
var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
|
|
2870
|
+
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
|
|
2871
|
+
function unicodeToArray$1(string2) {
|
|
2872
|
+
return string2.match(reUnicode) || [];
|
|
2873
|
+
}
|
|
2874
|
+
var _unicodeToArray = unicodeToArray$1;
|
|
2875
|
+
var asciiToArray = _asciiToArray, hasUnicode$1 = _hasUnicode, unicodeToArray = _unicodeToArray;
|
|
2876
|
+
function stringToArray$1(string2) {
|
|
2877
|
+
return hasUnicode$1(string2) ? unicodeToArray(string2) : asciiToArray(string2);
|
|
2878
|
+
}
|
|
2879
|
+
var _stringToArray = stringToArray$1;
|
|
2880
|
+
var castSlice = _castSlice, hasUnicode = _hasUnicode, stringToArray = _stringToArray, toString$1 = toString_1;
|
|
2881
|
+
function createCaseFirst$1(methodName) {
|
|
2882
|
+
return function(string2) {
|
|
2883
|
+
string2 = toString$1(string2);
|
|
2884
|
+
var strSymbols = hasUnicode(string2) ? stringToArray(string2) : void 0;
|
|
2885
|
+
var chr = strSymbols ? strSymbols[0] : string2.charAt(0);
|
|
2886
|
+
var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string2.slice(1);
|
|
2887
|
+
return chr[methodName]() + trailing;
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
var _createCaseFirst = createCaseFirst$1;
|
|
2891
|
+
var createCaseFirst = _createCaseFirst;
|
|
2892
|
+
var upperFirst$1 = createCaseFirst("toUpperCase");
|
|
2893
|
+
var upperFirst_1 = upperFirst$1;
|
|
2894
|
+
var toString = toString_1, upperFirst = upperFirst_1;
|
|
2895
|
+
function capitalize$1(string2) {
|
|
2896
|
+
return upperFirst(toString(string2).toLowerCase());
|
|
2897
|
+
}
|
|
2898
|
+
var capitalize_1 = capitalize$1;
|
|
2899
|
+
var capitalize = capitalize_1, createCompounder = _createCompounder;
|
|
2900
|
+
var camelCase = createCompounder(function(result, word, index2) {
|
|
2901
|
+
word = word.toLowerCase();
|
|
2902
|
+
return result + (index2 ? capitalize(word) : word);
|
|
2903
|
+
});
|
|
2904
|
+
var camelCase_1 = camelCase;
|
|
2905
|
+
const camelCase$1 = /* @__PURE__ */ getDefaultExportFromCjs(camelCase_1);
|
|
2906
|
+
var baseAssignValue = _baseAssignValue, baseForOwn = _baseForOwn, baseIteratee = _baseIteratee;
|
|
2907
|
+
function mapKeys(object2, iteratee) {
|
|
2908
|
+
var result = {};
|
|
2909
|
+
iteratee = baseIteratee(iteratee);
|
|
2910
|
+
baseForOwn(object2, function(value, key, object3) {
|
|
2911
|
+
baseAssignValue(result, iteratee(value, key, object3), value);
|
|
2912
|
+
});
|
|
2913
|
+
return result;
|
|
2914
|
+
}
|
|
2915
|
+
var mapKeys_1 = mapKeys;
|
|
2916
|
+
const mapKeys$1 = /* @__PURE__ */ getDefaultExportFromCjs(mapKeys_1);
|
|
2917
|
+
var toposort$2 = { exports: {} };
|
|
2918
|
+
toposort$2.exports = function(edges) {
|
|
2534
2919
|
return toposort(uniqueNodes(edges), edges);
|
|
2535
2920
|
};
|
|
2536
|
-
toposort$
|
|
2921
|
+
toposort$2.exports.array = toposort;
|
|
2537
2922
|
function toposort(nodes, edges) {
|
|
2538
2923
|
var cursor = nodes.length, sorted = new Array(cursor), visited = {}, i = cursor, outgoingEdges = makeOutgoingEdges(edges), nodesHash = makeNodesHash(nodes);
|
|
2539
2924
|
edges.forEach(function(edge) {
|
|
@@ -2599,9 +2984,514 @@ function makeNodesHash(arr) {
|
|
|
2599
2984
|
}
|
|
2600
2985
|
return res;
|
|
2601
2986
|
}
|
|
2987
|
+
var toposortExports = toposort$2.exports;
|
|
2988
|
+
const toposort$1 = /* @__PURE__ */ getDefaultExportFromCjs(toposortExports);
|
|
2989
|
+
function sortFields(fields, excludes = []) {
|
|
2990
|
+
let edges = [];
|
|
2991
|
+
let nodes = [];
|
|
2992
|
+
function addNode(depPath, key) {
|
|
2993
|
+
var node = propertyExpr.split(depPath)[0];
|
|
2994
|
+
if (!~nodes.indexOf(node)) nodes.push(node);
|
|
2995
|
+
if (!~excludes.indexOf(`${key}-${node}`)) edges.push([key, node]);
|
|
2996
|
+
}
|
|
2997
|
+
for (const key in fields) if (has$1(fields, key)) {
|
|
2998
|
+
let value = fields[key];
|
|
2999
|
+
if (!~nodes.indexOf(key)) nodes.push(key);
|
|
3000
|
+
if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);
|
|
3001
|
+
else if (isSchema(value) && "deps" in value) value.deps.forEach((path) => addNode(path, key));
|
|
3002
|
+
}
|
|
3003
|
+
return toposort$1.array(nodes, edges).reverse();
|
|
3004
|
+
}
|
|
3005
|
+
function findIndex(arr, err) {
|
|
3006
|
+
let idx = Infinity;
|
|
3007
|
+
arr.some((key, ii) => {
|
|
3008
|
+
var _err$path;
|
|
3009
|
+
if (((_err$path = err.path) == null ? void 0 : _err$path.indexOf(key)) !== -1) {
|
|
3010
|
+
idx = ii;
|
|
3011
|
+
return true;
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3014
|
+
return idx;
|
|
3015
|
+
}
|
|
3016
|
+
function sortByKeyOrder(keys2) {
|
|
3017
|
+
return (a, b) => {
|
|
3018
|
+
return findIndex(keys2, a) - findIndex(keys2, b);
|
|
3019
|
+
};
|
|
3020
|
+
}
|
|
3021
|
+
function _extends$1() {
|
|
3022
|
+
_extends$1 = Object.assign || function(target) {
|
|
3023
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3024
|
+
var source = arguments[i];
|
|
3025
|
+
for (var key in source) {
|
|
3026
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3027
|
+
target[key] = source[key];
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
return target;
|
|
3032
|
+
};
|
|
3033
|
+
return _extends$1.apply(this, arguments);
|
|
3034
|
+
}
|
|
3035
|
+
let isObject = (obj) => Object.prototype.toString.call(obj) === "[object Object]";
|
|
3036
|
+
function unknown(ctx, value) {
|
|
3037
|
+
let known = Object.keys(ctx.fields);
|
|
3038
|
+
return Object.keys(value).filter((key) => known.indexOf(key) === -1);
|
|
3039
|
+
}
|
|
3040
|
+
const defaultSort = sortByKeyOrder([]);
|
|
3041
|
+
class ObjectSchema extends BaseSchema {
|
|
3042
|
+
constructor(spec) {
|
|
3043
|
+
super({
|
|
3044
|
+
type: "object"
|
|
3045
|
+
});
|
|
3046
|
+
this.fields = /* @__PURE__ */ Object.create(null);
|
|
3047
|
+
this._sortErrors = defaultSort;
|
|
3048
|
+
this._nodes = [];
|
|
3049
|
+
this._excludedEdges = [];
|
|
3050
|
+
this.withMutation(() => {
|
|
3051
|
+
this.transform(function coerce(value) {
|
|
3052
|
+
if (typeof value === "string") {
|
|
3053
|
+
try {
|
|
3054
|
+
value = JSON.parse(value);
|
|
3055
|
+
} catch (err) {
|
|
3056
|
+
value = null;
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
if (this.isType(value)) return value;
|
|
3060
|
+
return null;
|
|
3061
|
+
});
|
|
3062
|
+
if (spec) {
|
|
3063
|
+
this.shape(spec);
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
}
|
|
3067
|
+
_typeCheck(value) {
|
|
3068
|
+
return isObject(value) || typeof value === "function";
|
|
3069
|
+
}
|
|
3070
|
+
_cast(_value, options = {}) {
|
|
3071
|
+
var _options$stripUnknown;
|
|
3072
|
+
let value = super._cast(_value, options);
|
|
3073
|
+
if (value === void 0) return this.getDefault();
|
|
3074
|
+
if (!this._typeCheck(value)) return value;
|
|
3075
|
+
let fields = this.fields;
|
|
3076
|
+
let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
|
|
3077
|
+
let props = this._nodes.concat(Object.keys(value).filter((v) => this._nodes.indexOf(v) === -1));
|
|
3078
|
+
let intermediateValue = {};
|
|
3079
|
+
let innerOptions = _extends$1({}, options, {
|
|
3080
|
+
parent: intermediateValue,
|
|
3081
|
+
__validating: options.__validating || false
|
|
3082
|
+
});
|
|
3083
|
+
let isChanged = false;
|
|
3084
|
+
for (const prop of props) {
|
|
3085
|
+
let field = fields[prop];
|
|
3086
|
+
let exists = has$1(value, prop);
|
|
3087
|
+
if (field) {
|
|
3088
|
+
let fieldValue;
|
|
3089
|
+
let inputValue = value[prop];
|
|
3090
|
+
innerOptions.path = (options.path ? `${options.path}.` : "") + prop;
|
|
3091
|
+
field = field.resolve({
|
|
3092
|
+
value: inputValue,
|
|
3093
|
+
context: options.context,
|
|
3094
|
+
parent: intermediateValue
|
|
3095
|
+
});
|
|
3096
|
+
let fieldSpec = "spec" in field ? field.spec : void 0;
|
|
3097
|
+
let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
|
|
3098
|
+
if (fieldSpec == null ? void 0 : fieldSpec.strip) {
|
|
3099
|
+
isChanged = isChanged || prop in value;
|
|
3100
|
+
continue;
|
|
3101
|
+
}
|
|
3102
|
+
fieldValue = !options.__validating || !strict ? (
|
|
3103
|
+
// TODO: use _cast, this is double resolving
|
|
3104
|
+
field.cast(value[prop], innerOptions)
|
|
3105
|
+
) : value[prop];
|
|
3106
|
+
if (fieldValue !== void 0) {
|
|
3107
|
+
intermediateValue[prop] = fieldValue;
|
|
3108
|
+
}
|
|
3109
|
+
} else if (exists && !strip) {
|
|
3110
|
+
intermediateValue[prop] = value[prop];
|
|
3111
|
+
}
|
|
3112
|
+
if (intermediateValue[prop] !== value[prop]) {
|
|
3113
|
+
isChanged = true;
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
return isChanged ? intermediateValue : value;
|
|
3117
|
+
}
|
|
3118
|
+
_validate(_value, opts = {}, callback) {
|
|
3119
|
+
let errors = [];
|
|
3120
|
+
let {
|
|
3121
|
+
sync,
|
|
3122
|
+
from = [],
|
|
3123
|
+
originalValue = _value,
|
|
3124
|
+
abortEarly = this.spec.abortEarly,
|
|
3125
|
+
recursive = this.spec.recursive
|
|
3126
|
+
} = opts;
|
|
3127
|
+
from = [{
|
|
3128
|
+
schema: this,
|
|
3129
|
+
value: originalValue
|
|
3130
|
+
}, ...from];
|
|
3131
|
+
opts.__validating = true;
|
|
3132
|
+
opts.originalValue = originalValue;
|
|
3133
|
+
opts.from = from;
|
|
3134
|
+
super._validate(_value, opts, (err, value) => {
|
|
3135
|
+
if (err) {
|
|
3136
|
+
if (!ValidationError.isError(err) || abortEarly) {
|
|
3137
|
+
return void callback(err, value);
|
|
3138
|
+
}
|
|
3139
|
+
errors.push(err);
|
|
3140
|
+
}
|
|
3141
|
+
if (!recursive || !isObject(value)) {
|
|
3142
|
+
callback(errors[0] || null, value);
|
|
3143
|
+
return;
|
|
3144
|
+
}
|
|
3145
|
+
originalValue = originalValue || value;
|
|
3146
|
+
let tests = this._nodes.map((key) => (_, cb) => {
|
|
3147
|
+
let path = key.indexOf(".") === -1 ? (opts.path ? `${opts.path}.` : "") + key : `${opts.path || ""}["${key}"]`;
|
|
3148
|
+
let field = this.fields[key];
|
|
3149
|
+
if (field && "validate" in field) {
|
|
3150
|
+
field.validate(value[key], _extends$1({}, opts, {
|
|
3151
|
+
// @ts-ignore
|
|
3152
|
+
path,
|
|
3153
|
+
from,
|
|
3154
|
+
// inner fields are always strict:
|
|
3155
|
+
// 1. this isn't strict so the casting will also have cast inner values
|
|
3156
|
+
// 2. this is strict in which case the nested values weren't cast either
|
|
3157
|
+
strict: true,
|
|
3158
|
+
parent: value,
|
|
3159
|
+
originalValue: originalValue[key]
|
|
3160
|
+
}), cb);
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
cb(null);
|
|
3164
|
+
});
|
|
3165
|
+
runTests({
|
|
3166
|
+
tests,
|
|
3167
|
+
value,
|
|
3168
|
+
errors,
|
|
3169
|
+
endEarly: abortEarly,
|
|
3170
|
+
sort: this._sortErrors,
|
|
3171
|
+
path: opts.path
|
|
3172
|
+
}, callback);
|
|
3173
|
+
});
|
|
3174
|
+
}
|
|
3175
|
+
clone(spec) {
|
|
3176
|
+
const next = super.clone(spec);
|
|
3177
|
+
next.fields = _extends$1({}, this.fields);
|
|
3178
|
+
next._nodes = this._nodes;
|
|
3179
|
+
next._excludedEdges = this._excludedEdges;
|
|
3180
|
+
next._sortErrors = this._sortErrors;
|
|
3181
|
+
return next;
|
|
3182
|
+
}
|
|
3183
|
+
concat(schema) {
|
|
3184
|
+
let next = super.concat(schema);
|
|
3185
|
+
let nextFields = next.fields;
|
|
3186
|
+
for (let [field, schemaOrRef] of Object.entries(this.fields)) {
|
|
3187
|
+
const target = nextFields[field];
|
|
3188
|
+
if (target === void 0) {
|
|
3189
|
+
nextFields[field] = schemaOrRef;
|
|
3190
|
+
} else if (target instanceof BaseSchema && schemaOrRef instanceof BaseSchema) {
|
|
3191
|
+
nextFields[field] = schemaOrRef.concat(target);
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
return next.withMutation(() => next.shape(nextFields));
|
|
3195
|
+
}
|
|
3196
|
+
getDefaultFromShape() {
|
|
3197
|
+
let dft = {};
|
|
3198
|
+
this._nodes.forEach((key) => {
|
|
3199
|
+
const field = this.fields[key];
|
|
3200
|
+
dft[key] = "default" in field ? field.getDefault() : void 0;
|
|
3201
|
+
});
|
|
3202
|
+
return dft;
|
|
3203
|
+
}
|
|
3204
|
+
_getDefault() {
|
|
3205
|
+
if ("default" in this.spec) {
|
|
3206
|
+
return super._getDefault();
|
|
3207
|
+
}
|
|
3208
|
+
if (!this._nodes.length) {
|
|
3209
|
+
return void 0;
|
|
3210
|
+
}
|
|
3211
|
+
return this.getDefaultFromShape();
|
|
3212
|
+
}
|
|
3213
|
+
shape(additions, excludes = []) {
|
|
3214
|
+
let next = this.clone();
|
|
3215
|
+
let fields = Object.assign(next.fields, additions);
|
|
3216
|
+
next.fields = fields;
|
|
3217
|
+
next._sortErrors = sortByKeyOrder(Object.keys(fields));
|
|
3218
|
+
if (excludes.length) {
|
|
3219
|
+
if (!Array.isArray(excludes[0])) excludes = [excludes];
|
|
3220
|
+
let keys2 = excludes.map(([first, second]) => `${first}-${second}`);
|
|
3221
|
+
next._excludedEdges = next._excludedEdges.concat(keys2);
|
|
3222
|
+
}
|
|
3223
|
+
next._nodes = sortFields(fields, next._excludedEdges);
|
|
3224
|
+
return next;
|
|
3225
|
+
}
|
|
3226
|
+
pick(keys2) {
|
|
3227
|
+
const picked = {};
|
|
3228
|
+
for (const key of keys2) {
|
|
3229
|
+
if (this.fields[key]) picked[key] = this.fields[key];
|
|
3230
|
+
}
|
|
3231
|
+
return this.clone().withMutation((next) => {
|
|
3232
|
+
next.fields = {};
|
|
3233
|
+
return next.shape(picked);
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3236
|
+
omit(keys2) {
|
|
3237
|
+
const next = this.clone();
|
|
3238
|
+
const fields = next.fields;
|
|
3239
|
+
next.fields = {};
|
|
3240
|
+
for (const key of keys2) {
|
|
3241
|
+
delete fields[key];
|
|
3242
|
+
}
|
|
3243
|
+
return next.withMutation(() => next.shape(fields));
|
|
3244
|
+
}
|
|
3245
|
+
from(from, to, alias) {
|
|
3246
|
+
let fromGetter = propertyExpr.getter(from, true);
|
|
3247
|
+
return this.transform((obj) => {
|
|
3248
|
+
if (obj == null) return obj;
|
|
3249
|
+
let newObj = obj;
|
|
3250
|
+
if (has$1(obj, from)) {
|
|
3251
|
+
newObj = _extends$1({}, obj);
|
|
3252
|
+
if (!alias) delete newObj[from];
|
|
3253
|
+
newObj[to] = fromGetter(obj);
|
|
3254
|
+
}
|
|
3255
|
+
return newObj;
|
|
3256
|
+
});
|
|
3257
|
+
}
|
|
3258
|
+
noUnknown(noAllow = true, message = object.noUnknown) {
|
|
3259
|
+
if (typeof noAllow === "string") {
|
|
3260
|
+
message = noAllow;
|
|
3261
|
+
noAllow = true;
|
|
3262
|
+
}
|
|
3263
|
+
let next = this.test({
|
|
3264
|
+
name: "noUnknown",
|
|
3265
|
+
exclusive: true,
|
|
3266
|
+
message,
|
|
3267
|
+
test(value) {
|
|
3268
|
+
if (value == null) return true;
|
|
3269
|
+
const unknownKeys = unknown(this.schema, value);
|
|
3270
|
+
return !noAllow || unknownKeys.length === 0 || this.createError({
|
|
3271
|
+
params: {
|
|
3272
|
+
unknown: unknownKeys.join(", ")
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
});
|
|
3277
|
+
next.spec.noUnknown = noAllow;
|
|
3278
|
+
return next;
|
|
3279
|
+
}
|
|
3280
|
+
unknown(allow = true, message = object.noUnknown) {
|
|
3281
|
+
return this.noUnknown(!allow, message);
|
|
3282
|
+
}
|
|
3283
|
+
transformKeys(fn) {
|
|
3284
|
+
return this.transform((obj) => obj && mapKeys$1(obj, (_, key) => fn(key)));
|
|
3285
|
+
}
|
|
3286
|
+
camelCase() {
|
|
3287
|
+
return this.transformKeys(camelCase$1);
|
|
3288
|
+
}
|
|
3289
|
+
snakeCase() {
|
|
3290
|
+
return this.transformKeys(snakeCase$1);
|
|
3291
|
+
}
|
|
3292
|
+
constantCase() {
|
|
3293
|
+
return this.transformKeys((key) => snakeCase$1(key).toUpperCase());
|
|
3294
|
+
}
|
|
3295
|
+
describe() {
|
|
3296
|
+
let base = super.describe();
|
|
3297
|
+
base.fields = mapValues$1(this.fields, (value) => value.describe());
|
|
3298
|
+
return base;
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
function create$1(spec) {
|
|
3302
|
+
return new ObjectSchema(spec);
|
|
3303
|
+
}
|
|
3304
|
+
create$1.prototype = ObjectSchema.prototype;
|
|
3305
|
+
function _extends() {
|
|
3306
|
+
_extends = Object.assign || function(target) {
|
|
3307
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3308
|
+
var source = arguments[i];
|
|
3309
|
+
for (var key in source) {
|
|
3310
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3311
|
+
target[key] = source[key];
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
return target;
|
|
3316
|
+
};
|
|
3317
|
+
return _extends.apply(this, arguments);
|
|
3318
|
+
}
|
|
3319
|
+
function create(type) {
|
|
3320
|
+
return new ArraySchema(type);
|
|
3321
|
+
}
|
|
3322
|
+
class ArraySchema extends BaseSchema {
|
|
3323
|
+
constructor(type) {
|
|
3324
|
+
super({
|
|
3325
|
+
type: "array"
|
|
3326
|
+
});
|
|
3327
|
+
this.innerType = type;
|
|
3328
|
+
this.withMutation(() => {
|
|
3329
|
+
this.transform(function(values) {
|
|
3330
|
+
if (typeof values === "string") try {
|
|
3331
|
+
values = JSON.parse(values);
|
|
3332
|
+
} catch (err) {
|
|
3333
|
+
values = null;
|
|
3334
|
+
}
|
|
3335
|
+
return this.isType(values) ? values : null;
|
|
3336
|
+
});
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3339
|
+
_typeCheck(v) {
|
|
3340
|
+
return Array.isArray(v);
|
|
3341
|
+
}
|
|
3342
|
+
get _subType() {
|
|
3343
|
+
return this.innerType;
|
|
3344
|
+
}
|
|
3345
|
+
_cast(_value, _opts) {
|
|
3346
|
+
const value = super._cast(_value, _opts);
|
|
3347
|
+
if (!this._typeCheck(value) || !this.innerType) return value;
|
|
3348
|
+
let isChanged = false;
|
|
3349
|
+
const castArray = value.map((v, idx) => {
|
|
3350
|
+
const castElement = this.innerType.cast(v, _extends({}, _opts, {
|
|
3351
|
+
path: `${_opts.path || ""}[${idx}]`
|
|
3352
|
+
}));
|
|
3353
|
+
if (castElement !== v) {
|
|
3354
|
+
isChanged = true;
|
|
3355
|
+
}
|
|
3356
|
+
return castElement;
|
|
3357
|
+
});
|
|
3358
|
+
return isChanged ? castArray : value;
|
|
3359
|
+
}
|
|
3360
|
+
_validate(_value, options = {}, callback) {
|
|
3361
|
+
var _options$abortEarly, _options$recursive;
|
|
3362
|
+
let errors = [];
|
|
3363
|
+
options.sync;
|
|
3364
|
+
let path = options.path;
|
|
3365
|
+
let innerType = this.innerType;
|
|
3366
|
+
let endEarly = (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly;
|
|
3367
|
+
let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive;
|
|
3368
|
+
let originalValue = options.originalValue != null ? options.originalValue : _value;
|
|
3369
|
+
super._validate(_value, options, (err, value) => {
|
|
3370
|
+
if (err) {
|
|
3371
|
+
if (!ValidationError.isError(err) || endEarly) {
|
|
3372
|
+
return void callback(err, value);
|
|
3373
|
+
}
|
|
3374
|
+
errors.push(err);
|
|
3375
|
+
}
|
|
3376
|
+
if (!recursive || !innerType || !this._typeCheck(value)) {
|
|
3377
|
+
callback(errors[0] || null, value);
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
originalValue = originalValue || value;
|
|
3381
|
+
let tests = new Array(value.length);
|
|
3382
|
+
for (let idx = 0; idx < value.length; idx++) {
|
|
3383
|
+
let item = value[idx];
|
|
3384
|
+
let path2 = `${options.path || ""}[${idx}]`;
|
|
3385
|
+
let innerOptions = _extends({}, options, {
|
|
3386
|
+
path: path2,
|
|
3387
|
+
strict: true,
|
|
3388
|
+
parent: value,
|
|
3389
|
+
index: idx,
|
|
3390
|
+
originalValue: originalValue[idx]
|
|
3391
|
+
});
|
|
3392
|
+
tests[idx] = (_, cb) => innerType.validate(item, innerOptions, cb);
|
|
3393
|
+
}
|
|
3394
|
+
runTests({
|
|
3395
|
+
path,
|
|
3396
|
+
value,
|
|
3397
|
+
errors,
|
|
3398
|
+
endEarly,
|
|
3399
|
+
tests
|
|
3400
|
+
}, callback);
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
clone(spec) {
|
|
3404
|
+
const next = super.clone(spec);
|
|
3405
|
+
next.innerType = this.innerType;
|
|
3406
|
+
return next;
|
|
3407
|
+
}
|
|
3408
|
+
concat(schema) {
|
|
3409
|
+
let next = super.concat(schema);
|
|
3410
|
+
next.innerType = this.innerType;
|
|
3411
|
+
if (schema.innerType) next.innerType = next.innerType ? (
|
|
3412
|
+
// @ts-expect-error Lazy doesn't have concat()
|
|
3413
|
+
next.innerType.concat(schema.innerType)
|
|
3414
|
+
) : schema.innerType;
|
|
3415
|
+
return next;
|
|
3416
|
+
}
|
|
3417
|
+
of(schema) {
|
|
3418
|
+
let next = this.clone();
|
|
3419
|
+
if (!isSchema(schema)) throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + printValue(schema));
|
|
3420
|
+
next.innerType = schema;
|
|
3421
|
+
return next;
|
|
3422
|
+
}
|
|
3423
|
+
length(length, message = array.length) {
|
|
3424
|
+
return this.test({
|
|
3425
|
+
message,
|
|
3426
|
+
name: "length",
|
|
3427
|
+
exclusive: true,
|
|
3428
|
+
params: {
|
|
3429
|
+
length
|
|
3430
|
+
},
|
|
3431
|
+
test(value) {
|
|
3432
|
+
return isAbsent(value) || value.length === this.resolve(length);
|
|
3433
|
+
}
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3436
|
+
min(min, message) {
|
|
3437
|
+
message = message || array.min;
|
|
3438
|
+
return this.test({
|
|
3439
|
+
message,
|
|
3440
|
+
name: "min",
|
|
3441
|
+
exclusive: true,
|
|
3442
|
+
params: {
|
|
3443
|
+
min
|
|
3444
|
+
},
|
|
3445
|
+
// FIXME(ts): Array<typeof T>
|
|
3446
|
+
test(value) {
|
|
3447
|
+
return isAbsent(value) || value.length >= this.resolve(min);
|
|
3448
|
+
}
|
|
3449
|
+
});
|
|
3450
|
+
}
|
|
3451
|
+
max(max, message) {
|
|
3452
|
+
message = message || array.max;
|
|
3453
|
+
return this.test({
|
|
3454
|
+
message,
|
|
3455
|
+
name: "max",
|
|
3456
|
+
exclusive: true,
|
|
3457
|
+
params: {
|
|
3458
|
+
max
|
|
3459
|
+
},
|
|
3460
|
+
test(value) {
|
|
3461
|
+
return isAbsent(value) || value.length <= this.resolve(max);
|
|
3462
|
+
}
|
|
3463
|
+
});
|
|
3464
|
+
}
|
|
3465
|
+
ensure() {
|
|
3466
|
+
return this.default(() => []).transform((val, original) => {
|
|
3467
|
+
if (this._typeCheck(val)) return val;
|
|
3468
|
+
return original == null ? [] : [].concat(original);
|
|
3469
|
+
});
|
|
3470
|
+
}
|
|
3471
|
+
compact(rejector) {
|
|
3472
|
+
let reject = !rejector ? (v) => !!v : (v, i, a) => !rejector(v, i, a);
|
|
3473
|
+
return this.transform((values) => values != null ? values.filter(reject) : values);
|
|
3474
|
+
}
|
|
3475
|
+
describe() {
|
|
3476
|
+
let base = super.describe();
|
|
3477
|
+
if (this.innerType) base.innerType = this.innerType.describe();
|
|
3478
|
+
return base;
|
|
3479
|
+
}
|
|
3480
|
+
nullable(isNullable = true) {
|
|
3481
|
+
return super.nullable(isNullable);
|
|
3482
|
+
}
|
|
3483
|
+
defined() {
|
|
3484
|
+
return super.defined();
|
|
3485
|
+
}
|
|
3486
|
+
required(msg) {
|
|
3487
|
+
return super.required(msg);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
create.prototype = ArraySchema.prototype;
|
|
2602
3491
|
const PLUGIN_ID = "littlebox-strapi-suite";
|
|
2603
3492
|
const SLUG_LANGUAGE_STRATEGY = "language";
|
|
2604
3493
|
const SLUG_CONTENT_STRATEGY = "content";
|
|
3494
|
+
const AI_TRANSLATION_DEFAULT_MODEL = "gpt-4o";
|
|
2605
3495
|
const config = {
|
|
2606
3496
|
pluginId: PLUGIN_ID,
|
|
2607
3497
|
uuid: {
|
|
@@ -2894,6 +3784,32 @@ class TranslationGatewayHttp {
|
|
|
2894
3784
|
async edit(uid, params) {
|
|
2895
3785
|
return this.httpClient.put(`/${config.pluginId}/admin/translations/${uid}`, params);
|
|
2896
3786
|
}
|
|
3787
|
+
async aiTranslate(params) {
|
|
3788
|
+
return this.httpClient.post(
|
|
3789
|
+
`/${config.pluginId}/admin/translations/actions/ai-translate`,
|
|
3790
|
+
params
|
|
3791
|
+
);
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
class DocumentGatewayHttp {
|
|
3795
|
+
httpClient;
|
|
3796
|
+
constructor() {
|
|
3797
|
+
this.httpClient = Registry.getInstance().inject("httpClient");
|
|
3798
|
+
}
|
|
3799
|
+
async fetch({ collectionType, model, documentId, params }) {
|
|
3800
|
+
const path = documentId ? `/content-manager/${collectionType}/${model}/${documentId}` : `/content-manager/${collectionType}/${model}`;
|
|
3801
|
+
const response = await this.httpClient.get(`${path}${objectToQueryString(params)}`);
|
|
3802
|
+
return response ? response.data : null;
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
class AiGatewayHttp {
|
|
3806
|
+
httpClient;
|
|
3807
|
+
constructor() {
|
|
3808
|
+
this.httpClient = Registry.getInstance().inject("httpClient");
|
|
3809
|
+
}
|
|
3810
|
+
async translateStrings(input) {
|
|
3811
|
+
return this.httpClient.post(`/${config.pluginId}/admin/ai/strings`, input);
|
|
3812
|
+
}
|
|
2897
3813
|
}
|
|
2898
3814
|
class Mediator {
|
|
2899
3815
|
handlers;
|
|
@@ -3019,21 +3935,21 @@ const DangerModal = ({ open, title, text, button }) => {
|
|
|
3019
3935
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant: "danger-light", children: button }) }) })
|
|
3020
3936
|
] }) }) });
|
|
3021
3937
|
};
|
|
3022
|
-
const PageAttributesBox = ({ document }) => {
|
|
3938
|
+
const PageAttributesBox = ({ document: document2 }) => {
|
|
3023
3939
|
const { formatMessage } = reactIntl.useIntl();
|
|
3024
3940
|
const location = reactRouterDom.useLocation();
|
|
3025
3941
|
const { form } = admin.unstable_useContentManagerContext();
|
|
3026
|
-
const [selectedParent, setSelectedParent] =
|
|
3027
|
-
const [selectedTemplate, setSelectedTemplate] =
|
|
3028
|
-
const [selectedPriority, setSelectedPriority] =
|
|
3029
|
-
const [selectedFrequency, setSelectedFrequency] =
|
|
3030
|
-
const [parents, setParents] =
|
|
3031
|
-
const [templates, setTemplates] =
|
|
3032
|
-
const [attributes, setAttributes] =
|
|
3033
|
-
const [appSettings, setAppSettings] =
|
|
3034
|
-
const [showDangerModal, setShowDangerModal] =
|
|
3035
|
-
const [showBox, setShowBox] =
|
|
3036
|
-
const [currentLocale, setCurrentLocale] =
|
|
3942
|
+
const [selectedParent, setSelectedParent] = React__namespace.default.useState(-1);
|
|
3943
|
+
const [selectedTemplate, setSelectedTemplate] = React__namespace.default.useState(-1);
|
|
3944
|
+
const [selectedPriority, setSelectedPriority] = React__namespace.default.useState("no-priority");
|
|
3945
|
+
const [selectedFrequency, setSelectedFrequency] = React__namespace.default.useState("no-frequency");
|
|
3946
|
+
const [parents, setParents] = React__namespace.default.useState([]);
|
|
3947
|
+
const [templates, setTemplates] = React__namespace.default.useState([]);
|
|
3948
|
+
const [attributes, setAttributes] = React__namespace.default.useState();
|
|
3949
|
+
const [appSettings, setAppSettings] = React__namespace.default.useState();
|
|
3950
|
+
const [showDangerModal, setShowDangerModal] = React__namespace.default.useState(false);
|
|
3951
|
+
const [showBox, setShowBox] = React__namespace.default.useState(false);
|
|
3952
|
+
const [currentLocale, setCurrentLocale] = React__namespace.default.useState(getCurrentLocate());
|
|
3037
3953
|
function getCurrentLocate() {
|
|
3038
3954
|
const queryString = window.location.search.split("?")[1];
|
|
3039
3955
|
const searchParams = new URLSearchParams(queryString);
|
|
@@ -3068,13 +3984,13 @@ const PageAttributesBox = ({ document }) => {
|
|
|
3068
3984
|
form.onChange(mockEvent);
|
|
3069
3985
|
}
|
|
3070
3986
|
async function fectchAttributes() {
|
|
3071
|
-
if (
|
|
3987
|
+
if (document2 && document2.documentId) {
|
|
3072
3988
|
const fetchDocumentAttributes$1 = new fetchDocumentAttributes();
|
|
3073
3989
|
const outputFetchDocumentAttributes = await fetchDocumentAttributes$1.execute(
|
|
3074
|
-
|
|
3990
|
+
document2.documentId,
|
|
3075
3991
|
{
|
|
3076
3992
|
locale: getCurrentLocate(),
|
|
3077
|
-
state:
|
|
3993
|
+
state: document2.publishedAt ? "published" : "draft"
|
|
3078
3994
|
}
|
|
3079
3995
|
);
|
|
3080
3996
|
setAttributes(outputFetchDocumentAttributes);
|
|
@@ -3085,7 +4001,7 @@ const PageAttributesBox = ({ document }) => {
|
|
|
3085
4001
|
const outputFetchSlugs = await fetchSlugs.execute({ locale: getCurrentLocate() });
|
|
3086
4002
|
const filteredParents = [];
|
|
3087
4003
|
outputFetchSlugs.forEach((parent) => {
|
|
3088
|
-
if (!
|
|
4004
|
+
if (!document2 || parent.contentId !== document2.documentId) {
|
|
3089
4005
|
filteredParents.push(parent);
|
|
3090
4006
|
}
|
|
3091
4007
|
});
|
|
@@ -3118,7 +4034,7 @@ const PageAttributesBox = ({ document }) => {
|
|
|
3118
4034
|
const settings = await fetchModuleSettings.execute("attribute");
|
|
3119
4035
|
setAppSettings(settings);
|
|
3120
4036
|
}
|
|
3121
|
-
|
|
4037
|
+
React__namespace.default.useEffect(() => {
|
|
3122
4038
|
if (attributes) {
|
|
3123
4039
|
if (parents) {
|
|
3124
4040
|
const index2 = parents.findIndex(
|
|
@@ -3138,19 +4054,19 @@ const PageAttributesBox = ({ document }) => {
|
|
|
3138
4054
|
setSelectedFrequency(attributes.frequency || "no-frequency");
|
|
3139
4055
|
}
|
|
3140
4056
|
}, [templates, parents, attributes]);
|
|
3141
|
-
|
|
4057
|
+
React__namespace.default.useEffect(() => {
|
|
3142
4058
|
if (parents.length > 0) {
|
|
3143
4059
|
const value = selectedParent === -1 ? "" : buildPath(selectedParent);
|
|
3144
4060
|
const mediator = Registry.getInstance().inject("mediator");
|
|
3145
4061
|
mediator.notify(new PageAttributeUpdated({ parentSlug: value }));
|
|
3146
4062
|
}
|
|
3147
4063
|
}, [selectedParent, parents]);
|
|
3148
|
-
|
|
4064
|
+
React__namespace.default.useEffect(() => {
|
|
3149
4065
|
fectchAttributes();
|
|
3150
4066
|
fetchTemplates$1();
|
|
3151
4067
|
fetchParents();
|
|
3152
4068
|
}, [location]);
|
|
3153
|
-
|
|
4069
|
+
React__namespace.default.useEffect(() => {
|
|
3154
4070
|
const subscription = Registry.getInstance().inject("mediator").subscribe(DocumentCustomFieldStarted.id, () => {
|
|
3155
4071
|
setShowBox(true);
|
|
3156
4072
|
});
|
|
@@ -3296,7 +4212,1287 @@ const PageAttributesBox = ({ document }) => {
|
|
|
3296
4212
|
] })
|
|
3297
4213
|
};
|
|
3298
4214
|
};
|
|
3299
|
-
|
|
4215
|
+
class FetchLocales {
|
|
4216
|
+
localeGateway;
|
|
4217
|
+
constructor() {
|
|
4218
|
+
this.localeGateway = Registry.getInstance().inject("localeGateway");
|
|
4219
|
+
}
|
|
4220
|
+
async execute() {
|
|
4221
|
+
const result = await this.localeGateway.fetch();
|
|
4222
|
+
const output = result.map((data) => ({
|
|
4223
|
+
id: data.id,
|
|
4224
|
+
code: data.code,
|
|
4225
|
+
name: data.name,
|
|
4226
|
+
isDefault: data.isDefault
|
|
4227
|
+
}));
|
|
4228
|
+
return output;
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
class AbstractSlugHandler {
|
|
4232
|
+
nextHandler = null;
|
|
4233
|
+
setNext(handler) {
|
|
4234
|
+
this.nextHandler = handler;
|
|
4235
|
+
return handler;
|
|
4236
|
+
}
|
|
4237
|
+
handle(text) {
|
|
4238
|
+
if (this.nextHandler) {
|
|
4239
|
+
return this.nextHandler.handle(this.process(text));
|
|
4240
|
+
}
|
|
4241
|
+
return this.process(text);
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
class LowercaseHandler extends AbstractSlugHandler {
|
|
4245
|
+
process(text) {
|
|
4246
|
+
return text.toLowerCase();
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
class AccentRemovalHandler extends AbstractSlugHandler {
|
|
4250
|
+
process(text) {
|
|
4251
|
+
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
class SpecialCharsHandler extends AbstractSlugHandler {
|
|
4255
|
+
process(text) {
|
|
4256
|
+
return text.replace(/[^a-z0-9-]+/g, "-");
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
class TrimHyphensHandler extends AbstractSlugHandler {
|
|
4260
|
+
process(text) {
|
|
4261
|
+
return text.replace(/^-+|-+$/g, "");
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
class MultipleHyphensHandler extends AbstractSlugHandler {
|
|
4265
|
+
process(text) {
|
|
4266
|
+
return text.replace(/-+/g, "-");
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
class LengthLimitHandler extends AbstractSlugHandler {
|
|
4270
|
+
maxLength;
|
|
4271
|
+
constructor(maxLength = 100) {
|
|
4272
|
+
super();
|
|
4273
|
+
this.maxLength = maxLength;
|
|
4274
|
+
}
|
|
4275
|
+
process(text) {
|
|
4276
|
+
if (text.length > this.maxLength) {
|
|
4277
|
+
const truncated = text.substring(0, this.maxLength);
|
|
4278
|
+
return truncated.replace(/-+$/g, "");
|
|
4279
|
+
}
|
|
4280
|
+
return text;
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
const convertToSlug = (text, maxLength = 100) => {
|
|
4284
|
+
if (!text) return "";
|
|
4285
|
+
const chain = new LowercaseHandler();
|
|
4286
|
+
const accentHandler = new AccentRemovalHandler();
|
|
4287
|
+
const specialCharsHandler = new SpecialCharsHandler();
|
|
4288
|
+
const trimHandler = new TrimHyphensHandler();
|
|
4289
|
+
const multipleHyphensHandler = new MultipleHyphensHandler();
|
|
4290
|
+
const lengthHandler = new LengthLimitHandler(maxLength);
|
|
4291
|
+
chain.setNext(accentHandler).setNext(specialCharsHandler).setNext(trimHandler).setNext(multipleHyphensHandler).setNext(lengthHandler);
|
|
4292
|
+
return chain.handle(text);
|
|
4293
|
+
};
|
|
4294
|
+
const SLUG_CUSTOM_FIELD = "plugin::littlebox-strapi-suite.ltbslug";
|
|
4295
|
+
const TEXT_TYPES = ["string", "text", "richtext"];
|
|
4296
|
+
const URL_PATTERN = /^(https?:\/\/|\/|mailto:|tel:)\S*$/i;
|
|
4297
|
+
function isFilled(value) {
|
|
4298
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
4299
|
+
}
|
|
4300
|
+
function isTranslatableText(value) {
|
|
4301
|
+
return isFilled(value) && !URL_PATTERN.test(value.trim());
|
|
4302
|
+
}
|
|
4303
|
+
function isLocalized(attribute) {
|
|
4304
|
+
return attribute?.pluginOptions?.i18n?.localized !== false;
|
|
4305
|
+
}
|
|
4306
|
+
function isSlug(attribute) {
|
|
4307
|
+
return attribute?.customField === SLUG_CUSTOM_FIELD || attribute?.type === "uid";
|
|
4308
|
+
}
|
|
4309
|
+
function join(path, segment) {
|
|
4310
|
+
return path ? `${path}.${segment}` : String(segment);
|
|
4311
|
+
}
|
|
4312
|
+
function collectBlocks(nodes, source, path, fields) {
|
|
4313
|
+
if (!Array.isArray(nodes) || !Array.isArray(source)) return;
|
|
4314
|
+
nodes.forEach((node, index2) => {
|
|
4315
|
+
const sourceNode = source[index2];
|
|
4316
|
+
if (!node || !sourceNode) return;
|
|
4317
|
+
if (isTranslatableText(sourceNode.text) && typeof node.text === "string") {
|
|
4318
|
+
fields.push({
|
|
4319
|
+
path: join(path, `${index2}.text`),
|
|
4320
|
+
value: sourceNode.text,
|
|
4321
|
+
current: node.text,
|
|
4322
|
+
kind: "text"
|
|
4323
|
+
});
|
|
4324
|
+
}
|
|
4325
|
+
collectBlocks(node.children, sourceNode.children, join(path, `${index2}.children`), fields);
|
|
4326
|
+
});
|
|
4327
|
+
}
|
|
4328
|
+
function collectTranslatableFields(attributes, components, target, source, basePath = "") {
|
|
4329
|
+
const fields = [];
|
|
4330
|
+
if (!attributes || !target || !source) return fields;
|
|
4331
|
+
for (const [name, attribute] of Object.entries(attributes)) {
|
|
4332
|
+
if (!isLocalized(attribute)) continue;
|
|
4333
|
+
const path = join(basePath, name);
|
|
4334
|
+
const targetValue = target[name];
|
|
4335
|
+
const sourceValue = source[name];
|
|
4336
|
+
if (isSlug(attribute)) {
|
|
4337
|
+
if (isFilled(sourceValue) && typeof targetValue === "string") {
|
|
4338
|
+
fields.push({ path, value: sourceValue, current: targetValue, kind: "slug" });
|
|
4339
|
+
}
|
|
4340
|
+
continue;
|
|
4341
|
+
}
|
|
4342
|
+
if (TEXT_TYPES.includes(attribute.type)) {
|
|
4343
|
+
if (isTranslatableText(sourceValue) && typeof targetValue === "string") {
|
|
4344
|
+
fields.push({ path, value: sourceValue, current: targetValue, kind: "text" });
|
|
4345
|
+
}
|
|
4346
|
+
continue;
|
|
4347
|
+
}
|
|
4348
|
+
if (attribute.type === "blocks") {
|
|
4349
|
+
collectBlocks(targetValue, sourceValue, path, fields);
|
|
4350
|
+
continue;
|
|
4351
|
+
}
|
|
4352
|
+
if (attribute.type === "component") {
|
|
4353
|
+
const schema = components[attribute.component];
|
|
4354
|
+
if (!schema) continue;
|
|
4355
|
+
if (attribute.repeatable) {
|
|
4356
|
+
if (!Array.isArray(targetValue) || !Array.isArray(sourceValue)) continue;
|
|
4357
|
+
targetValue.forEach((entry, index2) => {
|
|
4358
|
+
fields.push(
|
|
4359
|
+
...collectTranslatableFields(
|
|
4360
|
+
schema.attributes,
|
|
4361
|
+
components,
|
|
4362
|
+
entry,
|
|
4363
|
+
sourceValue[index2],
|
|
4364
|
+
join(path, index2)
|
|
4365
|
+
)
|
|
4366
|
+
);
|
|
4367
|
+
});
|
|
4368
|
+
continue;
|
|
4369
|
+
}
|
|
4370
|
+
fields.push(
|
|
4371
|
+
...collectTranslatableFields(schema.attributes, components, targetValue, sourceValue, path)
|
|
4372
|
+
);
|
|
4373
|
+
continue;
|
|
4374
|
+
}
|
|
4375
|
+
if (attribute.type === "dynamiczone") {
|
|
4376
|
+
if (!Array.isArray(targetValue) || !Array.isArray(sourceValue)) continue;
|
|
4377
|
+
targetValue.forEach((entry, index2) => {
|
|
4378
|
+
const sourceEntry = sourceValue[index2];
|
|
4379
|
+
if (!entry || !sourceEntry) return;
|
|
4380
|
+
if (entry.__component !== sourceEntry.__component) return;
|
|
4381
|
+
const schema = components[entry.__component];
|
|
4382
|
+
if (!schema) return;
|
|
4383
|
+
fields.push(
|
|
4384
|
+
...collectTranslatableFields(
|
|
4385
|
+
schema.attributes,
|
|
4386
|
+
components,
|
|
4387
|
+
entry,
|
|
4388
|
+
sourceEntry,
|
|
4389
|
+
join(path, index2)
|
|
4390
|
+
)
|
|
4391
|
+
);
|
|
4392
|
+
});
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
return fields;
|
|
4396
|
+
}
|
|
4397
|
+
function countTranslatableFields(attributes, components, source) {
|
|
4398
|
+
return collectTranslatableFields(attributes, components, source, source).length;
|
|
4399
|
+
}
|
|
4400
|
+
class TranslateDocument {
|
|
4401
|
+
documentGateway;
|
|
4402
|
+
aiGateway;
|
|
4403
|
+
constructor() {
|
|
4404
|
+
this.documentGateway = Registry.getInstance().inject("documentGateway");
|
|
4405
|
+
this.aiGateway = Registry.getInstance().inject("aiGateway");
|
|
4406
|
+
}
|
|
4407
|
+
async execute(input) {
|
|
4408
|
+
const source = await this.documentGateway.fetch({
|
|
4409
|
+
collectionType: input.collectionType,
|
|
4410
|
+
model: input.model,
|
|
4411
|
+
documentId: input.documentId,
|
|
4412
|
+
params: { locale: input.sourceLocale, status: input.status }
|
|
4413
|
+
});
|
|
4414
|
+
const total = source ? countTranslatableFields(input.attributes, input.components, source) : 0;
|
|
4415
|
+
if (total === 0) {
|
|
4416
|
+
return {
|
|
4417
|
+
results: [],
|
|
4418
|
+
translated: 0,
|
|
4419
|
+
skipped: 0,
|
|
4420
|
+
unmatched: 0,
|
|
4421
|
+
failed: 0,
|
|
4422
|
+
errors: ["no-source"]
|
|
4423
|
+
};
|
|
4424
|
+
}
|
|
4425
|
+
const matched = collectTranslatableFields(
|
|
4426
|
+
input.attributes,
|
|
4427
|
+
input.components,
|
|
4428
|
+
input.values,
|
|
4429
|
+
source
|
|
4430
|
+
);
|
|
4431
|
+
const unmatched = Math.max(0, total - matched.length);
|
|
4432
|
+
const pending = input.overwrite ? matched : matched.filter((field) => field.current.trim().length === 0);
|
|
4433
|
+
const skipped = matched.length - pending.length;
|
|
4434
|
+
if (pending.length === 0) {
|
|
4435
|
+
return { results: [], translated: 0, skipped, unmatched, failed: 0, errors: [] };
|
|
4436
|
+
}
|
|
4437
|
+
const strings = pending.reduce((acc, field, index2) => {
|
|
4438
|
+
acc[String(index2)] = field.kind === "slug" ? field.value.replace(/-/g, " ") : field.value;
|
|
4439
|
+
return acc;
|
|
4440
|
+
}, {});
|
|
4441
|
+
const output = await this.aiGateway.translateStrings({
|
|
4442
|
+
sourceLocale: input.sourceLocale,
|
|
4443
|
+
targetLocale: input.targetLocale,
|
|
4444
|
+
strings
|
|
4445
|
+
});
|
|
4446
|
+
const results = [];
|
|
4447
|
+
pending.forEach((field, index2) => {
|
|
4448
|
+
const translation = output.translations[String(index2)];
|
|
4449
|
+
if (typeof translation !== "string" || translation.trim().length === 0) return;
|
|
4450
|
+
results.push({
|
|
4451
|
+
path: field.path,
|
|
4452
|
+
value: field.kind === "slug" ? convertToSlug(translation) : translation,
|
|
4453
|
+
kind: field.kind
|
|
4454
|
+
});
|
|
4455
|
+
});
|
|
4456
|
+
return {
|
|
4457
|
+
results,
|
|
4458
|
+
translated: results.length,
|
|
4459
|
+
skipped,
|
|
4460
|
+
unmatched,
|
|
4461
|
+
failed: output.failed,
|
|
4462
|
+
errors: output.errors
|
|
4463
|
+
};
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
const BoxInput = styled__default.default(designSystem.Box)`
|
|
4467
|
+
flex: 1;
|
|
4468
|
+
display: flex;
|
|
4469
|
+
width: 100%;
|
|
4470
|
+
flex-direction: column;
|
|
4471
|
+
& > div {
|
|
4472
|
+
width: 100%;
|
|
4473
|
+
}
|
|
4474
|
+
`;
|
|
4475
|
+
const DocumentTranslateModal = ({ open, locales, targetLocale, translate, close }) => {
|
|
4476
|
+
const [module2] = React.useState(config.uuid.modules.translation);
|
|
4477
|
+
const [hidden, setHidden] = React.useState(true);
|
|
4478
|
+
const [sourceLocale, setSourceLocale] = React.useState();
|
|
4479
|
+
const [overwrite, setOverwrite] = React.useState(true);
|
|
4480
|
+
const [translateInProgress, setTranslateInProgress] = React.useState(false);
|
|
4481
|
+
const [result, setResult] = React.useState();
|
|
4482
|
+
const [error, setError] = React.useState("");
|
|
4483
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
4484
|
+
const sources = locales.filter(
|
|
4485
|
+
(locale) => locale.code !== targetLocale?.code
|
|
4486
|
+
);
|
|
4487
|
+
async function run() {
|
|
4488
|
+
if (translateInProgress || !sourceLocale) return;
|
|
4489
|
+
setTranslateInProgress(true);
|
|
4490
|
+
setResult(void 0);
|
|
4491
|
+
setError("");
|
|
4492
|
+
try {
|
|
4493
|
+
const output = await translate(sourceLocale, overwrite);
|
|
4494
|
+
if (output.errors.includes("no-source")) {
|
|
4495
|
+
setError(
|
|
4496
|
+
formatMessage({
|
|
4497
|
+
id: getTranslation(`module.${module2}.panel.ai.error.no-source`),
|
|
4498
|
+
defaultMessage: "This entry does not exist yet in the language you picked as the base"
|
|
4499
|
+
})
|
|
4500
|
+
);
|
|
4501
|
+
} else {
|
|
4502
|
+
setResult(output);
|
|
4503
|
+
}
|
|
4504
|
+
} catch (e) {
|
|
4505
|
+
setError(
|
|
4506
|
+
e?.response?.data?.error?.message || e?.message || formatMessage({
|
|
4507
|
+
id: getTranslation(`module.${module2}.modal.ai.error`),
|
|
4508
|
+
defaultMessage: "The translation request failed"
|
|
4509
|
+
})
|
|
4510
|
+
);
|
|
4511
|
+
}
|
|
4512
|
+
setTranslateInProgress(false);
|
|
4513
|
+
}
|
|
4514
|
+
function handleClose() {
|
|
4515
|
+
if (translateInProgress) return;
|
|
4516
|
+
setResult(void 0);
|
|
4517
|
+
setError("");
|
|
4518
|
+
close();
|
|
4519
|
+
}
|
|
4520
|
+
React.useEffect(() => {
|
|
4521
|
+
if (!open) {
|
|
4522
|
+
setHidden(true);
|
|
4523
|
+
return;
|
|
4524
|
+
}
|
|
4525
|
+
setSourceLocale(sources[0]?.code);
|
|
4526
|
+
setOverwrite(true);
|
|
4527
|
+
setResult(void 0);
|
|
4528
|
+
setError("");
|
|
4529
|
+
setHidden(false);
|
|
4530
|
+
}, [open]);
|
|
4531
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !hidden && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { defaultOpen: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
|
|
4532
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { style: { textAlign: "left" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { style: { width: "100%", justifyContent: "space-between" }, children: [
|
|
4533
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
|
|
4534
|
+
id: getTranslation(`module.${module2}.panel.ai.title`),
|
|
4535
|
+
defaultMessage: "Translate with AI"
|
|
4536
|
+
}) }),
|
|
4537
|
+
!translateInProgress && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4538
|
+
designSystem.IconButton,
|
|
4539
|
+
{
|
|
4540
|
+
variant: "tertiary",
|
|
4541
|
+
onClick: handleClose,
|
|
4542
|
+
label: "Close",
|
|
4543
|
+
borderWidth: 0,
|
|
4544
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {})
|
|
4545
|
+
}
|
|
4546
|
+
)
|
|
4547
|
+
] }) }),
|
|
4548
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { display: "flex", flexDirection: "column", width: "100%" }, children: [
|
|
4549
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", style: { paddingBottom: "5px" }, children: formatMessage({
|
|
4550
|
+
id: getTranslation(`module.${module2}.modal.ai.input.source.title`),
|
|
4551
|
+
defaultMessage: "Base language"
|
|
4552
|
+
}) }),
|
|
4553
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4554
|
+
designSystem.Typography,
|
|
4555
|
+
{
|
|
4556
|
+
variant: "pi",
|
|
4557
|
+
style: { paddingBottom: "5px", color: "#a5a5ba", display: "flex" },
|
|
4558
|
+
children: formatMessage(
|
|
4559
|
+
{
|
|
4560
|
+
id: getTranslation(`module.${module2}.panel.ai.input.source.description`),
|
|
4561
|
+
defaultMessage: "This entry is translated into {target} from the language you pick here"
|
|
4562
|
+
},
|
|
4563
|
+
{ target: targetLocale?.name || "" }
|
|
4564
|
+
)
|
|
4565
|
+
}
|
|
4566
|
+
),
|
|
4567
|
+
/* @__PURE__ */ jsxRuntime.jsx(BoxInput, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4568
|
+
designSystem.SingleSelect,
|
|
4569
|
+
{
|
|
4570
|
+
onChange: (value) => setSourceLocale(value),
|
|
4571
|
+
value: sourceLocale,
|
|
4572
|
+
disabled: translateInProgress,
|
|
4573
|
+
children: sources.map((locale, index2) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, index2))
|
|
4574
|
+
}
|
|
4575
|
+
) }),
|
|
4576
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", style: { paddingBottom: "5px", paddingTop: "24px" }, children: formatMessage({
|
|
4577
|
+
id: getTranslation(`module.${module2}.panel.ai.input.overwrite.title`),
|
|
4578
|
+
defaultMessage: "Overwrite fields that already have content"
|
|
4579
|
+
}) }),
|
|
4580
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4581
|
+
designSystem.Typography,
|
|
4582
|
+
{
|
|
4583
|
+
variant: "pi",
|
|
4584
|
+
style: { paddingBottom: "5px", color: "#a5a5ba", display: "flex" },
|
|
4585
|
+
children: formatMessage({
|
|
4586
|
+
id: getTranslation(`module.${module2}.panel.ai.input.overwrite.description`),
|
|
4587
|
+
defaultMessage: "When disabled only the empty fields are filled in"
|
|
4588
|
+
})
|
|
4589
|
+
}
|
|
4590
|
+
),
|
|
4591
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4592
|
+
designSystem.Toggle,
|
|
4593
|
+
{
|
|
4594
|
+
onLabel: "True",
|
|
4595
|
+
offLabel: "False",
|
|
4596
|
+
checked: overwrite,
|
|
4597
|
+
disabled: translateInProgress,
|
|
4598
|
+
onChange: (e) => setOverwrite(e.target.checked)
|
|
4599
|
+
}
|
|
4600
|
+
),
|
|
4601
|
+
translateInProgress && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4602
|
+
designSystem.Card,
|
|
4603
|
+
{
|
|
4604
|
+
shadow: false,
|
|
4605
|
+
style: {
|
|
4606
|
+
marginTop: "20px",
|
|
4607
|
+
padding: "10px",
|
|
4608
|
+
display: "flex",
|
|
4609
|
+
alignItems: "center"
|
|
4610
|
+
},
|
|
4611
|
+
children: [
|
|
4612
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true }),
|
|
4613
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4614
|
+
designSystem.Typography,
|
|
4615
|
+
{
|
|
4616
|
+
variant: "pi",
|
|
4617
|
+
style: { color: "#a5a5ba", display: "flex", marginLeft: "10px" },
|
|
4618
|
+
children: formatMessage({
|
|
4619
|
+
id: getTranslation(`module.${module2}.modal.ai.progress`),
|
|
4620
|
+
defaultMessage: "Translating. This can take a few minutes, please keep this window open"
|
|
4621
|
+
})
|
|
4622
|
+
}
|
|
4623
|
+
)
|
|
4624
|
+
]
|
|
4625
|
+
}
|
|
4626
|
+
),
|
|
4627
|
+
result && !translateInProgress && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4628
|
+
designSystem.Card,
|
|
4629
|
+
{
|
|
4630
|
+
shadow: false,
|
|
4631
|
+
style: {
|
|
4632
|
+
marginTop: "20px",
|
|
4633
|
+
padding: "10px",
|
|
4634
|
+
display: "flex",
|
|
4635
|
+
flexDirection: "column",
|
|
4636
|
+
alignItems: "start",
|
|
4637
|
+
gap: "5px"
|
|
4638
|
+
},
|
|
4639
|
+
children: [
|
|
4640
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", style: { display: "flex" }, children: formatMessage(
|
|
4641
|
+
{
|
|
4642
|
+
id: getTranslation(`module.${module2}.modal.ai.result`),
|
|
4643
|
+
defaultMessage: "{translated} translated, {skipped} skipped, {failed} failed"
|
|
4644
|
+
},
|
|
4645
|
+
{
|
|
4646
|
+
translated: result.translated,
|
|
4647
|
+
skipped: result.skipped,
|
|
4648
|
+
failed: result.failed
|
|
4649
|
+
}
|
|
4650
|
+
) }),
|
|
4651
|
+
result.translated > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", style: { color: "#a5a5ba", display: "flex" }, children: formatMessage({
|
|
4652
|
+
id: getTranslation(`module.${module2}.panel.ai.result.save`),
|
|
4653
|
+
defaultMessage: "Review the fields and save the entry to keep them"
|
|
4654
|
+
}) }),
|
|
4655
|
+
result.unmatched > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", style: { color: "#ee5e52", display: "flex" }, children: formatMessage(
|
|
4656
|
+
{
|
|
4657
|
+
id: getTranslation(`module.${module2}.panel.ai.result.unmatched`),
|
|
4658
|
+
defaultMessage: "{unmatched} fields of the base language have no match here, the two entries have a different structure"
|
|
4659
|
+
},
|
|
4660
|
+
{ unmatched: result.unmatched }
|
|
4661
|
+
) }),
|
|
4662
|
+
result.errors.map((message, index2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4663
|
+
designSystem.Typography,
|
|
4664
|
+
{
|
|
4665
|
+
variant: "pi",
|
|
4666
|
+
style: { color: "#ee5e52", display: "flex" },
|
|
4667
|
+
children: message
|
|
4668
|
+
},
|
|
4669
|
+
index2
|
|
4670
|
+
))
|
|
4671
|
+
]
|
|
4672
|
+
}
|
|
4673
|
+
),
|
|
4674
|
+
error && !translateInProgress && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4675
|
+
designSystem.Card,
|
|
4676
|
+
{
|
|
4677
|
+
shadow: false,
|
|
4678
|
+
style: {
|
|
4679
|
+
marginTop: "20px",
|
|
4680
|
+
padding: "10px",
|
|
4681
|
+
display: "flex",
|
|
4682
|
+
alignItems: "center"
|
|
4683
|
+
},
|
|
4684
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", style: { color: "#ee5e52", display: "flex" }, children: error })
|
|
4685
|
+
}
|
|
4686
|
+
)
|
|
4687
|
+
] }) }),
|
|
4688
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { style: { justifyContent: "end", gap: "5px" }, children: [
|
|
4689
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleClose, disabled: translateInProgress, children: formatMessage({
|
|
4690
|
+
id: getTranslation(`app.modal.confirm.button.cancel`),
|
|
4691
|
+
defaultMessage: "Cancel"
|
|
4692
|
+
}) }),
|
|
4693
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4694
|
+
designSystem.Button,
|
|
4695
|
+
{
|
|
4696
|
+
style: { marginRight: "5px" },
|
|
4697
|
+
onClick: run,
|
|
4698
|
+
disabled: translateInProgress || !sourceLocale,
|
|
4699
|
+
children: formatMessage({
|
|
4700
|
+
id: getTranslation(`module.${module2}.modal.ai.button.translate`),
|
|
4701
|
+
defaultMessage: "Translate"
|
|
4702
|
+
})
|
|
4703
|
+
}
|
|
4704
|
+
)
|
|
4705
|
+
] })
|
|
4706
|
+
] }) }) });
|
|
4707
|
+
};
|
|
4708
|
+
const DocumentTranslateBox = ({ document: document2 }) => {
|
|
4709
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
4710
|
+
const context = admin.unstable_useContentManagerContext();
|
|
4711
|
+
const [appSettings, setAppSettings] = React__namespace.useState();
|
|
4712
|
+
const [i18nLocales, setI18nLocales] = React__namespace.useState([]);
|
|
4713
|
+
const [showModal, setShowModal] = React__namespace.useState(false);
|
|
4714
|
+
const module2 = config.uuid.modules.translation;
|
|
4715
|
+
function getCurrentLocale() {
|
|
4716
|
+
const queryString = window.location.search.split("?")[1];
|
|
4717
|
+
const searchParams = new URLSearchParams(queryString);
|
|
4718
|
+
return searchParams.get("plugins[i18n][locale]");
|
|
4719
|
+
}
|
|
4720
|
+
function getCurrentStatus() {
|
|
4721
|
+
const queryString = window.location.search.split("?")[1];
|
|
4722
|
+
const searchParams = new URLSearchParams(queryString);
|
|
4723
|
+
return searchParams.get("status") || void 0;
|
|
4724
|
+
}
|
|
4725
|
+
async function fetchSettings() {
|
|
4726
|
+
const fetchModuleSettings = new FetchModuleSettings();
|
|
4727
|
+
setAppSettings(await fetchModuleSettings.execute(module2));
|
|
4728
|
+
}
|
|
4729
|
+
async function fetchLocales() {
|
|
4730
|
+
const fetchLocales2 = new FetchLocales();
|
|
4731
|
+
setI18nLocales(await fetchLocales2.execute());
|
|
4732
|
+
}
|
|
4733
|
+
function applyResults(results) {
|
|
4734
|
+
results.forEach((result) => {
|
|
4735
|
+
context.form.onChange(result.path, result.value);
|
|
4736
|
+
if (result.kind === "slug") {
|
|
4737
|
+
context.form.onChange("ltb_slug", result.value);
|
|
4738
|
+
}
|
|
4739
|
+
});
|
|
4740
|
+
}
|
|
4741
|
+
function getDocumentId() {
|
|
4742
|
+
const documentId = document2?.documentId || context.id;
|
|
4743
|
+
return documentId && documentId !== "create" ? documentId : void 0;
|
|
4744
|
+
}
|
|
4745
|
+
async function translate(sourceLocale, overwrite) {
|
|
4746
|
+
const translateDocument = new TranslateDocument();
|
|
4747
|
+
const output = await translateDocument.execute({
|
|
4748
|
+
collectionType: context.collectionType,
|
|
4749
|
+
model: context.model,
|
|
4750
|
+
documentId: context.isSingleType ? void 0 : getDocumentId(),
|
|
4751
|
+
sourceLocale,
|
|
4752
|
+
targetLocale: getCurrentLocale(),
|
|
4753
|
+
status: getCurrentStatus(),
|
|
4754
|
+
attributes: context.contentType?.attributes,
|
|
4755
|
+
components: context.components,
|
|
4756
|
+
values: context.form.values,
|
|
4757
|
+
overwrite
|
|
4758
|
+
});
|
|
4759
|
+
applyResults(output.results);
|
|
4760
|
+
return output;
|
|
4761
|
+
}
|
|
4762
|
+
React__namespace.useEffect(() => {
|
|
4763
|
+
fetchSettings();
|
|
4764
|
+
fetchLocales();
|
|
4765
|
+
}, []);
|
|
4766
|
+
const currentLocale = getCurrentLocale();
|
|
4767
|
+
const targetLocale = i18nLocales.find(
|
|
4768
|
+
(locale) => locale.code === currentLocale
|
|
4769
|
+
);
|
|
4770
|
+
const isLocalized2 = context.contentType?.pluginOptions?.i18n?.localized === true;
|
|
4771
|
+
if (!appSettings || !appSettings.active || !appSettings.aiEnabled) return null;
|
|
4772
|
+
if (!isLocalized2 || !currentLocale || i18nLocales.length < 2) return null;
|
|
4773
|
+
if (!context.contentType) return null;
|
|
4774
|
+
if (!context.isSingleType && !getDocumentId()) return null;
|
|
4775
|
+
return {
|
|
4776
|
+
title: formatMessage({
|
|
4777
|
+
id: getTranslation(`module.${module2}.panel.title`),
|
|
4778
|
+
defaultMessage: "Translation"
|
|
4779
|
+
}),
|
|
4780
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4781
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { display: "flex", style: { flexDirection: "column", width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4782
|
+
designSystem.Button,
|
|
4783
|
+
{
|
|
4784
|
+
variant: "secondary",
|
|
4785
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Sparkle, {}),
|
|
4786
|
+
onClick: () => setShowModal(true),
|
|
4787
|
+
disabled: context.form.isSubmitting || context.form.disabled,
|
|
4788
|
+
fullWidth: true,
|
|
4789
|
+
children: formatMessage({
|
|
4790
|
+
id: getTranslation(`module.${module2}.button.translate-with-ai`),
|
|
4791
|
+
defaultMessage: "Translate with AI"
|
|
4792
|
+
})
|
|
4793
|
+
}
|
|
4794
|
+
) }),
|
|
4795
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4796
|
+
DocumentTranslateModal,
|
|
4797
|
+
{
|
|
4798
|
+
open: showModal,
|
|
4799
|
+
locales: i18nLocales,
|
|
4800
|
+
targetLocale,
|
|
4801
|
+
translate,
|
|
4802
|
+
close: () => setShowModal(false)
|
|
4803
|
+
}
|
|
4804
|
+
)
|
|
4805
|
+
] })
|
|
4806
|
+
};
|
|
4807
|
+
};
|
|
4808
|
+
const TABS_PLUGIN_KEY = "littlebox-strapi-suite";
|
|
4809
|
+
const TABS_HASH_PARAM = "ltbTab";
|
|
4810
|
+
const TABS_BAR_FIELD_TYPE = "ltb-tabs-bar";
|
|
4811
|
+
const TABS_SECTION_FIELD_TYPE = "ltb-tab-section";
|
|
4812
|
+
function toTabKey(name) {
|
|
4813
|
+
return (name ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
4814
|
+
}
|
|
4815
|
+
function generateTabId() {
|
|
4816
|
+
return `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
4817
|
+
}
|
|
4818
|
+
function readTabs(pluginOptions) {
|
|
4819
|
+
const tabs = pluginOptions?.[TABS_PLUGIN_KEY]?.tabs;
|
|
4820
|
+
if (!Array.isArray(tabs)) return [];
|
|
4821
|
+
return tabs.filter((tab) => tab && typeof tab.id === "string" && typeof tab.name === "string");
|
|
4822
|
+
}
|
|
4823
|
+
function padTabs(next, previous) {
|
|
4824
|
+
const previousLength = Array.isArray(previous) ? previous.length : 0;
|
|
4825
|
+
const padding = Math.max(previousLength - next.length, 0);
|
|
4826
|
+
return [...next, ...Array(padding).fill(null)];
|
|
4827
|
+
}
|
|
4828
|
+
function readAttributeTabId(attribute) {
|
|
4829
|
+
const id = attribute?.pluginOptions?.[TABS_PLUGIN_KEY]?.tab;
|
|
4830
|
+
return typeof id === "string" && id !== "" ? id : null;
|
|
4831
|
+
}
|
|
4832
|
+
const SYSTEM_KEYS = [
|
|
4833
|
+
"id",
|
|
4834
|
+
"documentId",
|
|
4835
|
+
"locale",
|
|
4836
|
+
"createdAt",
|
|
4837
|
+
"updatedAt",
|
|
4838
|
+
"publishedAt",
|
|
4839
|
+
"createdBy",
|
|
4840
|
+
"updatedBy",
|
|
4841
|
+
"localizations"
|
|
4842
|
+
];
|
|
4843
|
+
function attributeNames(attributes) {
|
|
4844
|
+
if (Array.isArray(attributes)) {
|
|
4845
|
+
return attributes.map((attribute) => attribute?.name).filter((name) => typeof name === "string");
|
|
4846
|
+
}
|
|
4847
|
+
return attributes && typeof attributes === "object" ? Object.keys(attributes) : [];
|
|
4848
|
+
}
|
|
4849
|
+
function getConflictingTabIds(tabs, attributes) {
|
|
4850
|
+
const reserved = /* @__PURE__ */ new Set([...SYSTEM_KEYS, ...attributeNames(attributes)]);
|
|
4851
|
+
return new Set(tabs.filter((tab) => reserved.has(toTabKey(tab.name))).map((tab) => tab.id));
|
|
4852
|
+
}
|
|
4853
|
+
function validateTabs(tabs) {
|
|
4854
|
+
const keys2 = /* @__PURE__ */ new Set();
|
|
4855
|
+
for (const tab of tabs) {
|
|
4856
|
+
if (!tab.name || tab.name.trim() === "") return "name.required";
|
|
4857
|
+
const key = toTabKey(tab.name);
|
|
4858
|
+
if (key === "") return "key.empty";
|
|
4859
|
+
if (keys2.has(key)) return "key.duplicated";
|
|
4860
|
+
keys2.add(key);
|
|
4861
|
+
}
|
|
4862
|
+
return null;
|
|
4863
|
+
}
|
|
4864
|
+
function omitPluginKey(pluginOptions) {
|
|
4865
|
+
const { [TABS_PLUGIN_KEY]: _removed, ...rest } = pluginOptions;
|
|
4866
|
+
return rest;
|
|
4867
|
+
}
|
|
4868
|
+
function cleanAttribute(attribute, validIds) {
|
|
4869
|
+
if (!attribute?.pluginOptions || !(TABS_PLUGIN_KEY in attribute.pluginOptions)) return attribute;
|
|
4870
|
+
const id = readAttributeTabId(attribute);
|
|
4871
|
+
if (id && validIds.has(id)) return attribute;
|
|
4872
|
+
return { ...attribute, pluginOptions: omitPluginKey(attribute.pluginOptions) };
|
|
4873
|
+
}
|
|
4874
|
+
function cleanContentTypeSchema(schema) {
|
|
4875
|
+
const current = schema;
|
|
4876
|
+
if (!current || typeof current !== "object") return schema;
|
|
4877
|
+
const tabs = readTabs(current.pluginOptions);
|
|
4878
|
+
const validIds = new Set(tabs.map((tab) => tab.id));
|
|
4879
|
+
let changed = false;
|
|
4880
|
+
const next = { ...current };
|
|
4881
|
+
if (current.pluginOptions && TABS_PLUGIN_KEY in current.pluginOptions) {
|
|
4882
|
+
const storedTabs = current.pluginOptions[TABS_PLUGIN_KEY]?.tabs;
|
|
4883
|
+
if (tabs.length === 0) {
|
|
4884
|
+
next.pluginOptions = omitPluginKey(current.pluginOptions);
|
|
4885
|
+
changed = true;
|
|
4886
|
+
} else if (!Array.isArray(storedTabs) || storedTabs.length !== tabs.length) {
|
|
4887
|
+
next.pluginOptions = {
|
|
4888
|
+
...current.pluginOptions,
|
|
4889
|
+
[TABS_PLUGIN_KEY]: { ...current.pluginOptions[TABS_PLUGIN_KEY], tabs }
|
|
4890
|
+
};
|
|
4891
|
+
changed = true;
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4894
|
+
const clean = (attribute) => {
|
|
4895
|
+
const cleaned = cleanAttribute(attribute, validIds);
|
|
4896
|
+
if (cleaned !== attribute) changed = true;
|
|
4897
|
+
return cleaned;
|
|
4898
|
+
};
|
|
4899
|
+
if (Array.isArray(current.attributes)) {
|
|
4900
|
+
next.attributes = current.attributes.map(clean);
|
|
4901
|
+
} else if (current.attributes && typeof current.attributes === "object") {
|
|
4902
|
+
next.attributes = Object.fromEntries(
|
|
4903
|
+
Object.entries(current.attributes).map(([name, attribute]) => [name, clean(attribute)])
|
|
4904
|
+
);
|
|
4905
|
+
}
|
|
4906
|
+
return changed ? next : schema;
|
|
4907
|
+
}
|
|
4908
|
+
function fieldTabId(field, validIds) {
|
|
4909
|
+
const id = readAttributeTabId(field.attribute);
|
|
4910
|
+
return id && validIds.has(id) ? id : null;
|
|
4911
|
+
}
|
|
4912
|
+
function pickFields(panels, predicate) {
|
|
4913
|
+
return panels.map((panel) => panel.map((row) => row.filter(predicate)).filter((row) => row.length > 0)).filter((panel) => panel.length > 0);
|
|
4914
|
+
}
|
|
4915
|
+
function groupLayoutByTabs(panels, tabs) {
|
|
4916
|
+
const validIds = new Set(tabs.map((tab) => tab.id));
|
|
4917
|
+
return {
|
|
4918
|
+
rootPanels: pickFields(panels, (field) => fieldTabId(field, validIds) === null),
|
|
4919
|
+
sections: tabs.map((tab) => ({
|
|
4920
|
+
tab,
|
|
4921
|
+
panels: pickFields(panels, (field) => fieldTabId(field, validIds) === tab.id)
|
|
4922
|
+
}))
|
|
4923
|
+
};
|
|
4924
|
+
}
|
|
4925
|
+
function componentLeafPath(field, components, depth = 0) {
|
|
4926
|
+
const attribute = field.attribute;
|
|
4927
|
+
if (attribute?.type !== "component") return field.name;
|
|
4928
|
+
if (depth > 10) return null;
|
|
4929
|
+
const inner = components[attribute.component]?.layout?.flat() ?? [];
|
|
4930
|
+
for (const child of inner) {
|
|
4931
|
+
const path = componentLeafPath(child, components, depth + 1);
|
|
4932
|
+
if (path) return `${field.name}.${path}`;
|
|
4933
|
+
}
|
|
4934
|
+
return null;
|
|
4935
|
+
}
|
|
4936
|
+
function findAnchorName(panels, components = {}) {
|
|
4937
|
+
const fields = panels.flat(2);
|
|
4938
|
+
const plain = fields.find((field) => field.attribute?.type !== "component");
|
|
4939
|
+
if (plain) return plain.name;
|
|
4940
|
+
for (const field of fields) {
|
|
4941
|
+
const path = componentLeafPath(field, components);
|
|
4942
|
+
if (path) return path;
|
|
4943
|
+
}
|
|
4944
|
+
return null;
|
|
4945
|
+
}
|
|
4946
|
+
function readTabFromHash(hash) {
|
|
4947
|
+
const value = new URLSearchParams((hash ?? "").replace(/^#/, "")).get(TABS_HASH_PARAM);
|
|
4948
|
+
return value ? value : null;
|
|
4949
|
+
}
|
|
4950
|
+
function pickInitialTab(keys2, hashKey, currentKey) {
|
|
4951
|
+
if (hashKey && keys2.includes(hashKey)) return hashKey;
|
|
4952
|
+
if (currentKey && keys2.includes(currentKey)) return currentKey;
|
|
4953
|
+
return keys2[0] ?? null;
|
|
4954
|
+
}
|
|
4955
|
+
function tabHash(key) {
|
|
4956
|
+
return `#${TABS_HASH_PARAM}=${encodeURIComponent(key)}`;
|
|
4957
|
+
}
|
|
4958
|
+
function mapFieldsToTabKeys(panels, tabs) {
|
|
4959
|
+
const keysById = new Map(tabs.map((tab) => [tab.id, toTabKey(tab.name)]));
|
|
4960
|
+
const result = {};
|
|
4961
|
+
panels.flat(2).forEach((field) => {
|
|
4962
|
+
const id = readAttributeTabId(field.attribute);
|
|
4963
|
+
const key = id ? keysById.get(id) : void 0;
|
|
4964
|
+
if (key !== void 0) result[field.name] = key;
|
|
4965
|
+
});
|
|
4966
|
+
return result;
|
|
4967
|
+
}
|
|
4968
|
+
function countErrorsByTab(errors, fieldTabKeys) {
|
|
4969
|
+
const counts = {};
|
|
4970
|
+
if (!errors || typeof errors !== "object") return counts;
|
|
4971
|
+
Object.entries(errors).forEach(([name, error]) => {
|
|
4972
|
+
const key = fieldTabKeys[name];
|
|
4973
|
+
if (key !== void 0 && error) counts[key] = (counts[key] ?? 0) + 1;
|
|
4974
|
+
});
|
|
4975
|
+
return counts;
|
|
4976
|
+
}
|
|
4977
|
+
const EDIT_VIEW_PATH = /\/content-manager\/(collection-types\/[^/]+\/[^/]+|single-types\/[^/]+)\/?$/;
|
|
4978
|
+
const NON_EDIT_SEGMENTS = /* @__PURE__ */ new Set(["history", "preview", "configurations"]);
|
|
4979
|
+
function isEditViewPath(pathname) {
|
|
4980
|
+
if (!EDIT_VIEW_PATH.test(pathname)) return false;
|
|
4981
|
+
const lastSegment = pathname.replace(/\/$/, "").split("/").pop() ?? "";
|
|
4982
|
+
return !NON_EDIT_SEGMENTS.has(lastSegment);
|
|
4983
|
+
}
|
|
4984
|
+
const TabRow = ({
|
|
4985
|
+
tab,
|
|
4986
|
+
onRename,
|
|
4987
|
+
onRemove
|
|
4988
|
+
}) => {
|
|
4989
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
4990
|
+
const { attributes, listeners, setNodeRef, transform, transition } = sortable.useSortable({ id: tab.id });
|
|
4991
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4992
|
+
designSystem.Box,
|
|
4993
|
+
{
|
|
4994
|
+
ref: setNodeRef,
|
|
4995
|
+
style: { transform: utilities.CSS.Transform.toString(transform), transition },
|
|
4996
|
+
paddingBottom: 2,
|
|
4997
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
4998
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4999
|
+
designSystem.IconButton,
|
|
5000
|
+
{
|
|
5001
|
+
...attributes,
|
|
5002
|
+
...listeners,
|
|
5003
|
+
type: "button",
|
|
5004
|
+
variant: "ghost",
|
|
5005
|
+
label: formatMessage({
|
|
5006
|
+
id: getTranslation("tabs.ctb.reorder"),
|
|
5007
|
+
defaultMessage: "Drag to reorder"
|
|
5008
|
+
}),
|
|
5009
|
+
style: { cursor: "grab" },
|
|
5010
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Drag, {})
|
|
5011
|
+
}
|
|
5012
|
+
),
|
|
5013
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5014
|
+
designSystem.TextInput,
|
|
5015
|
+
{
|
|
5016
|
+
"aria-label": formatMessage({
|
|
5017
|
+
id: getTranslation("tabs.ctb.name.placeholder"),
|
|
5018
|
+
defaultMessage: "Tab name"
|
|
5019
|
+
}),
|
|
5020
|
+
placeholder: formatMessage({
|
|
5021
|
+
id: getTranslation("tabs.ctb.name.placeholder"),
|
|
5022
|
+
defaultMessage: "Tab name"
|
|
5023
|
+
}),
|
|
5024
|
+
value: tab.name,
|
|
5025
|
+
onChange: (event) => onRename(event.target.value)
|
|
5026
|
+
}
|
|
5027
|
+
) }),
|
|
5028
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5029
|
+
designSystem.IconButton,
|
|
5030
|
+
{
|
|
5031
|
+
type: "button",
|
|
5032
|
+
variant: "ghost",
|
|
5033
|
+
label: formatMessage({
|
|
5034
|
+
id: getTranslation("tabs.ctb.remove"),
|
|
5035
|
+
defaultMessage: "Remove tab"
|
|
5036
|
+
}),
|
|
5037
|
+
onClick: onRemove,
|
|
5038
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
|
|
5039
|
+
}
|
|
5040
|
+
)
|
|
5041
|
+
] })
|
|
5042
|
+
}
|
|
5043
|
+
);
|
|
5044
|
+
};
|
|
5045
|
+
const TabsEditor = ({ name, value, error, intlLabel, description, onChange }) => {
|
|
5046
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
5047
|
+
const tabs = readTabs({ [TABS_PLUGIN_KEY]: { tabs: value } });
|
|
5048
|
+
const sensors = core.useSensors(core.useSensor(core.PointerSensor, { activationConstraint: { distance: 4 } }));
|
|
5049
|
+
const change = (next) => onChange({ target: { name, value: padTabs(next, value) } });
|
|
5050
|
+
const handleDragEnd = ({ active, over }) => {
|
|
5051
|
+
if (!over || active.id === over.id) return;
|
|
5052
|
+
const oldIndex = tabs.findIndex((tab) => tab.id === active.id);
|
|
5053
|
+
const newIndex = tabs.findIndex((tab) => tab.id === over.id);
|
|
5054
|
+
change(sortable.arrayMove(tabs, oldIndex, newIndex));
|
|
5055
|
+
};
|
|
5056
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
|
|
5057
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, paddingBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}) }),
|
|
5058
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name, id: name, error, children: [
|
|
5059
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { style: { fontSize: "1.4rem" }, children: formatMessage(intlLabel, intlLabel.values) }),
|
|
5060
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: formatMessage(description, description.values) }) }),
|
|
5061
|
+
tabs.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral500", children: formatMessage({
|
|
5062
|
+
id: getTranslation("tabs.ctb.empty"),
|
|
5063
|
+
defaultMessage: "No tabs yet."
|
|
5064
|
+
}) }) }),
|
|
5065
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5066
|
+
core.DndContext,
|
|
5067
|
+
{
|
|
5068
|
+
sensors,
|
|
5069
|
+
collisionDetection: core.closestCenter,
|
|
5070
|
+
modifiers: [modifiers.restrictToVerticalAxis],
|
|
5071
|
+
onDragEnd: handleDragEnd,
|
|
5072
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(sortable.SortableContext, { items: tabs.map((tab) => tab.id), strategy: sortable.verticalListSortingStrategy, children: tabs.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5073
|
+
TabRow,
|
|
5074
|
+
{
|
|
5075
|
+
tab,
|
|
5076
|
+
onRename: (tabName) => change(
|
|
5077
|
+
tabs.map(
|
|
5078
|
+
(current) => current.id === tab.id ? { ...current, name: tabName } : current
|
|
5079
|
+
)
|
|
5080
|
+
),
|
|
5081
|
+
onRemove: () => change(tabs.filter((current) => current.id !== tab.id))
|
|
5082
|
+
},
|
|
5083
|
+
tab.id
|
|
5084
|
+
)) })
|
|
5085
|
+
}
|
|
5086
|
+
),
|
|
5087
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5088
|
+
designSystem.Button,
|
|
5089
|
+
{
|
|
5090
|
+
type: "button",
|
|
5091
|
+
variant: "secondary",
|
|
5092
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
|
|
5093
|
+
onClick: () => change([...tabs, { id: generateTabId(), name: "" }]),
|
|
5094
|
+
children: formatMessage({ id: getTranslation("tabs.ctb.add"), defaultMessage: "Add tab" })
|
|
5095
|
+
}
|
|
5096
|
+
) }),
|
|
5097
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
5098
|
+
] })
|
|
5099
|
+
] });
|
|
5100
|
+
};
|
|
5101
|
+
const TabSelect = ({
|
|
5102
|
+
name,
|
|
5103
|
+
value,
|
|
5104
|
+
error,
|
|
5105
|
+
intlLabel,
|
|
5106
|
+
description,
|
|
5107
|
+
options = [],
|
|
5108
|
+
onChange
|
|
5109
|
+
}) => {
|
|
5110
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
5111
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5112
|
+
designSystem.Field.Root,
|
|
5113
|
+
{
|
|
5114
|
+
name,
|
|
5115
|
+
id: name,
|
|
5116
|
+
error,
|
|
5117
|
+
hint: description ? formatMessage(description) : void 0,
|
|
5118
|
+
children: [
|
|
5119
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { style: { fontSize: "1.6rem", paddingTop: "11px", paddingBottom: "12px" }, children: formatMessage(intlLabel) }),
|
|
5120
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5121
|
+
designSystem.SingleSelect,
|
|
5122
|
+
{
|
|
5123
|
+
value: value ?? "",
|
|
5124
|
+
onChange: (next) => onChange({ target: { name, value: String(next), type: "select" } }),
|
|
5125
|
+
children: options.map(({ key, value: optionValue, metadatas }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5126
|
+
designSystem.SingleSelectOption,
|
|
5127
|
+
{
|
|
5128
|
+
value: optionValue,
|
|
5129
|
+
disabled: metadatas.disabled,
|
|
5130
|
+
hidden: metadatas.hidden,
|
|
5131
|
+
children: formatMessage(metadatas.intlLabel)
|
|
5132
|
+
},
|
|
5133
|
+
key
|
|
5134
|
+
))
|
|
5135
|
+
}
|
|
5136
|
+
),
|
|
5137
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
|
|
5138
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
5139
|
+
]
|
|
5140
|
+
}
|
|
5141
|
+
);
|
|
5142
|
+
};
|
|
5143
|
+
const TABS_EDITOR_INPUT = "ltbTabsEditor";
|
|
5144
|
+
const TAB_SELECT_INPUT = "ltbTabSelect";
|
|
5145
|
+
const TAB_FIELD_TYPES = [
|
|
5146
|
+
"biginteger",
|
|
5147
|
+
"blocks",
|
|
5148
|
+
"boolean",
|
|
5149
|
+
"component",
|
|
5150
|
+
"date",
|
|
5151
|
+
"datetime",
|
|
5152
|
+
"decimal",
|
|
5153
|
+
"dynamiczone",
|
|
5154
|
+
"email",
|
|
5155
|
+
"enumeration",
|
|
5156
|
+
"float",
|
|
5157
|
+
"integer",
|
|
5158
|
+
"json",
|
|
5159
|
+
"media",
|
|
5160
|
+
"password",
|
|
5161
|
+
"relation",
|
|
5162
|
+
"richtext",
|
|
5163
|
+
"string",
|
|
5164
|
+
"text",
|
|
5165
|
+
"time",
|
|
5166
|
+
"uid"
|
|
5167
|
+
];
|
|
5168
|
+
function registerTabsInContentTypeBuilder(app) {
|
|
5169
|
+
const forms = app.getPlugin("content-type-builder")?.apis?.forms;
|
|
5170
|
+
if (!forms) return;
|
|
5171
|
+
forms.components.add({ id: TABS_EDITOR_INPUT, component: TabsEditor });
|
|
5172
|
+
forms.components.add({ id: TAB_SELECT_INPUT, component: TabSelect });
|
|
5173
|
+
forms.addContentTypeSchemaMutation((nextSchema) => cleanContentTypeSchema(nextSchema));
|
|
5174
|
+
forms.extendContentType({
|
|
5175
|
+
validator: () => ({
|
|
5176
|
+
[TABS_PLUGIN_KEY]: create$1().shape({
|
|
5177
|
+
tabs: create().test("ltb-tabs", function(tabs) {
|
|
5178
|
+
const error = validateTabs(readTabs({ [TABS_PLUGIN_KEY]: { tabs } }));
|
|
5179
|
+
return error === null ? true : this.createError({ message: getTranslation(`tabs.ctb.error.${error}`) });
|
|
5180
|
+
})
|
|
5181
|
+
})
|
|
5182
|
+
}),
|
|
5183
|
+
form: {
|
|
5184
|
+
advanced: () => [
|
|
5185
|
+
{
|
|
5186
|
+
name: `pluginOptions.${TABS_PLUGIN_KEY}.tabs`,
|
|
5187
|
+
type: TABS_EDITOR_INPUT,
|
|
5188
|
+
size: 12,
|
|
5189
|
+
intlLabel: { id: getTranslation("tabs.ctb.content-type.label"), defaultMessage: "Tabs" },
|
|
5190
|
+
description: {
|
|
5191
|
+
id: getTranslation("tabs.ctb.content-type.description"),
|
|
5192
|
+
defaultMessage: "Organize the fields of this content type in tabs. Fields in a tab are returned by the REST API inside a property named after the tab."
|
|
5193
|
+
}
|
|
5194
|
+
}
|
|
5195
|
+
]
|
|
5196
|
+
}
|
|
5197
|
+
});
|
|
5198
|
+
forms.extendFields(TAB_FIELD_TYPES, {
|
|
5199
|
+
form: {
|
|
5200
|
+
advanced: ({ contentTypeSchema, forTarget }) => {
|
|
5201
|
+
if (forTarget !== "contentType") return [];
|
|
5202
|
+
const tabs = readTabs(
|
|
5203
|
+
contentTypeSchema?.pluginOptions ?? contentTypeSchema?.schema?.pluginOptions
|
|
5204
|
+
);
|
|
5205
|
+
if (tabs.length === 0) return [];
|
|
5206
|
+
const conflicting = getConflictingTabIds(
|
|
5207
|
+
tabs,
|
|
5208
|
+
contentTypeSchema?.attributes ?? contentTypeSchema?.schema?.attributes
|
|
5209
|
+
);
|
|
5210
|
+
return [
|
|
5211
|
+
{
|
|
5212
|
+
name: `pluginOptions.${TABS_PLUGIN_KEY}.tab`,
|
|
5213
|
+
type: TAB_SELECT_INPUT,
|
|
5214
|
+
size: 12,
|
|
5215
|
+
intlLabel: { id: getTranslation("tabs.ctb.field.label"), defaultMessage: "Tab" },
|
|
5216
|
+
description: {
|
|
5217
|
+
id: getTranslation("tabs.ctb.field.description"),
|
|
5218
|
+
defaultMessage: "Tab where this field is shown. Fields without a tab are always visible."
|
|
5219
|
+
},
|
|
5220
|
+
options: [
|
|
5221
|
+
{
|
|
5222
|
+
key: "__null_reset_value__",
|
|
5223
|
+
value: "",
|
|
5224
|
+
metadatas: {
|
|
5225
|
+
intlLabel: {
|
|
5226
|
+
id: getTranslation("tabs.ctb.field.none"),
|
|
5227
|
+
defaultMessage: "None (always visible)"
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
},
|
|
5231
|
+
...tabs.map((tab) => ({
|
|
5232
|
+
key: tab.id,
|
|
5233
|
+
value: tab.id,
|
|
5234
|
+
metadatas: conflicting.has(tab.id) ? {
|
|
5235
|
+
disabled: true,
|
|
5236
|
+
// The CTB select formats option labels without values, so the text is prebuilt.
|
|
5237
|
+
intlLabel: {
|
|
5238
|
+
id: `${TABS_PLUGIN_KEY}.tab.${tab.id}.conflict`,
|
|
5239
|
+
defaultMessage: `${tab.name} (conflicts with a field name)`
|
|
5240
|
+
}
|
|
5241
|
+
} : {
|
|
5242
|
+
intlLabel: {
|
|
5243
|
+
id: `${TABS_PLUGIN_KEY}.tab.${tab.id}`,
|
|
5244
|
+
defaultMessage: tab.name
|
|
5245
|
+
}
|
|
5246
|
+
}
|
|
5247
|
+
}))
|
|
5248
|
+
]
|
|
5249
|
+
}
|
|
5250
|
+
];
|
|
5251
|
+
}
|
|
5252
|
+
}
|
|
5253
|
+
});
|
|
5254
|
+
}
|
|
5255
|
+
const BADGE_ATTRIBUTE = "data-ltb-tab-badge";
|
|
5256
|
+
const ROW_SELECTOR = "li[aria-label]";
|
|
5257
|
+
const CTB_STATE_KEY = "content-type-builder_dataManagerProvider";
|
|
5258
|
+
const CTB_CONTENT_TYPE_PATH = /\/plugins\/content-type-builder\/content-types\/([^/]+)\/?$/;
|
|
5259
|
+
function ctbContentTypeUid(pathname) {
|
|
5260
|
+
const match = pathname.match(CTB_CONTENT_TYPE_PATH);
|
|
5261
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
5262
|
+
}
|
|
5263
|
+
function buildFieldTabNames(contentType) {
|
|
5264
|
+
const tabs = readTabs(contentType?.pluginOptions);
|
|
5265
|
+
if (tabs.length === 0) return {};
|
|
5266
|
+
const namesById = new Map(tabs.map((tab) => [tab.id, tab.name]));
|
|
5267
|
+
const attributes = Array.isArray(contentType?.attributes) ? contentType.attributes.map((attribute) => [attribute?.name, attribute]) : Object.entries(contentType?.attributes ?? {});
|
|
5268
|
+
const result = {};
|
|
5269
|
+
attributes.forEach(([name, attribute]) => {
|
|
5270
|
+
const id = readAttributeTabId(attribute);
|
|
5271
|
+
const tabName = id ? namesById.get(id) : void 0;
|
|
5272
|
+
if (typeof name === "string" && tabName !== void 0) result[name] = tabName;
|
|
5273
|
+
});
|
|
5274
|
+
return result;
|
|
5275
|
+
}
|
|
5276
|
+
function findNameElement(row, name) {
|
|
5277
|
+
const walker = row.ownerDocument.createTreeWalker(row, NodeFilter.SHOW_TEXT);
|
|
5278
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
5279
|
+
if (node.textContent === name) return node.parentElement;
|
|
5280
|
+
}
|
|
5281
|
+
return null;
|
|
5282
|
+
}
|
|
5283
|
+
function createBadge(doc) {
|
|
5284
|
+
const badge = doc.createElement("span");
|
|
5285
|
+
badge.setAttribute(BADGE_ATTRIBUTE, "");
|
|
5286
|
+
Object.assign(badge.style, {
|
|
5287
|
+
flexShrink: "0",
|
|
5288
|
+
marginLeft: "8px",
|
|
5289
|
+
padding: "2px 8px",
|
|
5290
|
+
borderRadius: "4px",
|
|
5291
|
+
fontSize: "1.1rem",
|
|
5292
|
+
fontWeight: "600",
|
|
5293
|
+
lineHeight: "1.6rem",
|
|
5294
|
+
whiteSpace: "nowrap",
|
|
5295
|
+
color: "#7b79ff",
|
|
5296
|
+
backgroundColor: "rgba(123, 121, 255, 0.16)"
|
|
5297
|
+
});
|
|
5298
|
+
return badge;
|
|
5299
|
+
}
|
|
5300
|
+
function syncTabBadges(root2, fieldTabNames) {
|
|
5301
|
+
root2.querySelectorAll(ROW_SELECTOR).forEach((row) => {
|
|
5302
|
+
if (row.parentElement?.closest(ROW_SELECTOR)) return;
|
|
5303
|
+
const name = row.getAttribute("aria-label") ?? "";
|
|
5304
|
+
const nameElement = findNameElement(row, name);
|
|
5305
|
+
if (!nameElement) return;
|
|
5306
|
+
const existing = nameElement.nextElementSibling?.hasAttribute(BADGE_ATTRIBUTE) ? nameElement.nextElementSibling : null;
|
|
5307
|
+
const tabName = fieldTabNames[name];
|
|
5308
|
+
if (!tabName) {
|
|
5309
|
+
existing?.remove();
|
|
5310
|
+
return;
|
|
5311
|
+
}
|
|
5312
|
+
const badge = existing ?? createBadge(row.ownerDocument);
|
|
5313
|
+
if (badge.textContent !== tabName) badge.textContent = tabName;
|
|
5314
|
+
if (!existing) nameElement.after(badge);
|
|
5315
|
+
});
|
|
5316
|
+
}
|
|
5317
|
+
function startTabBadges(app) {
|
|
5318
|
+
if (typeof window === "undefined" || typeof MutationObserver === "undefined") return;
|
|
5319
|
+
let scheduled = false;
|
|
5320
|
+
let storeUnsubscribe = null;
|
|
5321
|
+
const update = () => {
|
|
5322
|
+
scheduled = false;
|
|
5323
|
+
const uid = ctbContentTypeUid(window.location.pathname);
|
|
5324
|
+
if (!uid) return;
|
|
5325
|
+
const store = app?.store;
|
|
5326
|
+
if (store && !storeUnsubscribe) storeUnsubscribe = store.subscribe(schedule);
|
|
5327
|
+
const contentType = store?.getState?.()[CTB_STATE_KEY]?.current?.contentTypes?.[uid];
|
|
5328
|
+
syncTabBadges(document, buildFieldTabNames(contentType));
|
|
5329
|
+
};
|
|
5330
|
+
function schedule() {
|
|
5331
|
+
if (scheduled) return;
|
|
5332
|
+
scheduled = true;
|
|
5333
|
+
requestAnimationFrame(update);
|
|
5334
|
+
}
|
|
5335
|
+
const observer = new MutationObserver((mutations) => {
|
|
5336
|
+
const onlyBadges = mutations.every(
|
|
5337
|
+
(mutation) => [...mutation.addedNodes, ...mutation.removedNodes].every(
|
|
5338
|
+
(node) => node instanceof Element && node.hasAttribute(BADGE_ATTRIBUTE)
|
|
5339
|
+
)
|
|
5340
|
+
);
|
|
5341
|
+
if (!onlyBadges) schedule();
|
|
5342
|
+
});
|
|
5343
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
5344
|
+
}
|
|
5345
|
+
function pseudoField(name, type, extra) {
|
|
5346
|
+
return {
|
|
5347
|
+
name,
|
|
5348
|
+
label: "",
|
|
5349
|
+
type,
|
|
5350
|
+
size: 12,
|
|
5351
|
+
visible: true,
|
|
5352
|
+
disabled: false,
|
|
5353
|
+
required: false,
|
|
5354
|
+
unique: false,
|
|
5355
|
+
hint: "",
|
|
5356
|
+
placeholder: "",
|
|
5357
|
+
attribute: { type },
|
|
5358
|
+
...extra
|
|
5359
|
+
};
|
|
5360
|
+
}
|
|
5361
|
+
function mutateEditViewLayout(args, pathname = typeof window !== "undefined" ? window.location.pathname : "") {
|
|
5362
|
+
const tabs = readTabs(args.layout?.options);
|
|
5363
|
+
const panels = args.layout?.layout ?? [];
|
|
5364
|
+
if (tabs.length === 0 || !isEditViewPath(pathname)) return args;
|
|
5365
|
+
const { rootPanels, sections } = groupLayoutByTabs(panels, tabs);
|
|
5366
|
+
const anchor = findAnchorName(rootPanels, args.layout?.components) ?? findAnchorName(panels, args.layout?.components);
|
|
5367
|
+
if (!anchor) return args;
|
|
5368
|
+
const bar = pseudoField(anchor, TABS_BAR_FIELD_TYPE, {
|
|
5369
|
+
ltbTabs: tabs.map((tab) => ({ ...tab, key: toTabKey(tab.name) })),
|
|
5370
|
+
ltbFieldTabKeys: mapFieldsToTabKeys(panels, tabs)
|
|
5371
|
+
});
|
|
5372
|
+
return {
|
|
5373
|
+
...args,
|
|
5374
|
+
layout: {
|
|
5375
|
+
...args.layout,
|
|
5376
|
+
layout: [
|
|
5377
|
+
...rootPanels,
|
|
5378
|
+
[[bar]],
|
|
5379
|
+
...sections.flatMap(({ tab, panels: tabPanels }) => [
|
|
5380
|
+
[[pseudoField(anchor, TABS_SECTION_FIELD_TYPE, { ltbTabKey: toTabKey(tab.name) })]],
|
|
5381
|
+
...tabPanels
|
|
5382
|
+
])
|
|
5383
|
+
]
|
|
5384
|
+
}
|
|
5385
|
+
};
|
|
5386
|
+
}
|
|
5387
|
+
function createTabsStore() {
|
|
5388
|
+
let active = null;
|
|
5389
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
5390
|
+
return {
|
|
5391
|
+
get: () => active,
|
|
5392
|
+
set(key) {
|
|
5393
|
+
if (key === active) return;
|
|
5394
|
+
active = key;
|
|
5395
|
+
listeners.forEach((listener) => listener());
|
|
5396
|
+
},
|
|
5397
|
+
subscribe(listener) {
|
|
5398
|
+
listeners.add(listener);
|
|
5399
|
+
return () => {
|
|
5400
|
+
listeners.delete(listener);
|
|
5401
|
+
};
|
|
5402
|
+
}
|
|
5403
|
+
};
|
|
5404
|
+
}
|
|
5405
|
+
const tabsStore = createTabsStore();
|
|
5406
|
+
function selectTab(key) {
|
|
5407
|
+
tabsStore.set(key);
|
|
5408
|
+
const { pathname, search } = window.location;
|
|
5409
|
+
window.history.replaceState(window.history.state, "", `${pathname}${search}${tabHash(key)}`);
|
|
5410
|
+
}
|
|
5411
|
+
const TabsBar = ({ ltbTabs = [], ltbFieldTabKeys = {} }) => {
|
|
5412
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
5413
|
+
const { form } = admin.unstable_useContentManagerContext();
|
|
5414
|
+
const errors = form?.errors;
|
|
5415
|
+
const active = React.useSyncExternalStore(tabsStore.subscribe, tabsStore.get);
|
|
5416
|
+
const keys2 = React.useMemo(() => ltbTabs.map((tab) => tab.key), [ltbTabs]);
|
|
5417
|
+
const errorCounts = React.useMemo(
|
|
5418
|
+
() => countErrorsByTab(errors, ltbFieldTabKeys),
|
|
5419
|
+
[errors, ltbFieldTabKeys]
|
|
5420
|
+
);
|
|
5421
|
+
React.useLayoutEffect(() => {
|
|
5422
|
+
const initial = pickInitialTab(keys2, readTabFromHash(window.location.hash), tabsStore.get());
|
|
5423
|
+
if (initial) tabsStore.set(initial);
|
|
5424
|
+
}, [keys2.join("|")]);
|
|
5425
|
+
const previousErrors = React.useRef(errors);
|
|
5426
|
+
React.useEffect(() => {
|
|
5427
|
+
if (previousErrors.current === errors) return;
|
|
5428
|
+
previousErrors.current = errors;
|
|
5429
|
+
if (active && (errorCounts[active] ?? 0) > 0) return;
|
|
5430
|
+
const tabWithErrors = ltbTabs.find((tab) => (errorCounts[tab.key] ?? 0) > 0);
|
|
5431
|
+
if (tabWithErrors) selectTab(tabWithErrors.key);
|
|
5432
|
+
}, [errors]);
|
|
5433
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { "data-ltb-tabs-bar": "", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Root, { variant: "simple", value: active ?? keys2[0], onValueChange: selectTab, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5434
|
+
designSystem.Tabs.List,
|
|
5435
|
+
{
|
|
5436
|
+
"aria-label": formatMessage({
|
|
5437
|
+
id: getTranslation("tabs.edit-view.label"),
|
|
5438
|
+
defaultMessage: "Content tabs"
|
|
5439
|
+
}),
|
|
5440
|
+
children: ltbTabs.map((tab) => {
|
|
5441
|
+
const count = errorCounts[tab.key] ?? 0;
|
|
5442
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: tab.key, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
5443
|
+
tab.name,
|
|
5444
|
+
count > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5445
|
+
designSystem.Badge,
|
|
5446
|
+
{
|
|
5447
|
+
backgroundColor: "danger100",
|
|
5448
|
+
textColor: "danger600",
|
|
5449
|
+
title: formatMessage(
|
|
5450
|
+
{
|
|
5451
|
+
id: getTranslation("tabs.edit-view.errors"),
|
|
5452
|
+
defaultMessage: "{count, plural, one {# error} other {# errors}}"
|
|
5453
|
+
},
|
|
5454
|
+
{ count }
|
|
5455
|
+
),
|
|
5456
|
+
children: count
|
|
5457
|
+
}
|
|
5458
|
+
)
|
|
5459
|
+
] }) }, tab.id);
|
|
5460
|
+
})
|
|
5461
|
+
}
|
|
5462
|
+
) }) });
|
|
5463
|
+
};
|
|
5464
|
+
const BAR_SELECTOR = "[data-ltb-tabs-bar]";
|
|
5465
|
+
const SECTION_SELECTOR = "[data-ltb-tab-section]";
|
|
5466
|
+
function applySectionVisibility(marker, visible) {
|
|
5467
|
+
let panel = marker;
|
|
5468
|
+
while (panel?.parentElement && !panel.parentElement.querySelector(BAR_SELECTOR)) {
|
|
5469
|
+
panel = panel.parentElement;
|
|
5470
|
+
}
|
|
5471
|
+
if (!panel?.parentElement) return null;
|
|
5472
|
+
panel.style.display = "none";
|
|
5473
|
+
let sibling = panel.nextElementSibling;
|
|
5474
|
+
while (sibling && !sibling.querySelector(SECTION_SELECTOR) && !sibling.querySelector(BAR_SELECTOR)) {
|
|
5475
|
+
sibling.style.display = visible ? "" : "none";
|
|
5476
|
+
sibling = sibling.nextElementSibling;
|
|
5477
|
+
}
|
|
5478
|
+
return panel.parentElement;
|
|
5479
|
+
}
|
|
5480
|
+
const TabSection = ({ ltbTabKey = "" }) => {
|
|
5481
|
+
const ref = React.useRef(null);
|
|
5482
|
+
const active = React.useSyncExternalStore(tabsStore.subscribe, tabsStore.get);
|
|
5483
|
+
React.useLayoutEffect(() => {
|
|
5484
|
+
const marker = ref.current;
|
|
5485
|
+
if (!marker || active === null) return;
|
|
5486
|
+
const visible = active === ltbTabKey;
|
|
5487
|
+
const container = applySectionVisibility(marker, visible);
|
|
5488
|
+
if (!container) return;
|
|
5489
|
+
const observer = new MutationObserver(() => applySectionVisibility(marker, visible));
|
|
5490
|
+
observer.observe(container, { childList: true });
|
|
5491
|
+
return () => observer.disconnect();
|
|
5492
|
+
}, [active, ltbTabKey]);
|
|
5493
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ref, "data-ltb-tab-section": ltbTabKey, hidden: true });
|
|
5494
|
+
};
|
|
5495
|
+
const index = {
|
|
3300
5496
|
async register(app) {
|
|
3301
5497
|
app.addMenuLink({
|
|
3302
5498
|
to: `plugins/${config.pluginId}`,
|
|
@@ -3306,7 +5502,7 @@ const index = {
|
|
|
3306
5502
|
defaultMessage: config.pluginId
|
|
3307
5503
|
},
|
|
3308
5504
|
position: 999,
|
|
3309
|
-
Component: () => Promise.resolve().then(() => require("./App-
|
|
5505
|
+
Component: () => Promise.resolve().then(() => require("./App-B7_8BaVG.js"))
|
|
3310
5506
|
});
|
|
3311
5507
|
app.customFields.register({
|
|
3312
5508
|
name: "ltbslug",
|
|
@@ -3324,7 +5520,7 @@ const index = {
|
|
|
3324
5520
|
components: {
|
|
3325
5521
|
Input: async () => Promise.resolve().then(() => require(
|
|
3326
5522
|
/* webpackChunkName: "input-slug-component" */
|
|
3327
|
-
"./SlugInput-
|
|
5523
|
+
"./SlugInput-eCwgqJtH.js"
|
|
3328
5524
|
))
|
|
3329
5525
|
},
|
|
3330
5526
|
options: {
|
|
@@ -3358,13 +5554,18 @@ const index = {
|
|
|
3358
5554
|
],
|
|
3359
5555
|
advanced: [],
|
|
3360
5556
|
validator: (args) => ({
|
|
3361
|
-
targetField: create().required({
|
|
5557
|
+
targetField: create$2().required({
|
|
3362
5558
|
id: getTranslation(`module.${config.uuid.modules.slug}.field.slug.target.error`),
|
|
3363
5559
|
defaultMessage: "The target field is required"
|
|
3364
5560
|
})
|
|
3365
5561
|
})
|
|
3366
5562
|
}
|
|
3367
5563
|
});
|
|
5564
|
+
app.addFields([
|
|
5565
|
+
{ type: TABS_BAR_FIELD_TYPE, Component: TabsBar },
|
|
5566
|
+
{ type: TABS_SECTION_FIELD_TYPE, Component: TabSection }
|
|
5567
|
+
]);
|
|
5568
|
+
startTabBadges(app);
|
|
3368
5569
|
app.registerPlugin({
|
|
3369
5570
|
id: config.pluginId,
|
|
3370
5571
|
initializer: Initializer,
|
|
@@ -3376,7 +5577,7 @@ const index = {
|
|
|
3376
5577
|
return Promise.all(
|
|
3377
5578
|
locales.map(async (locale) => {
|
|
3378
5579
|
try {
|
|
3379
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => Promise.resolve().then(() => require("./en-
|
|
5580
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => Promise.resolve().then(() => require("./en-D89cXiov.js")) }), `./core/translations/${locale}.json`, 4);
|
|
3380
5581
|
return { data, locale };
|
|
3381
5582
|
} catch {
|
|
3382
5583
|
return { data: {}, locale };
|
|
@@ -3395,10 +5596,22 @@ const index = {
|
|
|
3395
5596
|
Registry.getInstance().provide("menuGateway", new MenuGatewayHttp());
|
|
3396
5597
|
Registry.getInstance().provide("parameterGateway", new ParameterGatewayHttp());
|
|
3397
5598
|
Registry.getInstance().provide("translationGateway", new TranslationGatewayHttp());
|
|
3398
|
-
|
|
5599
|
+
Registry.getInstance().provide("documentGateway", new DocumentGatewayHttp());
|
|
5600
|
+
Registry.getInstance().provide("aiGateway", new AiGatewayHttp());
|
|
5601
|
+
app.getPlugin("content-manager").apis.addEditViewSidePanel([
|
|
5602
|
+
PageAttributesBox,
|
|
5603
|
+
DocumentTranslateBox
|
|
5604
|
+
]);
|
|
5605
|
+
registerTabsInContentTypeBuilder(app);
|
|
5606
|
+
app.registerHook(
|
|
5607
|
+
"Admin/CM/pages/EditView/mutate-edit-view-layout",
|
|
5608
|
+
(args) => mutateEditViewLayout(args)
|
|
5609
|
+
);
|
|
3399
5610
|
}
|
|
3400
5611
|
};
|
|
5612
|
+
exports.AI_TRANSLATION_DEFAULT_MODEL = AI_TRANSLATION_DEFAULT_MODEL;
|
|
3401
5613
|
exports.DocumentCustomFieldStarted = DocumentCustomFieldStarted;
|
|
5614
|
+
exports.FetchLocales = FetchLocales;
|
|
3402
5615
|
exports.FetchModuleSettings = FetchModuleSettings;
|
|
3403
5616
|
exports.FetchSettings = FetchSettings;
|
|
3404
5617
|
exports.FetchSlugs = FetchSlugs;
|
|
@@ -3408,6 +5621,7 @@ exports.Registry = Registry;
|
|
|
3408
5621
|
exports.SLUG_CONTENT_STRATEGY = SLUG_CONTENT_STRATEGY;
|
|
3409
5622
|
exports.SLUG_LANGUAGE_STRATEGY = SLUG_LANGUAGE_STRATEGY;
|
|
3410
5623
|
exports.config = config;
|
|
5624
|
+
exports.convertToSlug = convertToSlug;
|
|
3411
5625
|
exports.fetchTemplates = fetchTemplates;
|
|
3412
5626
|
exports.getTranslation = getTranslation;
|
|
3413
5627
|
exports.index = index;
|