@tunghtml/strapi-plugin-composite-field 1.1.7 → 1.1.10
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.
|
@@ -1,8 +1,466 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import React__default from "react";
|
|
4
2
|
import { Field, Flex, Button, Typography } from "@strapi/design-system";
|
|
5
3
|
import { Play } from "@strapi/icons";
|
|
4
|
+
import { unstable_useContentManagerContext } from "@strapi/strapi/admin";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import React__default from "react";
|
|
7
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
8
|
+
function getDefaultExportFromCjs(x) {
|
|
9
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
10
|
+
}
|
|
11
|
+
var isArray$3 = Array.isArray;
|
|
12
|
+
var isArray_1 = isArray$3;
|
|
13
|
+
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
14
|
+
var _freeGlobal = freeGlobal$1;
|
|
15
|
+
var freeGlobal = _freeGlobal;
|
|
16
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
17
|
+
var root$3 = freeGlobal || freeSelf || Function("return this")();
|
|
18
|
+
var _root = root$3;
|
|
19
|
+
var root$2 = _root;
|
|
20
|
+
var Symbol$4 = root$2.Symbol;
|
|
21
|
+
var _Symbol = Symbol$4;
|
|
22
|
+
var Symbol$3 = _Symbol;
|
|
23
|
+
var objectProto$4 = Object.prototype;
|
|
24
|
+
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
25
|
+
var nativeObjectToString$1 = objectProto$4.toString;
|
|
26
|
+
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
27
|
+
function getRawTag$1(value) {
|
|
28
|
+
var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
29
|
+
try {
|
|
30
|
+
value[symToStringTag$1] = void 0;
|
|
31
|
+
var unmasked = true;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
}
|
|
34
|
+
var result = nativeObjectToString$1.call(value);
|
|
35
|
+
if (unmasked) {
|
|
36
|
+
if (isOwn) {
|
|
37
|
+
value[symToStringTag$1] = tag;
|
|
38
|
+
} else {
|
|
39
|
+
delete value[symToStringTag$1];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
var _getRawTag = getRawTag$1;
|
|
45
|
+
var objectProto$3 = Object.prototype;
|
|
46
|
+
var nativeObjectToString = objectProto$3.toString;
|
|
47
|
+
function objectToString$1(value) {
|
|
48
|
+
return nativeObjectToString.call(value);
|
|
49
|
+
}
|
|
50
|
+
var _objectToString = objectToString$1;
|
|
51
|
+
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
52
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
53
|
+
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
54
|
+
function baseGetTag$2(value) {
|
|
55
|
+
if (value == null) {
|
|
56
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
57
|
+
}
|
|
58
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
59
|
+
}
|
|
60
|
+
var _baseGetTag = baseGetTag$2;
|
|
61
|
+
function isObjectLike$1(value) {
|
|
62
|
+
return value != null && typeof value == "object";
|
|
63
|
+
}
|
|
64
|
+
var isObjectLike_1 = isObjectLike$1;
|
|
65
|
+
var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
|
|
66
|
+
var symbolTag = "[object Symbol]";
|
|
67
|
+
function isSymbol$3(value) {
|
|
68
|
+
return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
69
|
+
}
|
|
70
|
+
var isSymbol_1 = isSymbol$3;
|
|
71
|
+
var isArray$2 = isArray_1, isSymbol$2 = isSymbol_1;
|
|
72
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
|
|
73
|
+
function isKey$1(value, object) {
|
|
74
|
+
if (isArray$2(value)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
var type = typeof value;
|
|
78
|
+
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$2(value)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
82
|
+
}
|
|
83
|
+
var _isKey = isKey$1;
|
|
84
|
+
function isObject$2(value) {
|
|
85
|
+
var type = typeof value;
|
|
86
|
+
return value != null && (type == "object" || type == "function");
|
|
87
|
+
}
|
|
88
|
+
var isObject_1 = isObject$2;
|
|
89
|
+
var baseGetTag = _baseGetTag, isObject$1 = isObject_1;
|
|
90
|
+
var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
91
|
+
function isFunction$1(value) {
|
|
92
|
+
if (!isObject$1(value)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
var tag = baseGetTag(value);
|
|
96
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
97
|
+
}
|
|
98
|
+
var isFunction_1 = isFunction$1;
|
|
99
|
+
var root$1 = _root;
|
|
100
|
+
var coreJsData$1 = root$1["__core-js_shared__"];
|
|
101
|
+
var _coreJsData = coreJsData$1;
|
|
102
|
+
var coreJsData = _coreJsData;
|
|
103
|
+
var maskSrcKey = function() {
|
|
104
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
|
|
105
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
106
|
+
}();
|
|
107
|
+
function isMasked$1(func) {
|
|
108
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
109
|
+
}
|
|
110
|
+
var _isMasked = isMasked$1;
|
|
111
|
+
var funcProto$1 = Function.prototype;
|
|
112
|
+
var funcToString$1 = funcProto$1.toString;
|
|
113
|
+
function toSource$1(func) {
|
|
114
|
+
if (func != null) {
|
|
115
|
+
try {
|
|
116
|
+
return funcToString$1.call(func);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return func + "";
|
|
121
|
+
} catch (e) {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return "";
|
|
125
|
+
}
|
|
126
|
+
var _toSource = toSource$1;
|
|
127
|
+
var isFunction = isFunction_1, isMasked = _isMasked, isObject = isObject_1, toSource = _toSource;
|
|
128
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
129
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
130
|
+
var funcProto = Function.prototype, objectProto$2 = Object.prototype;
|
|
131
|
+
var funcToString = funcProto.toString;
|
|
132
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
133
|
+
var reIsNative = RegExp(
|
|
134
|
+
"^" + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
135
|
+
);
|
|
136
|
+
function baseIsNative$1(value) {
|
|
137
|
+
if (!isObject(value) || isMasked(value)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
141
|
+
return pattern.test(toSource(value));
|
|
142
|
+
}
|
|
143
|
+
var _baseIsNative = baseIsNative$1;
|
|
144
|
+
function getValue$1(object, key) {
|
|
145
|
+
return object == null ? void 0 : object[key];
|
|
146
|
+
}
|
|
147
|
+
var _getValue = getValue$1;
|
|
148
|
+
var baseIsNative = _baseIsNative, getValue = _getValue;
|
|
149
|
+
function getNative$2(object, key) {
|
|
150
|
+
var value = getValue(object, key);
|
|
151
|
+
return baseIsNative(value) ? value : void 0;
|
|
152
|
+
}
|
|
153
|
+
var _getNative = getNative$2;
|
|
154
|
+
var getNative$1 = _getNative;
|
|
155
|
+
var nativeCreate$4 = getNative$1(Object, "create");
|
|
156
|
+
var _nativeCreate = nativeCreate$4;
|
|
157
|
+
var nativeCreate$3 = _nativeCreate;
|
|
158
|
+
function hashClear$1() {
|
|
159
|
+
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
160
|
+
this.size = 0;
|
|
161
|
+
}
|
|
162
|
+
var _hashClear = hashClear$1;
|
|
163
|
+
function hashDelete$1(key) {
|
|
164
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
165
|
+
this.size -= result ? 1 : 0;
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
var _hashDelete = hashDelete$1;
|
|
169
|
+
var nativeCreate$2 = _nativeCreate;
|
|
170
|
+
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
|
|
171
|
+
var objectProto$1 = Object.prototype;
|
|
172
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
173
|
+
function hashGet$1(key) {
|
|
174
|
+
var data = this.__data__;
|
|
175
|
+
if (nativeCreate$2) {
|
|
176
|
+
var result = data[key];
|
|
177
|
+
return result === HASH_UNDEFINED$1 ? void 0 : result;
|
|
178
|
+
}
|
|
179
|
+
return hasOwnProperty$1.call(data, key) ? data[key] : void 0;
|
|
180
|
+
}
|
|
181
|
+
var _hashGet = hashGet$1;
|
|
182
|
+
var nativeCreate$1 = _nativeCreate;
|
|
183
|
+
var objectProto = Object.prototype;
|
|
184
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
185
|
+
function hashHas$1(key) {
|
|
186
|
+
var data = this.__data__;
|
|
187
|
+
return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty.call(data, key);
|
|
188
|
+
}
|
|
189
|
+
var _hashHas = hashHas$1;
|
|
190
|
+
var nativeCreate = _nativeCreate;
|
|
191
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
192
|
+
function hashSet$1(key, value) {
|
|
193
|
+
var data = this.__data__;
|
|
194
|
+
this.size += this.has(key) ? 0 : 1;
|
|
195
|
+
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
var _hashSet = hashSet$1;
|
|
199
|
+
var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
|
|
200
|
+
function Hash$1(entries) {
|
|
201
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
202
|
+
this.clear();
|
|
203
|
+
while (++index < length) {
|
|
204
|
+
var entry = entries[index];
|
|
205
|
+
this.set(entry[0], entry[1]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
Hash$1.prototype.clear = hashClear;
|
|
209
|
+
Hash$1.prototype["delete"] = hashDelete;
|
|
210
|
+
Hash$1.prototype.get = hashGet;
|
|
211
|
+
Hash$1.prototype.has = hashHas;
|
|
212
|
+
Hash$1.prototype.set = hashSet;
|
|
213
|
+
var _Hash = Hash$1;
|
|
214
|
+
function listCacheClear$1() {
|
|
215
|
+
this.__data__ = [];
|
|
216
|
+
this.size = 0;
|
|
217
|
+
}
|
|
218
|
+
var _listCacheClear = listCacheClear$1;
|
|
219
|
+
function eq$1(value, other) {
|
|
220
|
+
return value === other || value !== value && other !== other;
|
|
221
|
+
}
|
|
222
|
+
var eq_1 = eq$1;
|
|
223
|
+
var eq = eq_1;
|
|
224
|
+
function assocIndexOf$4(array, key) {
|
|
225
|
+
var length = array.length;
|
|
226
|
+
while (length--) {
|
|
227
|
+
if (eq(array[length][0], key)) {
|
|
228
|
+
return length;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return -1;
|
|
232
|
+
}
|
|
233
|
+
var _assocIndexOf = assocIndexOf$4;
|
|
234
|
+
var assocIndexOf$3 = _assocIndexOf;
|
|
235
|
+
var arrayProto = Array.prototype;
|
|
236
|
+
var splice = arrayProto.splice;
|
|
237
|
+
function listCacheDelete$1(key) {
|
|
238
|
+
var data = this.__data__, index = assocIndexOf$3(data, key);
|
|
239
|
+
if (index < 0) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
var lastIndex = data.length - 1;
|
|
243
|
+
if (index == lastIndex) {
|
|
244
|
+
data.pop();
|
|
245
|
+
} else {
|
|
246
|
+
splice.call(data, index, 1);
|
|
247
|
+
}
|
|
248
|
+
--this.size;
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
var _listCacheDelete = listCacheDelete$1;
|
|
252
|
+
var assocIndexOf$2 = _assocIndexOf;
|
|
253
|
+
function listCacheGet$1(key) {
|
|
254
|
+
var data = this.__data__, index = assocIndexOf$2(data, key);
|
|
255
|
+
return index < 0 ? void 0 : data[index][1];
|
|
256
|
+
}
|
|
257
|
+
var _listCacheGet = listCacheGet$1;
|
|
258
|
+
var assocIndexOf$1 = _assocIndexOf;
|
|
259
|
+
function listCacheHas$1(key) {
|
|
260
|
+
return assocIndexOf$1(this.__data__, key) > -1;
|
|
261
|
+
}
|
|
262
|
+
var _listCacheHas = listCacheHas$1;
|
|
263
|
+
var assocIndexOf = _assocIndexOf;
|
|
264
|
+
function listCacheSet$1(key, value) {
|
|
265
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
266
|
+
if (index < 0) {
|
|
267
|
+
++this.size;
|
|
268
|
+
data.push([key, value]);
|
|
269
|
+
} else {
|
|
270
|
+
data[index][1] = value;
|
|
271
|
+
}
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
var _listCacheSet = listCacheSet$1;
|
|
275
|
+
var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
|
|
276
|
+
function ListCache$1(entries) {
|
|
277
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
278
|
+
this.clear();
|
|
279
|
+
while (++index < length) {
|
|
280
|
+
var entry = entries[index];
|
|
281
|
+
this.set(entry[0], entry[1]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
ListCache$1.prototype.clear = listCacheClear;
|
|
285
|
+
ListCache$1.prototype["delete"] = listCacheDelete;
|
|
286
|
+
ListCache$1.prototype.get = listCacheGet;
|
|
287
|
+
ListCache$1.prototype.has = listCacheHas;
|
|
288
|
+
ListCache$1.prototype.set = listCacheSet;
|
|
289
|
+
var _ListCache = ListCache$1;
|
|
290
|
+
var getNative = _getNative, root = _root;
|
|
291
|
+
var Map$1 = getNative(root, "Map");
|
|
292
|
+
var _Map = Map$1;
|
|
293
|
+
var Hash = _Hash, ListCache = _ListCache, Map = _Map;
|
|
294
|
+
function mapCacheClear$1() {
|
|
295
|
+
this.size = 0;
|
|
296
|
+
this.__data__ = {
|
|
297
|
+
"hash": new Hash(),
|
|
298
|
+
"map": new (Map || ListCache)(),
|
|
299
|
+
"string": new Hash()
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
var _mapCacheClear = mapCacheClear$1;
|
|
303
|
+
function isKeyable$1(value) {
|
|
304
|
+
var type = typeof value;
|
|
305
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
306
|
+
}
|
|
307
|
+
var _isKeyable = isKeyable$1;
|
|
308
|
+
var isKeyable = _isKeyable;
|
|
309
|
+
function getMapData$4(map, key) {
|
|
310
|
+
var data = map.__data__;
|
|
311
|
+
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
312
|
+
}
|
|
313
|
+
var _getMapData = getMapData$4;
|
|
314
|
+
var getMapData$3 = _getMapData;
|
|
315
|
+
function mapCacheDelete$1(key) {
|
|
316
|
+
var result = getMapData$3(this, key)["delete"](key);
|
|
317
|
+
this.size -= result ? 1 : 0;
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
var _mapCacheDelete = mapCacheDelete$1;
|
|
321
|
+
var getMapData$2 = _getMapData;
|
|
322
|
+
function mapCacheGet$1(key) {
|
|
323
|
+
return getMapData$2(this, key).get(key);
|
|
324
|
+
}
|
|
325
|
+
var _mapCacheGet = mapCacheGet$1;
|
|
326
|
+
var getMapData$1 = _getMapData;
|
|
327
|
+
function mapCacheHas$1(key) {
|
|
328
|
+
return getMapData$1(this, key).has(key);
|
|
329
|
+
}
|
|
330
|
+
var _mapCacheHas = mapCacheHas$1;
|
|
331
|
+
var getMapData = _getMapData;
|
|
332
|
+
function mapCacheSet$1(key, value) {
|
|
333
|
+
var data = getMapData(this, key), size = data.size;
|
|
334
|
+
data.set(key, value);
|
|
335
|
+
this.size += data.size == size ? 0 : 1;
|
|
336
|
+
return this;
|
|
337
|
+
}
|
|
338
|
+
var _mapCacheSet = mapCacheSet$1;
|
|
339
|
+
var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
|
|
340
|
+
function MapCache$1(entries) {
|
|
341
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
342
|
+
this.clear();
|
|
343
|
+
while (++index < length) {
|
|
344
|
+
var entry = entries[index];
|
|
345
|
+
this.set(entry[0], entry[1]);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
MapCache$1.prototype.clear = mapCacheClear;
|
|
349
|
+
MapCache$1.prototype["delete"] = mapCacheDelete;
|
|
350
|
+
MapCache$1.prototype.get = mapCacheGet;
|
|
351
|
+
MapCache$1.prototype.has = mapCacheHas;
|
|
352
|
+
MapCache$1.prototype.set = mapCacheSet;
|
|
353
|
+
var _MapCache = MapCache$1;
|
|
354
|
+
var MapCache = _MapCache;
|
|
355
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
356
|
+
function memoize$1(func, resolver) {
|
|
357
|
+
if (typeof func != "function" || resolver != null && typeof resolver != "function") {
|
|
358
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
359
|
+
}
|
|
360
|
+
var memoized = function() {
|
|
361
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
362
|
+
if (cache.has(key)) {
|
|
363
|
+
return cache.get(key);
|
|
364
|
+
}
|
|
365
|
+
var result = func.apply(this, args);
|
|
366
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
367
|
+
return result;
|
|
368
|
+
};
|
|
369
|
+
memoized.cache = new (memoize$1.Cache || MapCache)();
|
|
370
|
+
return memoized;
|
|
371
|
+
}
|
|
372
|
+
memoize$1.Cache = MapCache;
|
|
373
|
+
var memoize_1 = memoize$1;
|
|
374
|
+
var memoize = memoize_1;
|
|
375
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
376
|
+
function memoizeCapped$1(func) {
|
|
377
|
+
var result = memoize(func, function(key) {
|
|
378
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
379
|
+
cache.clear();
|
|
380
|
+
}
|
|
381
|
+
return key;
|
|
382
|
+
});
|
|
383
|
+
var cache = result.cache;
|
|
384
|
+
return result;
|
|
385
|
+
}
|
|
386
|
+
var _memoizeCapped = memoizeCapped$1;
|
|
387
|
+
var memoizeCapped = _memoizeCapped;
|
|
388
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
389
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
390
|
+
var stringToPath$1 = memoizeCapped(function(string) {
|
|
391
|
+
var result = [];
|
|
392
|
+
if (string.charCodeAt(0) === 46) {
|
|
393
|
+
result.push("");
|
|
394
|
+
}
|
|
395
|
+
string.replace(rePropName, function(match, number, quote, subString) {
|
|
396
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
|
|
397
|
+
});
|
|
398
|
+
return result;
|
|
399
|
+
});
|
|
400
|
+
var _stringToPath = stringToPath$1;
|
|
401
|
+
function arrayMap$1(array, iteratee) {
|
|
402
|
+
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
|
|
403
|
+
while (++index < length) {
|
|
404
|
+
result[index] = iteratee(array[index], index, array);
|
|
405
|
+
}
|
|
406
|
+
return result;
|
|
407
|
+
}
|
|
408
|
+
var _arrayMap = arrayMap$1;
|
|
409
|
+
var Symbol$1 = _Symbol, arrayMap = _arrayMap, isArray$1 = isArray_1, isSymbol$1 = isSymbol_1;
|
|
410
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
411
|
+
function baseToString$1(value) {
|
|
412
|
+
if (typeof value == "string") {
|
|
413
|
+
return value;
|
|
414
|
+
}
|
|
415
|
+
if (isArray$1(value)) {
|
|
416
|
+
return arrayMap(value, baseToString$1) + "";
|
|
417
|
+
}
|
|
418
|
+
if (isSymbol$1(value)) {
|
|
419
|
+
return symbolToString ? symbolToString.call(value) : "";
|
|
420
|
+
}
|
|
421
|
+
var result = value + "";
|
|
422
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
423
|
+
}
|
|
424
|
+
var _baseToString = baseToString$1;
|
|
425
|
+
var baseToString = _baseToString;
|
|
426
|
+
function toString$1(value) {
|
|
427
|
+
return value == null ? "" : baseToString(value);
|
|
428
|
+
}
|
|
429
|
+
var toString_1 = toString$1;
|
|
430
|
+
var isArray = isArray_1, isKey = _isKey, stringToPath = _stringToPath, toString = toString_1;
|
|
431
|
+
function castPath$1(value, object) {
|
|
432
|
+
if (isArray(value)) {
|
|
433
|
+
return value;
|
|
434
|
+
}
|
|
435
|
+
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
|
436
|
+
}
|
|
437
|
+
var _castPath = castPath$1;
|
|
438
|
+
var isSymbol = isSymbol_1;
|
|
439
|
+
function toKey$1(value) {
|
|
440
|
+
if (typeof value == "string" || isSymbol(value)) {
|
|
441
|
+
return value;
|
|
442
|
+
}
|
|
443
|
+
var result = value + "";
|
|
444
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
445
|
+
}
|
|
446
|
+
var _toKey = toKey$1;
|
|
447
|
+
var castPath = _castPath, toKey = _toKey;
|
|
448
|
+
function baseGet$1(object, path) {
|
|
449
|
+
path = castPath(path, object);
|
|
450
|
+
var index = 0, length = path.length;
|
|
451
|
+
while (object != null && index < length) {
|
|
452
|
+
object = object[toKey(path[index++])];
|
|
453
|
+
}
|
|
454
|
+
return index && index == length ? object : void 0;
|
|
455
|
+
}
|
|
456
|
+
var _baseGet = baseGet$1;
|
|
457
|
+
var baseGet = _baseGet;
|
|
458
|
+
function get(object, path, defaultValue) {
|
|
459
|
+
var result = object == null ? void 0 : baseGet(object, path);
|
|
460
|
+
return result === void 0 ? defaultValue : result;
|
|
461
|
+
}
|
|
462
|
+
var get_1 = get;
|
|
463
|
+
const get$1 = /* @__PURE__ */ getDefaultExportFromCjs(get_1);
|
|
6
464
|
var __assign = function() {
|
|
7
465
|
__assign = Object.assign || function __assign2(t) {
|
|
8
466
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -411,9 +869,6 @@ createFormattedComponent("formatDisplayName");
|
|
|
411
869
|
createFormattedDateTimePartsComponent("formatDate");
|
|
412
870
|
createFormattedDateTimePartsComponent("formatTime");
|
|
413
871
|
const CompositeInput = (props) => {
|
|
414
|
-
if (!props) {
|
|
415
|
-
return null;
|
|
416
|
-
}
|
|
417
872
|
const {
|
|
418
873
|
attribute,
|
|
419
874
|
name,
|
|
@@ -428,128 +883,107 @@ const CompositeInput = (props) => {
|
|
|
428
883
|
intlLabel
|
|
429
884
|
} = props;
|
|
430
885
|
const { formatMessage } = useIntl();
|
|
886
|
+
const { form } = unstable_useContentManagerContext();
|
|
887
|
+
const { values } = form;
|
|
431
888
|
const [localValue, setLocalValue] = React__default.useState(value || "");
|
|
889
|
+
const lastGeneratedVal = React__default.useRef(value || "");
|
|
432
890
|
React__default.useEffect(() => {
|
|
433
|
-
|
|
891
|
+
const validValue = value || "";
|
|
892
|
+
setLocalValue(validValue);
|
|
893
|
+
lastGeneratedVal.current = validValue;
|
|
434
894
|
}, [value]);
|
|
435
895
|
const fieldsConfig = attribute?.options?.fields || "";
|
|
436
896
|
const separator = attribute?.options?.separator || " - ";
|
|
437
897
|
const editable = attribute?.options?.editable !== false;
|
|
438
898
|
const autoGenerate = attribute?.options?.autoGenerate === true;
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
899
|
+
const fields = React__default.useMemo(() => {
|
|
900
|
+
if (typeof fieldsConfig === "string") {
|
|
901
|
+
return fieldsConfig.split("\n").map((f) => f.trim()).filter(Boolean);
|
|
902
|
+
}
|
|
903
|
+
return [];
|
|
904
|
+
}, [fieldsConfig]);
|
|
443
905
|
const handleChange = (e) => {
|
|
444
906
|
const newValue = e.target.value;
|
|
445
907
|
setLocalValue(newValue);
|
|
908
|
+
lastGeneratedVal.current = newValue;
|
|
446
909
|
if (onChange) {
|
|
447
910
|
onChange({ target: { name, value: newValue, type: "text" } });
|
|
448
911
|
}
|
|
449
912
|
};
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
913
|
+
const formatFieldValue = React__default.useCallback((val) => {
|
|
914
|
+
if (val === null || val === void 0) return "";
|
|
915
|
+
if (val instanceof Date) {
|
|
916
|
+
return val.toLocaleTimeString([], {
|
|
917
|
+
hour: "2-digit",
|
|
918
|
+
minute: "2-digit",
|
|
919
|
+
hour12: false
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
const stringVal = String(val);
|
|
923
|
+
const isoDateRegex = /^(\d{4})-(\d{2})-(\d{2})(T[\d:.]+Z?)?$/;
|
|
924
|
+
const dateMatch = stringVal.match(isoDateRegex);
|
|
925
|
+
if (dateMatch) {
|
|
926
|
+
const [, year, month, day] = dateMatch;
|
|
927
|
+
return `${month}/${day}/${year}`;
|
|
928
|
+
}
|
|
452
929
|
const timeRegex = /^(\d{2}):(\d{2}):(\d{2})(\.\d{3})?$/;
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
return `${
|
|
930
|
+
const timeMatch = stringVal.match(timeRegex);
|
|
931
|
+
if (timeMatch) {
|
|
932
|
+
return `${timeMatch[1]}:${timeMatch[2]}`;
|
|
456
933
|
}
|
|
457
|
-
return
|
|
458
|
-
};
|
|
934
|
+
return stringVal;
|
|
935
|
+
}, []);
|
|
459
936
|
const handleGenerate = React__default.useCallback(() => {
|
|
460
|
-
const parts =
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
937
|
+
const parts = name.split(".");
|
|
938
|
+
parts.pop();
|
|
939
|
+
const parentPath = parts.join(".");
|
|
940
|
+
const generatedParts = [];
|
|
941
|
+
fields.forEach((fieldName) => {
|
|
942
|
+
const fullPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;
|
|
943
|
+
let rawValue = get$1(values, fullPath);
|
|
944
|
+
if (rawValue !== null && rawValue !== void 0) {
|
|
945
|
+
let stringValue = "";
|
|
946
|
+
if (typeof rawValue === "object" && !(rawValue instanceof Date)) {
|
|
947
|
+
if (rawValue.name) stringValue = String(rawValue.name);
|
|
948
|
+
else if (rawValue.title) stringValue = String(rawValue.title);
|
|
949
|
+
else if (rawValue.label) stringValue = String(rawValue.label);
|
|
950
|
+
} else {
|
|
951
|
+
stringValue = formatFieldValue(rawValue);
|
|
473
952
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const combobox = document.querySelector(
|
|
477
|
-
`div[role="combobox"][name="${fieldPath}"]`
|
|
478
|
-
);
|
|
479
|
-
if (combobox) {
|
|
480
|
-
const selectedText = combobox.textContent?.trim();
|
|
481
|
-
if (selectedText && selectedText !== "Select..." && selectedText !== "") {
|
|
482
|
-
fieldValue = selectedText;
|
|
483
|
-
}
|
|
953
|
+
if (stringValue) {
|
|
954
|
+
generatedParts.push(stringValue);
|
|
484
955
|
}
|
|
485
956
|
}
|
|
486
|
-
if (!fieldValue) {
|
|
487
|
-
const fieldById = document.getElementById(fieldPath);
|
|
488
|
-
if (fieldById) {
|
|
489
|
-
if (fieldById.tagName === "SELECT") {
|
|
490
|
-
fieldValue = fieldById.value;
|
|
491
|
-
} else if (fieldById.value) {
|
|
492
|
-
fieldValue = fieldById.value;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
if (fieldValue) {
|
|
497
|
-
fieldValue = formatTimeValue(fieldValue);
|
|
498
|
-
parts.push(fieldValue);
|
|
499
|
-
}
|
|
500
957
|
});
|
|
501
958
|
const cleanSeparator = separator.trim();
|
|
502
|
-
const result =
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
959
|
+
const result = generatedParts.join(` ${cleanSeparator} `).trim();
|
|
960
|
+
if (result !== lastGeneratedVal.current) {
|
|
961
|
+
setLocalValue(result);
|
|
962
|
+
lastGeneratedVal.current = result;
|
|
963
|
+
if (onChange) {
|
|
964
|
+
onChange({ target: { name, value: result, type: "text" } });
|
|
965
|
+
}
|
|
506
966
|
}
|
|
507
|
-
}, [fields, separator, onChange, name]);
|
|
967
|
+
}, [fields, separator, onChange, name, values, formatFieldValue]);
|
|
968
|
+
const watchedValues = React__default.useMemo(() => {
|
|
969
|
+
const parts = name.split(".");
|
|
970
|
+
parts.pop();
|
|
971
|
+
const parentPath = parts.join(".");
|
|
972
|
+
return fields.map((fieldName) => {
|
|
973
|
+
const fullPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;
|
|
974
|
+
return get$1(values, fullPath);
|
|
975
|
+
});
|
|
976
|
+
}, [fields, name, values]);
|
|
508
977
|
React__default.useEffect(() => {
|
|
509
978
|
if (!autoGenerate || fields.length === 0) return;
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const observers = [];
|
|
519
|
-
fields.forEach((fieldPath) => {
|
|
520
|
-
const elements = document.querySelectorAll(
|
|
521
|
-
`input[name="${fieldPath}"], textarea[name="${fieldPath}"], select[name="${fieldPath}"]`
|
|
522
|
-
);
|
|
523
|
-
elements.forEach((element) => {
|
|
524
|
-
element.addEventListener("change", handleFieldChange);
|
|
525
|
-
element.addEventListener("input", handleFieldChange);
|
|
526
|
-
listeners.push({ element, handler: handleFieldChange });
|
|
527
|
-
});
|
|
528
|
-
const combobox = document.querySelector(
|
|
529
|
-
`div[role="combobox"][name="${fieldPath}"]`
|
|
530
|
-
);
|
|
531
|
-
if (combobox) {
|
|
532
|
-
const observer = new MutationObserver(handleFieldChange);
|
|
533
|
-
observer.observe(combobox, {
|
|
534
|
-
childList: true,
|
|
535
|
-
subtree: true,
|
|
536
|
-
characterData: true
|
|
537
|
-
});
|
|
538
|
-
observers.push(observer);
|
|
539
|
-
combobox.addEventListener("click", handleFieldChange);
|
|
540
|
-
listeners.push({ element: combobox, handler: handleFieldChange });
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
return () => {
|
|
544
|
-
clearTimeout(debounceTimer);
|
|
545
|
-
listeners.forEach(({ element, handler }) => {
|
|
546
|
-
element.removeEventListener("change", handler);
|
|
547
|
-
element.removeEventListener("input", handler);
|
|
548
|
-
element.removeEventListener("click", handler);
|
|
549
|
-
});
|
|
550
|
-
observers.forEach((observer) => observer.disconnect());
|
|
551
|
-
};
|
|
552
|
-
}, [autoGenerate, fields, handleGenerate]);
|
|
979
|
+
const timeoutId = setTimeout(() => {
|
|
980
|
+
handleGenerate();
|
|
981
|
+
}, 300);
|
|
982
|
+
return () => clearTimeout(timeoutId);
|
|
983
|
+
}, [autoGenerate, fields, handleGenerate, watchedValues, name]);
|
|
984
|
+
if (!props) {
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
553
987
|
return /* @__PURE__ */ jsx(
|
|
554
988
|
Field.Root,
|
|
555
989
|
{
|
package/dist/admin/index.js
CHANGED
|
@@ -37,7 +37,7 @@ const index = {
|
|
|
37
37
|
defaultMessage: "Combine multiple fields into one display value"
|
|
38
38
|
},
|
|
39
39
|
components: {
|
|
40
|
-
Input: async () => Promise.resolve().then(() => require("../_chunks/CompositeInput-
|
|
40
|
+
Input: async () => Promise.resolve().then(() => require("../_chunks/CompositeInput-DjJxL_5Z.js"))
|
|
41
41
|
},
|
|
42
42
|
options: {
|
|
43
43
|
base: [
|
package/dist/admin/index.mjs
CHANGED
|
@@ -34,7 +34,7 @@ const index = {
|
|
|
34
34
|
defaultMessage: "Combine multiple fields into one display value"
|
|
35
35
|
},
|
|
36
36
|
components: {
|
|
37
|
-
Input: async () => import("../_chunks/CompositeInput-
|
|
37
|
+
Input: async () => import("../_chunks/CompositeInput-yW3aLiyf.mjs")
|
|
38
38
|
},
|
|
39
39
|
options: {
|
|
40
40
|
base: [
|