@next-core/brick-kit 2.166.0 → 2.166.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.bundle.js +234 -229
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +235 -230
- package/dist/index.esm.js.map +1 -1
- package/dist/types/internal/setProperties.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.bundle.js
CHANGED
|
@@ -2430,6 +2430,229 @@
|
|
|
2430
2430
|
}
|
|
2431
2431
|
}
|
|
2432
2432
|
|
|
2433
|
+
function isBasicProperty(propRef) {
|
|
2434
|
+
return !!propRef.refProperty;
|
|
2435
|
+
}
|
|
2436
|
+
function isTransformableProperty(propRef) {
|
|
2437
|
+
return !!propRef.refTransform;
|
|
2438
|
+
}
|
|
2439
|
+
function isMergeableProperty(propRef) {
|
|
2440
|
+
return !!propRef.mergeProperty;
|
|
2441
|
+
}
|
|
2442
|
+
function isRefProperty(propRef) {
|
|
2443
|
+
return !!propRef.ref;
|
|
2444
|
+
}
|
|
2445
|
+
function isVariableProperty(propRef) {
|
|
2446
|
+
return !!propRef.asVariable;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
var customTemplateRegistry = new Map();
|
|
2450
|
+
var appRegistered = new Set();
|
|
2451
|
+
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
2452
|
+
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
2453
|
+
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
2454
|
+
|
|
2455
|
+
function propertyMerge(conf, value, object) {
|
|
2456
|
+
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
2457
|
+
}
|
|
2458
|
+
function propertyMergeAll(mergeBase, object) {
|
|
2459
|
+
if (mergeBase.mergeType === "array") {
|
|
2460
|
+
return propertyMergeAllOfArray(mergeBase, object);
|
|
2461
|
+
}
|
|
2462
|
+
if (mergeBase.mergeType === "object") {
|
|
2463
|
+
return propertyMergeAllOfObject(mergeBase, object);
|
|
2464
|
+
}
|
|
2465
|
+
// istanbul ignore next: should never reach
|
|
2466
|
+
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
2467
|
+
}
|
|
2468
|
+
function propertyMergeAllOfArray(_ref, object) {
|
|
2469
|
+
var _$1, _proxy$mergeArgs;
|
|
2470
|
+
var {
|
|
2471
|
+
baseValue,
|
|
2472
|
+
context,
|
|
2473
|
+
proxies
|
|
2474
|
+
} = _ref;
|
|
2475
|
+
// Use an approach like template-literal's quasis:
|
|
2476
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
2477
|
+
// Every quasi can be merged with multiple items.
|
|
2478
|
+
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
2479
|
+
$$lazyForUseBrick: true
|
|
2480
|
+
}) : [];
|
|
2481
|
+
var quasis = [];
|
|
2482
|
+
var size = computedBaseValue.length + 1;
|
|
2483
|
+
for (var i = 0; i < size; i += 1) {
|
|
2484
|
+
quasis.push([]);
|
|
2485
|
+
}
|
|
2486
|
+
for (var proxy of proxies) {
|
|
2487
|
+
var position = void 0;
|
|
2488
|
+
switch (proxy.mergeMethod) {
|
|
2489
|
+
case "append":
|
|
2490
|
+
position = computedBaseValue.length;
|
|
2491
|
+
break;
|
|
2492
|
+
case "prepend":
|
|
2493
|
+
position = 0;
|
|
2494
|
+
break;
|
|
2495
|
+
case "insertAt":
|
|
2496
|
+
// Defaults to `-1`.
|
|
2497
|
+
position = (_$1 = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _$1 !== void 0 ? _$1 : -1;
|
|
2498
|
+
if (position < 0) {
|
|
2499
|
+
// It's counted from the end if position is negative.
|
|
2500
|
+
position += quasis.length;
|
|
2501
|
+
}
|
|
2502
|
+
position = _.clamp(position, 0, computedBaseValue.length);
|
|
2503
|
+
break;
|
|
2504
|
+
// istanbul ignore next: should never reach
|
|
2505
|
+
default:
|
|
2506
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2507
|
+
}
|
|
2508
|
+
var patchValue = object[proxy.$$reversedRef];
|
|
2509
|
+
if (!Array.isArray(patchValue)) {
|
|
2510
|
+
patchValue = [];
|
|
2511
|
+
}
|
|
2512
|
+
quasis[position].push(...patchValue);
|
|
2513
|
+
}
|
|
2514
|
+
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
2515
|
+
}
|
|
2516
|
+
function propertyMergeAllOfObject(_ref2, object) {
|
|
2517
|
+
var {
|
|
2518
|
+
baseValue,
|
|
2519
|
+
proxies,
|
|
2520
|
+
context
|
|
2521
|
+
} = _ref2;
|
|
2522
|
+
var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
2523
|
+
return proxies.reduce((acc, proxy) => {
|
|
2524
|
+
switch (proxy.mergeMethod) {
|
|
2525
|
+
case "extend":
|
|
2526
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
|
|
2527
|
+
// istanbul ignore next: should never reach
|
|
2528
|
+
default:
|
|
2529
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2530
|
+
}
|
|
2531
|
+
}, computedBaseValue);
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
2535
|
+
var computedPropsFromProxy = {};
|
|
2536
|
+
var refForProxy;
|
|
2537
|
+
var {
|
|
2538
|
+
reversedProxies,
|
|
2539
|
+
templateProperties,
|
|
2540
|
+
externalSlots,
|
|
2541
|
+
templateContextId,
|
|
2542
|
+
proxyBrick
|
|
2543
|
+
} = proxyContext;
|
|
2544
|
+
if (ref && reversedProxies) {
|
|
2545
|
+
refForProxy = {};
|
|
2546
|
+
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
2547
|
+
|
|
2548
|
+
// Reversed proxies are used for expand storyboard before rendering page.
|
|
2549
|
+
if (reversedProxies.properties.has(ref)) {
|
|
2550
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
2551
|
+
// `propValue` is computed.
|
|
2552
|
+
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
2553
|
+
if (isTransformableProperty(propRef)) {
|
|
2554
|
+
return Object.entries(preprocessTransformProperties({
|
|
2555
|
+
[propRef.$$reversedRef]: propValue
|
|
2556
|
+
}, propRef.refTransform));
|
|
2557
|
+
}
|
|
2558
|
+
if (isBasicProperty(propRef)) {
|
|
2559
|
+
return [[propRef.refProperty, propValue]];
|
|
2560
|
+
}
|
|
2561
|
+
// Ignore Variable properties.
|
|
2562
|
+
// And mergeable properties are processed later.
|
|
2563
|
+
return [];
|
|
2564
|
+
}).filter(propRef => propRef[1] !== undefined)));
|
|
2565
|
+
|
|
2566
|
+
// Brick properties can be merged multiple times.
|
|
2567
|
+
if (reversedProxies.mergeBases.has(ref)) {
|
|
2568
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
2569
|
+
var [mergeProperty, mergeBase] = _ref;
|
|
2570
|
+
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
2571
|
+
}).filter(item => item[1] !== undefined)));
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
// Use an approach like template-literal's quasis:
|
|
2576
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
2577
|
+
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
2578
|
+
var quasisMap = new Map();
|
|
2579
|
+
if (reversedProxies.slots.has(ref)) {
|
|
2580
|
+
for (var item of reversedProxies.slots.get(ref)) {
|
|
2581
|
+
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
2582
|
+
if (!quasisMap.has(item.refSlot)) {
|
|
2583
|
+
var quasis = [];
|
|
2584
|
+
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
2585
|
+
var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
2586
|
+
for (var i = 0; i < size; i += 1) {
|
|
2587
|
+
quasis.push([]);
|
|
2588
|
+
}
|
|
2589
|
+
quasisMap.set(item.refSlot, quasis);
|
|
2590
|
+
}
|
|
2591
|
+
var expandableSlot = quasisMap.get(item.refSlot);
|
|
2592
|
+
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
2593
|
+
expandableSlot[_.clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
var _loop = function (slotName, _quasis) {
|
|
2597
|
+
if (!brickUtils.hasOwnProperty(slots, slotName)) {
|
|
2598
|
+
slots[slotName] = {
|
|
2599
|
+
type: "bricks",
|
|
2600
|
+
bricks: []
|
|
2601
|
+
};
|
|
2602
|
+
}
|
|
2603
|
+
var slotConf = slots[slotName];
|
|
2604
|
+
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
2605
|
+
if (slotConf.bricks.length === 0) {
|
|
2606
|
+
delete slots[slotName];
|
|
2607
|
+
}
|
|
2608
|
+
};
|
|
2609
|
+
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
2610
|
+
_loop(slotName, _quasis);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
return {
|
|
2614
|
+
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
2615
|
+
[symbolForRefForProxy]: refForProxy,
|
|
2616
|
+
[symbolForTplContextId]: templateContextId
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
var _excluded$7 = ["properties", "slots"];
|
|
2621
|
+
function setupUseBrickInTemplate(props, proxyContext) {
|
|
2622
|
+
function walk(props) {
|
|
2623
|
+
if (!brickUtils.isObject(props)) {
|
|
2624
|
+
return props;
|
|
2625
|
+
}
|
|
2626
|
+
if (Array.isArray(props)) {
|
|
2627
|
+
return props.map(walk);
|
|
2628
|
+
}
|
|
2629
|
+
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
2630
|
+
var [key, value] = _ref;
|
|
2631
|
+
return brickUtils.isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
2632
|
+
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
2633
|
+
}
|
|
2634
|
+
function setup(item) {
|
|
2635
|
+
var {
|
|
2636
|
+
properties,
|
|
2637
|
+
slots: originalSlots
|
|
2638
|
+
} = item,
|
|
2639
|
+
restConf = _objectWithoutProperties__default["default"](item, _excluded$7);
|
|
2640
|
+
var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
|
|
2641
|
+
var _slotConf$bricks;
|
|
2642
|
+
var [slotName, slotConf] = _ref2;
|
|
2643
|
+
return [slotName, {
|
|
2644
|
+
type: "bricks",
|
|
2645
|
+
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
2646
|
+
}];
|
|
2647
|
+
}));
|
|
2648
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, restConf), {}, {
|
|
2649
|
+
properties: walk(properties),
|
|
2650
|
+
slots
|
|
2651
|
+
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
2652
|
+
}
|
|
2653
|
+
return walk(props);
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2433
2656
|
var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
2434
2657
|
var preEvaluated = isPreEvaluated(value);
|
|
2435
2658
|
if (preEvaluated || typeof value === "string") {
|
|
@@ -2481,6 +2704,11 @@
|
|
|
2481
2704
|
};
|
|
2482
2705
|
function setProperties(bricks, properties, context, injectDeep) {
|
|
2483
2706
|
var realProps = computeRealProperties(properties, context, injectDeep);
|
|
2707
|
+
if (context.tplContextId) {
|
|
2708
|
+
realProps = setupUseBrickInTemplate(realProps, {
|
|
2709
|
+
templateContextId: context.tplContextId
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2484
2712
|
if (!Array.isArray(bricks)) {
|
|
2485
2713
|
bricks = [bricks];
|
|
2486
2714
|
}
|
|
@@ -2548,7 +2776,7 @@
|
|
|
2548
2776
|
}) : internalOptions;
|
|
2549
2777
|
}
|
|
2550
2778
|
|
|
2551
|
-
var _excluded$
|
|
2779
|
+
var _excluded$6 = ["children"],
|
|
2552
2780
|
_excluded2$2 = ["children"],
|
|
2553
2781
|
_excluded3 = ["items", "app"];
|
|
2554
2782
|
var symbolAppId = Symbol("appId");
|
|
@@ -2811,7 +3039,7 @@
|
|
|
2811
3039
|
var {
|
|
2812
3040
|
children
|
|
2813
3041
|
} = _ref,
|
|
2814
|
-
rest = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
3042
|
+
rest = _objectWithoutProperties__default["default"](_ref, _excluded$6);
|
|
2815
3043
|
var overrideAppId = rest[symbolAppId];
|
|
2816
3044
|
if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
|
|
2817
3045
|
appIds.add(overrideAppId);
|
|
@@ -3433,7 +3661,7 @@
|
|
|
3433
3661
|
return kernel.loadDynamicBricksInBrickConf(brickConf);
|
|
3434
3662
|
}
|
|
3435
3663
|
|
|
3436
|
-
var _excluded$
|
|
3664
|
+
var _excluded$5 = ["extraQuery", "clear", "keepHash"];
|
|
3437
3665
|
var blocked = false;
|
|
3438
3666
|
function getUserConfirmation(message, callback) {
|
|
3439
3667
|
blocked = !confirm(message);
|
|
@@ -3463,7 +3691,7 @@
|
|
|
3463
3691
|
clear,
|
|
3464
3692
|
keepHash
|
|
3465
3693
|
} = options,
|
|
3466
|
-
state = _objectWithoutProperties__default["default"](options, _excluded$
|
|
3694
|
+
state = _objectWithoutProperties__default["default"](options, _excluded$5);
|
|
3467
3695
|
var urlSearchParams = new URLSearchParams(clear ? "" : browserHistory.location.search);
|
|
3468
3696
|
var params = {};
|
|
3469
3697
|
Object.assign(params, query, extraQuery);
|
|
@@ -6534,7 +6762,7 @@
|
|
|
6534
6762
|
};
|
|
6535
6763
|
}();
|
|
6536
6764
|
|
|
6537
|
-
var _excluded$
|
|
6765
|
+
var _excluded$4 = ["feature_flags"],
|
|
6538
6766
|
_excluded2$1 = ["featureFlags", "misc"];
|
|
6539
6767
|
function standaloneBootstrap() {
|
|
6540
6768
|
return _standaloneBootstrap.apply(this, arguments);
|
|
@@ -6580,7 +6808,7 @@
|
|
|
6580
6808
|
var {
|
|
6581
6809
|
feature_flags: featureFlags
|
|
6582
6810
|
} = sys_settings,
|
|
6583
|
-
rest = _objectWithoutProperties__default["default"](sys_settings, _excluded$
|
|
6811
|
+
rest = _objectWithoutProperties__default["default"](sys_settings, _excluded$4);
|
|
6584
6812
|
settings = _objectSpread__default["default"]({
|
|
6585
6813
|
featureFlags
|
|
6586
6814
|
}, rest);
|
|
@@ -7538,28 +7766,6 @@
|
|
|
7538
7766
|
var filterProperties = ["instanceId", "brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
|
|
7539
7767
|
var symbolForFormContextId = Symbol.for("form.contextId");
|
|
7540
7768
|
|
|
7541
|
-
var customTemplateRegistry = new Map();
|
|
7542
|
-
var appRegistered = new Set();
|
|
7543
|
-
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
7544
|
-
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
7545
|
-
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
7546
|
-
|
|
7547
|
-
function isBasicProperty(propRef) {
|
|
7548
|
-
return !!propRef.refProperty;
|
|
7549
|
-
}
|
|
7550
|
-
function isTransformableProperty(propRef) {
|
|
7551
|
-
return !!propRef.refTransform;
|
|
7552
|
-
}
|
|
7553
|
-
function isMergeableProperty(propRef) {
|
|
7554
|
-
return !!propRef.mergeProperty;
|
|
7555
|
-
}
|
|
7556
|
-
function isRefProperty(propRef) {
|
|
7557
|
-
return !!propRef.ref;
|
|
7558
|
-
}
|
|
7559
|
-
function isVariableProperty(propRef) {
|
|
7560
|
-
return !!propRef.asVariable;
|
|
7561
|
-
}
|
|
7562
|
-
|
|
7563
7769
|
function collectRefsInTemplate(template) {
|
|
7564
7770
|
var refMap = new Map();
|
|
7565
7771
|
collectRefsInBrickConfs(template.bricks, refMap);
|
|
@@ -7615,207 +7821,6 @@
|
|
|
7615
7821
|
}
|
|
7616
7822
|
}
|
|
7617
7823
|
|
|
7618
|
-
function propertyMerge(conf, value, object) {
|
|
7619
|
-
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
7620
|
-
}
|
|
7621
|
-
function propertyMergeAll(mergeBase, object) {
|
|
7622
|
-
if (mergeBase.mergeType === "array") {
|
|
7623
|
-
return propertyMergeAllOfArray(mergeBase, object);
|
|
7624
|
-
}
|
|
7625
|
-
if (mergeBase.mergeType === "object") {
|
|
7626
|
-
return propertyMergeAllOfObject(mergeBase, object);
|
|
7627
|
-
}
|
|
7628
|
-
// istanbul ignore next: should never reach
|
|
7629
|
-
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
7630
|
-
}
|
|
7631
|
-
function propertyMergeAllOfArray(_ref, object) {
|
|
7632
|
-
var _$1, _proxy$mergeArgs;
|
|
7633
|
-
var {
|
|
7634
|
-
baseValue,
|
|
7635
|
-
context,
|
|
7636
|
-
proxies
|
|
7637
|
-
} = _ref;
|
|
7638
|
-
// Use an approach like template-literal's quasis:
|
|
7639
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
7640
|
-
// Every quasi can be merged with multiple items.
|
|
7641
|
-
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
7642
|
-
$$lazyForUseBrick: true
|
|
7643
|
-
}) : [];
|
|
7644
|
-
var quasis = [];
|
|
7645
|
-
var size = computedBaseValue.length + 1;
|
|
7646
|
-
for (var i = 0; i < size; i += 1) {
|
|
7647
|
-
quasis.push([]);
|
|
7648
|
-
}
|
|
7649
|
-
for (var proxy of proxies) {
|
|
7650
|
-
var position = void 0;
|
|
7651
|
-
switch (proxy.mergeMethod) {
|
|
7652
|
-
case "append":
|
|
7653
|
-
position = computedBaseValue.length;
|
|
7654
|
-
break;
|
|
7655
|
-
case "prepend":
|
|
7656
|
-
position = 0;
|
|
7657
|
-
break;
|
|
7658
|
-
case "insertAt":
|
|
7659
|
-
// Defaults to `-1`.
|
|
7660
|
-
position = (_$1 = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _$1 !== void 0 ? _$1 : -1;
|
|
7661
|
-
if (position < 0) {
|
|
7662
|
-
// It's counted from the end if position is negative.
|
|
7663
|
-
position += quasis.length;
|
|
7664
|
-
}
|
|
7665
|
-
position = _.clamp(position, 0, computedBaseValue.length);
|
|
7666
|
-
break;
|
|
7667
|
-
// istanbul ignore next: should never reach
|
|
7668
|
-
default:
|
|
7669
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
7670
|
-
}
|
|
7671
|
-
var patchValue = object[proxy.$$reversedRef];
|
|
7672
|
-
if (!Array.isArray(patchValue)) {
|
|
7673
|
-
patchValue = [];
|
|
7674
|
-
}
|
|
7675
|
-
quasis[position].push(...patchValue);
|
|
7676
|
-
}
|
|
7677
|
-
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
7678
|
-
}
|
|
7679
|
-
function propertyMergeAllOfObject(_ref2, object) {
|
|
7680
|
-
var {
|
|
7681
|
-
baseValue,
|
|
7682
|
-
proxies,
|
|
7683
|
-
context
|
|
7684
|
-
} = _ref2;
|
|
7685
|
-
var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
7686
|
-
return proxies.reduce((acc, proxy) => {
|
|
7687
|
-
switch (proxy.mergeMethod) {
|
|
7688
|
-
case "extend":
|
|
7689
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
|
|
7690
|
-
// istanbul ignore next: should never reach
|
|
7691
|
-
default:
|
|
7692
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
7693
|
-
}
|
|
7694
|
-
}, computedBaseValue);
|
|
7695
|
-
}
|
|
7696
|
-
|
|
7697
|
-
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
7698
|
-
var computedPropsFromProxy = {};
|
|
7699
|
-
var refForProxy;
|
|
7700
|
-
var {
|
|
7701
|
-
reversedProxies,
|
|
7702
|
-
templateProperties,
|
|
7703
|
-
externalSlots,
|
|
7704
|
-
templateContextId,
|
|
7705
|
-
proxyBrick
|
|
7706
|
-
} = proxyContext;
|
|
7707
|
-
if (ref && reversedProxies) {
|
|
7708
|
-
refForProxy = {};
|
|
7709
|
-
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
7710
|
-
|
|
7711
|
-
// Reversed proxies are used for expand storyboard before rendering page.
|
|
7712
|
-
if (reversedProxies.properties.has(ref)) {
|
|
7713
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
7714
|
-
// `propValue` is computed.
|
|
7715
|
-
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
7716
|
-
if (isTransformableProperty(propRef)) {
|
|
7717
|
-
return Object.entries(preprocessTransformProperties({
|
|
7718
|
-
[propRef.$$reversedRef]: propValue
|
|
7719
|
-
}, propRef.refTransform));
|
|
7720
|
-
}
|
|
7721
|
-
if (isBasicProperty(propRef)) {
|
|
7722
|
-
return [[propRef.refProperty, propValue]];
|
|
7723
|
-
}
|
|
7724
|
-
// Ignore Variable properties.
|
|
7725
|
-
// And mergeable properties are processed later.
|
|
7726
|
-
return [];
|
|
7727
|
-
}).filter(propRef => propRef[1] !== undefined)));
|
|
7728
|
-
|
|
7729
|
-
// Brick properties can be merged multiple times.
|
|
7730
|
-
if (reversedProxies.mergeBases.has(ref)) {
|
|
7731
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
7732
|
-
var [mergeProperty, mergeBase] = _ref;
|
|
7733
|
-
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
7734
|
-
}).filter(item => item[1] !== undefined)));
|
|
7735
|
-
}
|
|
7736
|
-
}
|
|
7737
|
-
|
|
7738
|
-
// Use an approach like template-literal's quasis:
|
|
7739
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
7740
|
-
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
7741
|
-
var quasisMap = new Map();
|
|
7742
|
-
if (reversedProxies.slots.has(ref)) {
|
|
7743
|
-
for (var item of reversedProxies.slots.get(ref)) {
|
|
7744
|
-
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
7745
|
-
if (!quasisMap.has(item.refSlot)) {
|
|
7746
|
-
var quasis = [];
|
|
7747
|
-
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
7748
|
-
var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
7749
|
-
for (var i = 0; i < size; i += 1) {
|
|
7750
|
-
quasis.push([]);
|
|
7751
|
-
}
|
|
7752
|
-
quasisMap.set(item.refSlot, quasis);
|
|
7753
|
-
}
|
|
7754
|
-
var expandableSlot = quasisMap.get(item.refSlot);
|
|
7755
|
-
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
7756
|
-
expandableSlot[_.clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
|
|
7757
|
-
}
|
|
7758
|
-
}
|
|
7759
|
-
var _loop = function (slotName, _quasis) {
|
|
7760
|
-
if (!brickUtils.hasOwnProperty(slots, slotName)) {
|
|
7761
|
-
slots[slotName] = {
|
|
7762
|
-
type: "bricks",
|
|
7763
|
-
bricks: []
|
|
7764
|
-
};
|
|
7765
|
-
}
|
|
7766
|
-
var slotConf = slots[slotName];
|
|
7767
|
-
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
7768
|
-
if (slotConf.bricks.length === 0) {
|
|
7769
|
-
delete slots[slotName];
|
|
7770
|
-
}
|
|
7771
|
-
};
|
|
7772
|
-
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
7773
|
-
_loop(slotName, _quasis);
|
|
7774
|
-
}
|
|
7775
|
-
}
|
|
7776
|
-
return {
|
|
7777
|
-
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
7778
|
-
[symbolForRefForProxy]: refForProxy,
|
|
7779
|
-
[symbolForTplContextId]: templateContextId
|
|
7780
|
-
};
|
|
7781
|
-
}
|
|
7782
|
-
|
|
7783
|
-
var _excluded$4 = ["properties", "slots"];
|
|
7784
|
-
function setupUseBrickInTemplate(props, proxyContext) {
|
|
7785
|
-
function walk(props) {
|
|
7786
|
-
if (!brickUtils.isObject(props)) {
|
|
7787
|
-
return props;
|
|
7788
|
-
}
|
|
7789
|
-
if (Array.isArray(props)) {
|
|
7790
|
-
return props.map(walk);
|
|
7791
|
-
}
|
|
7792
|
-
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
7793
|
-
var [key, value] = _ref;
|
|
7794
|
-
return brickUtils.isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
7795
|
-
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
7796
|
-
}
|
|
7797
|
-
function setup(item) {
|
|
7798
|
-
var {
|
|
7799
|
-
properties,
|
|
7800
|
-
slots: originalSlots
|
|
7801
|
-
} = item,
|
|
7802
|
-
restConf = _objectWithoutProperties__default["default"](item, _excluded$4);
|
|
7803
|
-
var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
|
|
7804
|
-
var _slotConf$bricks;
|
|
7805
|
-
var [slotName, slotConf] = _ref2;
|
|
7806
|
-
return [slotName, {
|
|
7807
|
-
type: "bricks",
|
|
7808
|
-
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
7809
|
-
}];
|
|
7810
|
-
}));
|
|
7811
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, restConf), {}, {
|
|
7812
|
-
properties: walk(properties),
|
|
7813
|
-
slots
|
|
7814
|
-
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
7815
|
-
}
|
|
7816
|
-
return walk(props);
|
|
7817
|
-
}
|
|
7818
|
-
|
|
7819
7824
|
var _excluded$3 = ["properties", "slots"],
|
|
7820
7825
|
_excluded2 = ["ref", "slots"];
|
|
7821
7826
|
function expandCustomTemplate(brickConf, proxyBrick, context) {
|