@littlebox/strapi-suite 1.0.52 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{App-C1HyspTk.mjs → App-CwdSC1Y7.mjs} +2 -2
- package/dist/_chunks/{App-C-h--Kv_.js → App-v4u-QmyQ.js} +2 -2
- package/dist/_chunks/{SlugInput-3gkr6B0t.js → SlugInput-B5yuoNLc.js} +1 -1
- package/dist/_chunks/{SlugInput-CU9_b0dd.mjs → SlugInput-xtNYx9gU.mjs} +1 -1
- package/dist/_chunks/{en-CLNZnNeq.js → en-D89cXiov.js} +16 -1
- package/dist/_chunks/{en-F6RYx79c.mjs → en-knG97mCH.mjs} +16 -1
- package/dist/_chunks/{index-DQ3vX9So.mjs → index-Do7CxfkQ.mjs} +1632 -65
- package/dist/_chunks/{index-60sq8G6p.js → index-Ml4j6jxD.js} +1629 -62
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- 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 +426 -313
- package/dist/server/index.mjs +426 -313
- package/dist/server/src/middlewares/tabs.d.ts +4 -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
|
@@ -7,6 +7,10 @@ const designSystem = require("@strapi/design-system");
|
|
|
7
7
|
const reactIntl = require("react-intl");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
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");
|
|
10
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
11
15
|
function _interopNamespace(e) {
|
|
12
16
|
if (e && e.__esModule) return e;
|
|
@@ -92,7 +96,7 @@ function baseClone(src, circulars, clones) {
|
|
|
92
96
|
function clone(src) {
|
|
93
97
|
return baseClone(src, [], []);
|
|
94
98
|
}
|
|
95
|
-
const toString$
|
|
99
|
+
const toString$6 = Object.prototype.toString;
|
|
96
100
|
const errorToString = Error.prototype.toString;
|
|
97
101
|
const regExpToString = RegExp.prototype.toString;
|
|
98
102
|
const symbolToString$1 = typeof Symbol !== "undefined" ? Symbol.prototype.toString : () => "";
|
|
@@ -109,7 +113,7 @@ function printSimpleValue(val, quoteStrings = false) {
|
|
|
109
113
|
if (typeOf === "string") return quoteStrings ? `"${val}"` : val;
|
|
110
114
|
if (typeOf === "function") return "[Function " + (val.name || "anonymous") + "]";
|
|
111
115
|
if (typeOf === "symbol") return symbolToString$1.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
|
112
|
-
const tag = toString$
|
|
116
|
+
const tag = toString$6.call(val).slice(8, -1);
|
|
113
117
|
if (tag === "Date") return isNaN(val.getTime()) ? "" + val : val.toISOString(val);
|
|
114
118
|
if (tag === "Error" || val instanceof Error) return "[" + errorToString.call(val) + "]";
|
|
115
119
|
if (tag === "RegExp") return regExpToString.call(val);
|
|
@@ -273,15 +277,15 @@ function isKey$3(value, object2) {
|
|
|
273
277
|
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object2 != null && value in Object(object2);
|
|
274
278
|
}
|
|
275
279
|
var _isKey = isKey$3;
|
|
276
|
-
function isObject$
|
|
280
|
+
function isObject$4(value) {
|
|
277
281
|
var type = typeof value;
|
|
278
282
|
return value != null && (type == "object" || type == "function");
|
|
279
283
|
}
|
|
280
|
-
var isObject_1 = isObject$
|
|
281
|
-
var baseGetTag$3 = _baseGetTag, isObject$
|
|
284
|
+
var isObject_1 = isObject$4;
|
|
285
|
+
var baseGetTag$3 = _baseGetTag, isObject$3 = isObject_1;
|
|
282
286
|
var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
283
287
|
function isFunction$2(value) {
|
|
284
|
-
if (!isObject$
|
|
288
|
+
if (!isObject$3(value)) {
|
|
285
289
|
return false;
|
|
286
290
|
}
|
|
287
291
|
var tag = baseGetTag$3(value);
|
|
@@ -316,7 +320,7 @@ function toSource$2(func) {
|
|
|
316
320
|
return "";
|
|
317
321
|
}
|
|
318
322
|
var _toSource = toSource$2;
|
|
319
|
-
var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$
|
|
323
|
+
var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$2 = isObject_1, toSource$1 = _toSource;
|
|
320
324
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
321
325
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
322
326
|
var funcProto = Function.prototype, objectProto$9 = Object.prototype;
|
|
@@ -326,7 +330,7 @@ var reIsNative = RegExp(
|
|
|
326
330
|
"^" + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
327
331
|
);
|
|
328
332
|
function baseIsNative$1(value) {
|
|
329
|
-
if (!isObject$
|
|
333
|
+
if (!isObject$2(value) || isMasked(value)) {
|
|
330
334
|
return false;
|
|
331
335
|
}
|
|
332
336
|
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
@@ -615,16 +619,16 @@ function baseToString$1(value) {
|
|
|
615
619
|
}
|
|
616
620
|
var _baseToString = baseToString$1;
|
|
617
621
|
var baseToString = _baseToString;
|
|
618
|
-
function toString$
|
|
622
|
+
function toString$5(value) {
|
|
619
623
|
return value == null ? "" : baseToString(value);
|
|
620
624
|
}
|
|
621
|
-
var toString_1 = toString$
|
|
622
|
-
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;
|
|
623
627
|
function castPath$2(value, object2) {
|
|
624
628
|
if (isArray$5(value)) {
|
|
625
629
|
return value;
|
|
626
630
|
}
|
|
627
|
-
return isKey$2(value, object2) ? [value] : stringToPath(toString(value));
|
|
631
|
+
return isKey$2(value, object2) ? [value] : stringToPath(toString$4(value));
|
|
628
632
|
}
|
|
629
633
|
var _castPath = castPath$2;
|
|
630
634
|
var baseGetTag$2 = _baseGetTag, isObjectLike$3 = isObjectLike_1;
|
|
@@ -726,8 +730,8 @@ class Condition {
|
|
|
726
730
|
function toArray(value) {
|
|
727
731
|
return value == null ? [] : [].concat(value);
|
|
728
732
|
}
|
|
729
|
-
function _extends$
|
|
730
|
-
_extends$
|
|
733
|
+
function _extends$4() {
|
|
734
|
+
_extends$4 = Object.assign || function(target) {
|
|
731
735
|
for (var i = 1; i < arguments.length; i++) {
|
|
732
736
|
var source = arguments[i];
|
|
733
737
|
for (var key in source) {
|
|
@@ -738,13 +742,13 @@ function _extends$2() {
|
|
|
738
742
|
}
|
|
739
743
|
return target;
|
|
740
744
|
};
|
|
741
|
-
return _extends$
|
|
745
|
+
return _extends$4.apply(this, arguments);
|
|
742
746
|
}
|
|
743
747
|
let strReg = /\$\{\s*(\w+)\s*\}/g;
|
|
744
748
|
class ValidationError extends Error {
|
|
745
749
|
static formatError(message, params) {
|
|
746
750
|
const path = params.label || params.path || "this";
|
|
747
|
-
if (path !== params.path) params = _extends$
|
|
751
|
+
if (path !== params.path) params = _extends$4({}, params, {
|
|
748
752
|
path
|
|
749
753
|
});
|
|
750
754
|
if (typeof message === "string") return message.replace(strReg, (_, key) => printValue(params[key]));
|
|
@@ -836,7 +840,7 @@ var defineProperty$1 = function() {
|
|
|
836
840
|
}();
|
|
837
841
|
var _defineProperty = defineProperty$1;
|
|
838
842
|
var defineProperty = _defineProperty;
|
|
839
|
-
function baseAssignValue$
|
|
843
|
+
function baseAssignValue$2(object2, key, value) {
|
|
840
844
|
if (key == "__proto__" && defineProperty) {
|
|
841
845
|
defineProperty(object2, key, {
|
|
842
846
|
"configurable": true,
|
|
@@ -848,7 +852,7 @@ function baseAssignValue$1(object2, key, value) {
|
|
|
848
852
|
object2[key] = value;
|
|
849
853
|
}
|
|
850
854
|
}
|
|
851
|
-
var _baseAssignValue = baseAssignValue$
|
|
855
|
+
var _baseAssignValue = baseAssignValue$2;
|
|
852
856
|
function createBaseFor$1(fromRight) {
|
|
853
857
|
return function(object2, iteratee, keysFunc) {
|
|
854
858
|
var index2 = -1, iterable = Object(object2), props = keysFunc(object2), length = props.length;
|
|
@@ -990,10 +994,10 @@ function keys$3(object2) {
|
|
|
990
994
|
}
|
|
991
995
|
var keys_1 = keys$3;
|
|
992
996
|
var baseFor = _baseFor, keys$2 = keys_1;
|
|
993
|
-
function baseForOwn$
|
|
997
|
+
function baseForOwn$2(object2, iteratee) {
|
|
994
998
|
return object2 && baseFor(object2, iteratee, keys$2);
|
|
995
999
|
}
|
|
996
|
-
var _baseForOwn = baseForOwn$
|
|
1000
|
+
var _baseForOwn = baseForOwn$2;
|
|
997
1001
|
var ListCache$2 = _ListCache;
|
|
998
1002
|
function stackClear$1() {
|
|
999
1003
|
this.__data__ = new ListCache$2();
|
|
@@ -1410,9 +1414,9 @@ function baseIsMatch$1(object2, source, matchData, customizer) {
|
|
|
1410
1414
|
return true;
|
|
1411
1415
|
}
|
|
1412
1416
|
var _baseIsMatch = baseIsMatch$1;
|
|
1413
|
-
var isObject = isObject_1;
|
|
1417
|
+
var isObject$1 = isObject_1;
|
|
1414
1418
|
function isStrictComparable$2(value) {
|
|
1415
|
-
return value === value && !isObject(value);
|
|
1419
|
+
return value === value && !isObject$1(value);
|
|
1416
1420
|
}
|
|
1417
1421
|
var _isStrictComparable = isStrictComparable$2;
|
|
1418
1422
|
var isStrictComparable$1 = _isStrictComparable, keys = keys_1;
|
|
@@ -1505,7 +1509,7 @@ function property$1(path) {
|
|
|
1505
1509
|
}
|
|
1506
1510
|
var property_1 = property$1;
|
|
1507
1511
|
var baseMatches = _baseMatches, baseMatchesProperty = _baseMatchesProperty, identity = identity_1, isArray = isArray_1, property = property_1;
|
|
1508
|
-
function baseIteratee$
|
|
1512
|
+
function baseIteratee$2(value) {
|
|
1509
1513
|
if (typeof value == "function") {
|
|
1510
1514
|
return value;
|
|
1511
1515
|
}
|
|
@@ -1517,13 +1521,13 @@ function baseIteratee$1(value) {
|
|
|
1517
1521
|
}
|
|
1518
1522
|
return property(value);
|
|
1519
1523
|
}
|
|
1520
|
-
var _baseIteratee = baseIteratee$
|
|
1521
|
-
var baseAssignValue = _baseAssignValue, baseForOwn = _baseForOwn, baseIteratee = _baseIteratee;
|
|
1524
|
+
var _baseIteratee = baseIteratee$2;
|
|
1525
|
+
var baseAssignValue$1 = _baseAssignValue, baseForOwn$1 = _baseForOwn, baseIteratee$1 = _baseIteratee;
|
|
1522
1526
|
function mapValues(object2, iteratee) {
|
|
1523
1527
|
var result = {};
|
|
1524
|
-
iteratee = baseIteratee(iteratee);
|
|
1525
|
-
baseForOwn(object2, function(value, key, object3) {
|
|
1526
|
-
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));
|
|
1527
1531
|
});
|
|
1528
1532
|
return result;
|
|
1529
1533
|
}
|
|
@@ -1674,8 +1678,8 @@ class Reference {
|
|
|
1674
1678
|
}
|
|
1675
1679
|
}
|
|
1676
1680
|
Reference.prototype.__isYupRef = true;
|
|
1677
|
-
function _extends$
|
|
1678
|
-
_extends$
|
|
1681
|
+
function _extends$3() {
|
|
1682
|
+
_extends$3 = Object.assign || function(target) {
|
|
1679
1683
|
for (var i = 1; i < arguments.length; i++) {
|
|
1680
1684
|
var source = arguments[i];
|
|
1681
1685
|
for (var key in source) {
|
|
@@ -1686,7 +1690,7 @@ function _extends$1() {
|
|
|
1686
1690
|
}
|
|
1687
1691
|
return target;
|
|
1688
1692
|
};
|
|
1689
|
-
return _extends$
|
|
1693
|
+
return _extends$3.apply(this, arguments);
|
|
1690
1694
|
}
|
|
1691
1695
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
1692
1696
|
if (source == null) return {};
|
|
@@ -1724,7 +1728,7 @@ function createValidation(config2) {
|
|
|
1724
1728
|
return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
|
|
1725
1729
|
}
|
|
1726
1730
|
function createError(overrides = {}) {
|
|
1727
|
-
const nextParams = mapValues$1(_extends$
|
|
1731
|
+
const nextParams = mapValues$1(_extends$3({
|
|
1728
1732
|
value,
|
|
1729
1733
|
originalValue,
|
|
1730
1734
|
label,
|
|
@@ -1734,7 +1738,7 @@ function createValidation(config2) {
|
|
|
1734
1738
|
error.params = nextParams;
|
|
1735
1739
|
return error;
|
|
1736
1740
|
}
|
|
1737
|
-
let ctx = _extends$
|
|
1741
|
+
let ctx = _extends$3({
|
|
1738
1742
|
path,
|
|
1739
1743
|
parent,
|
|
1740
1744
|
type: name,
|
|
@@ -1856,8 +1860,8 @@ class ReferenceSet {
|
|
|
1856
1860
|
return next;
|
|
1857
1861
|
}
|
|
1858
1862
|
}
|
|
1859
|
-
function _extends() {
|
|
1860
|
-
_extends = Object.assign || function(target) {
|
|
1863
|
+
function _extends$2() {
|
|
1864
|
+
_extends$2 = Object.assign || function(target) {
|
|
1861
1865
|
for (var i = 1; i < arguments.length; i++) {
|
|
1862
1866
|
var source = arguments[i];
|
|
1863
1867
|
for (var key in source) {
|
|
@@ -1868,7 +1872,7 @@ function _extends() {
|
|
|
1868
1872
|
}
|
|
1869
1873
|
return target;
|
|
1870
1874
|
};
|
|
1871
|
-
return _extends.apply(this, arguments);
|
|
1875
|
+
return _extends$2.apply(this, arguments);
|
|
1872
1876
|
}
|
|
1873
1877
|
class BaseSchema {
|
|
1874
1878
|
constructor(options) {
|
|
@@ -1883,7 +1887,7 @@ class BaseSchema {
|
|
|
1883
1887
|
this.typeError(mixed.notType);
|
|
1884
1888
|
});
|
|
1885
1889
|
this.type = (options == null ? void 0 : options.type) || "mixed";
|
|
1886
|
-
this.spec = _extends({
|
|
1890
|
+
this.spec = _extends$2({
|
|
1887
1891
|
strip: false,
|
|
1888
1892
|
strict: false,
|
|
1889
1893
|
abortEarly: true,
|
|
@@ -1911,12 +1915,12 @@ class BaseSchema {
|
|
|
1911
1915
|
next._blacklistError = this._blacklistError;
|
|
1912
1916
|
next._whitelist = this._whitelist.clone();
|
|
1913
1917
|
next._blacklist = this._blacklist.clone();
|
|
1914
|
-
next.exclusiveTests = _extends({}, this.exclusiveTests);
|
|
1918
|
+
next.exclusiveTests = _extends$2({}, this.exclusiveTests);
|
|
1915
1919
|
next.deps = [...this.deps];
|
|
1916
1920
|
next.conditions = [...this.conditions];
|
|
1917
1921
|
next.tests = [...this.tests];
|
|
1918
1922
|
next.transforms = [...this.transforms];
|
|
1919
|
-
next.spec = clone(_extends({}, this.spec, spec));
|
|
1923
|
+
next.spec = clone(_extends$2({}, this.spec, spec));
|
|
1920
1924
|
return next;
|
|
1921
1925
|
}
|
|
1922
1926
|
label(label) {
|
|
@@ -1949,7 +1953,7 @@ class BaseSchema {
|
|
|
1949
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}`);
|
|
1950
1954
|
let base = this;
|
|
1951
1955
|
let combined = schema.clone();
|
|
1952
|
-
const mergedSpec = _extends({}, base.spec, combined.spec);
|
|
1956
|
+
const mergedSpec = _extends$2({}, base.spec, combined.spec);
|
|
1953
1957
|
combined.spec = mergedSpec;
|
|
1954
1958
|
combined._typeError || (combined._typeError = base._typeError);
|
|
1955
1959
|
combined._whitelistError || (combined._whitelistError = base._whitelistError);
|
|
@@ -1988,7 +1992,7 @@ class BaseSchema {
|
|
|
1988
1992
|
* @param {*=} options.context
|
|
1989
1993
|
*/
|
|
1990
1994
|
cast(value, options = {}) {
|
|
1991
|
-
let resolvedSchema = this.resolve(_extends({
|
|
1995
|
+
let resolvedSchema = this.resolve(_extends$2({
|
|
1992
1996
|
value
|
|
1993
1997
|
}, options));
|
|
1994
1998
|
let result = resolvedSchema._cast(value, options);
|
|
@@ -2020,7 +2024,7 @@ attempted value: ${formattedValue}
|
|
|
2020
2024
|
} = options;
|
|
2021
2025
|
let value = _value;
|
|
2022
2026
|
if (!strict) {
|
|
2023
|
-
value = this._cast(value, _extends({
|
|
2027
|
+
value = this._cast(value, _extends$2({
|
|
2024
2028
|
assert: false
|
|
2025
2029
|
}, options));
|
|
2026
2030
|
}
|
|
@@ -2057,7 +2061,7 @@ attempted value: ${formattedValue}
|
|
|
2057
2061
|
});
|
|
2058
2062
|
}
|
|
2059
2063
|
validate(value, options, maybeCb) {
|
|
2060
|
-
let schema = this.resolve(_extends({}, options, {
|
|
2064
|
+
let schema = this.resolve(_extends$2({}, options, {
|
|
2061
2065
|
value
|
|
2062
2066
|
}));
|
|
2063
2067
|
return typeof maybeCb === "function" ? schema._validate(value, options, maybeCb) : new Promise((resolve, reject) => schema._validate(value, options, (err, value2) => {
|
|
@@ -2066,11 +2070,11 @@ attempted value: ${formattedValue}
|
|
|
2066
2070
|
}));
|
|
2067
2071
|
}
|
|
2068
2072
|
validateSync(value, options) {
|
|
2069
|
-
let schema = this.resolve(_extends({}, options, {
|
|
2073
|
+
let schema = this.resolve(_extends$2({}, options, {
|
|
2070
2074
|
value
|
|
2071
2075
|
}));
|
|
2072
2076
|
let result;
|
|
2073
|
-
schema._validate(value, _extends({}, options, {
|
|
2077
|
+
schema._validate(value, _extends$2({}, options, {
|
|
2074
2078
|
sync: true
|
|
2075
2079
|
}), (err, value2) => {
|
|
2076
2080
|
if (err) throw err;
|
|
@@ -2318,7 +2322,7 @@ for (const method of ["validate", "validateSync"]) BaseSchema.prototype[`${metho
|
|
|
2318
2322
|
parentPath,
|
|
2319
2323
|
schema
|
|
2320
2324
|
} = getIn(this, path, value, options.context);
|
|
2321
|
-
return schema[method](parent && parent[parentPath], _extends({}, options, {
|
|
2325
|
+
return schema[method](parent && parent[parentPath], _extends$2({}, options, {
|
|
2322
2326
|
parent,
|
|
2323
2327
|
path
|
|
2324
2328
|
}));
|
|
@@ -2332,7 +2336,7 @@ let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFD
|
|
|
2332
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;
|
|
2333
2337
|
let isTrimmed = (value) => isAbsent(value) || value === value.trim();
|
|
2334
2338
|
let objStringTag = {}.toString();
|
|
2335
|
-
function create() {
|
|
2339
|
+
function create$2() {
|
|
2336
2340
|
return new StringSchema();
|
|
2337
2341
|
}
|
|
2338
2342
|
class StringSchema extends BaseSchema {
|
|
@@ -2469,7 +2473,7 @@ class StringSchema extends BaseSchema {
|
|
|
2469
2473
|
});
|
|
2470
2474
|
}
|
|
2471
2475
|
}
|
|
2472
|
-
create.prototype = StringSchema.prototype;
|
|
2476
|
+
create$2.prototype = StringSchema.prototype;
|
|
2473
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}))?)?)?$/;
|
|
2474
2478
|
function parseIsoDate(date2) {
|
|
2475
2479
|
var numericKeys = [1, 4, 5, 6, 7, 10, 11], minutesOffset = 0, timestamp, struct;
|
|
@@ -2548,11 +2552,373 @@ class DateSchema extends BaseSchema {
|
|
|
2548
2552
|
}
|
|
2549
2553
|
}
|
|
2550
2554
|
DateSchema.INVALID_DATE = invalidDate;
|
|
2551
|
-
|
|
2552
|
-
|
|
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) {
|
|
2553
2919
|
return toposort(uniqueNodes(edges), edges);
|
|
2554
2920
|
};
|
|
2555
|
-
toposort$
|
|
2921
|
+
toposort$2.exports.array = toposort;
|
|
2556
2922
|
function toposort(nodes, edges) {
|
|
2557
2923
|
var cursor = nodes.length, sorted = new Array(cursor), visited = {}, i = cursor, outgoingEdges = makeOutgoingEdges(edges), nodesHash = makeNodesHash(nodes);
|
|
2558
2924
|
edges.forEach(function(edge) {
|
|
@@ -2618,6 +2984,510 @@ function makeNodesHash(arr) {
|
|
|
2618
2984
|
}
|
|
2619
2985
|
return res;
|
|
2620
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;
|
|
2621
3491
|
const PLUGIN_ID = "littlebox-strapi-suite";
|
|
2622
3492
|
const SLUG_LANGUAGE_STRATEGY = "language";
|
|
2623
3493
|
const SLUG_CONTENT_STRATEGY = "content";
|
|
@@ -3065,7 +3935,7 @@ const DangerModal = ({ open, title, text, button }) => {
|
|
|
3065
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 }) }) })
|
|
3066
3936
|
] }) }) });
|
|
3067
3937
|
};
|
|
3068
|
-
const PageAttributesBox = ({ document }) => {
|
|
3938
|
+
const PageAttributesBox = ({ document: document2 }) => {
|
|
3069
3939
|
const { formatMessage } = reactIntl.useIntl();
|
|
3070
3940
|
const location = reactRouterDom.useLocation();
|
|
3071
3941
|
const { form } = admin.unstable_useContentManagerContext();
|
|
@@ -3114,13 +3984,13 @@ const PageAttributesBox = ({ document }) => {
|
|
|
3114
3984
|
form.onChange(mockEvent);
|
|
3115
3985
|
}
|
|
3116
3986
|
async function fectchAttributes() {
|
|
3117
|
-
if (
|
|
3987
|
+
if (document2 && document2.documentId) {
|
|
3118
3988
|
const fetchDocumentAttributes$1 = new fetchDocumentAttributes();
|
|
3119
3989
|
const outputFetchDocumentAttributes = await fetchDocumentAttributes$1.execute(
|
|
3120
|
-
|
|
3990
|
+
document2.documentId,
|
|
3121
3991
|
{
|
|
3122
3992
|
locale: getCurrentLocate(),
|
|
3123
|
-
state:
|
|
3993
|
+
state: document2.publishedAt ? "published" : "draft"
|
|
3124
3994
|
}
|
|
3125
3995
|
);
|
|
3126
3996
|
setAttributes(outputFetchDocumentAttributes);
|
|
@@ -3131,7 +4001,7 @@ const PageAttributesBox = ({ document }) => {
|
|
|
3131
4001
|
const outputFetchSlugs = await fetchSlugs.execute({ locale: getCurrentLocate() });
|
|
3132
4002
|
const filteredParents = [];
|
|
3133
4003
|
outputFetchSlugs.forEach((parent) => {
|
|
3134
|
-
if (!
|
|
4004
|
+
if (!document2 || parent.contentId !== document2.documentId) {
|
|
3135
4005
|
filteredParents.push(parent);
|
|
3136
4006
|
}
|
|
3137
4007
|
});
|
|
@@ -3835,7 +4705,7 @@ const DocumentTranslateModal = ({ open, locales, targetLocale, translate, close
|
|
|
3835
4705
|
] })
|
|
3836
4706
|
] }) }) });
|
|
3837
4707
|
};
|
|
3838
|
-
const DocumentTranslateBox = ({ document }) => {
|
|
4708
|
+
const DocumentTranslateBox = ({ document: document2 }) => {
|
|
3839
4709
|
const { formatMessage } = reactIntl.useIntl();
|
|
3840
4710
|
const context = admin.unstable_useContentManagerContext();
|
|
3841
4711
|
const [appSettings, setAppSettings] = React__namespace.useState();
|
|
@@ -3869,7 +4739,7 @@ const DocumentTranslateBox = ({ document }) => {
|
|
|
3869
4739
|
});
|
|
3870
4740
|
}
|
|
3871
4741
|
function getDocumentId() {
|
|
3872
|
-
const documentId =
|
|
4742
|
+
const documentId = document2?.documentId || context.id;
|
|
3873
4743
|
return documentId && documentId !== "create" ? documentId : void 0;
|
|
3874
4744
|
}
|
|
3875
4745
|
async function translate(sourceLocale, overwrite) {
|
|
@@ -3935,6 +4805,693 @@ const DocumentTranslateBox = ({ document }) => {
|
|
|
3935
4805
|
] })
|
|
3936
4806
|
};
|
|
3937
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
|
+
};
|
|
3938
5495
|
const index = {
|
|
3939
5496
|
async register(app) {
|
|
3940
5497
|
app.addMenuLink({
|
|
@@ -3945,7 +5502,7 @@ const index = {
|
|
|
3945
5502
|
defaultMessage: config.pluginId
|
|
3946
5503
|
},
|
|
3947
5504
|
position: 999,
|
|
3948
|
-
Component: () => Promise.resolve().then(() => require("./App-
|
|
5505
|
+
Component: () => Promise.resolve().then(() => require("./App-v4u-QmyQ.js"))
|
|
3949
5506
|
});
|
|
3950
5507
|
app.customFields.register({
|
|
3951
5508
|
name: "ltbslug",
|
|
@@ -3963,7 +5520,7 @@ const index = {
|
|
|
3963
5520
|
components: {
|
|
3964
5521
|
Input: async () => Promise.resolve().then(() => require(
|
|
3965
5522
|
/* webpackChunkName: "input-slug-component" */
|
|
3966
|
-
"./SlugInput-
|
|
5523
|
+
"./SlugInput-B5yuoNLc.js"
|
|
3967
5524
|
))
|
|
3968
5525
|
},
|
|
3969
5526
|
options: {
|
|
@@ -3997,13 +5554,18 @@ const index = {
|
|
|
3997
5554
|
],
|
|
3998
5555
|
advanced: [],
|
|
3999
5556
|
validator: (args) => ({
|
|
4000
|
-
targetField: create().required({
|
|
5557
|
+
targetField: create$2().required({
|
|
4001
5558
|
id: getTranslation(`module.${config.uuid.modules.slug}.field.slug.target.error`),
|
|
4002
5559
|
defaultMessage: "The target field is required"
|
|
4003
5560
|
})
|
|
4004
5561
|
})
|
|
4005
5562
|
}
|
|
4006
5563
|
});
|
|
5564
|
+
app.addFields([
|
|
5565
|
+
{ type: TABS_BAR_FIELD_TYPE, Component: TabsBar },
|
|
5566
|
+
{ type: TABS_SECTION_FIELD_TYPE, Component: TabSection }
|
|
5567
|
+
]);
|
|
5568
|
+
startTabBadges(app);
|
|
4007
5569
|
app.registerPlugin({
|
|
4008
5570
|
id: config.pluginId,
|
|
4009
5571
|
initializer: Initializer,
|
|
@@ -4015,7 +5577,7 @@ const index = {
|
|
|
4015
5577
|
return Promise.all(
|
|
4016
5578
|
locales.map(async (locale) => {
|
|
4017
5579
|
try {
|
|
4018
|
-
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);
|
|
4019
5581
|
return { data, locale };
|
|
4020
5582
|
} catch {
|
|
4021
5583
|
return { data: {}, locale };
|
|
@@ -4040,6 +5602,11 @@ const index = {
|
|
|
4040
5602
|
PageAttributesBox,
|
|
4041
5603
|
DocumentTranslateBox
|
|
4042
5604
|
]);
|
|
5605
|
+
registerTabsInContentTypeBuilder(app);
|
|
5606
|
+
app.registerHook(
|
|
5607
|
+
"Admin/CM/pages/EditView/mutate-edit-view-layout",
|
|
5608
|
+
(args) => mutateEditViewLayout(args)
|
|
5609
|
+
);
|
|
4043
5610
|
}
|
|
4044
5611
|
};
|
|
4045
5612
|
exports.AI_TRANSLATION_DEFAULT_MODEL = AI_TRANSLATION_DEFAULT_MODEL;
|