@next-core/brick-kit 2.200.4 → 2.202.0
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 +86 -11
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +97 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/types/ModalStack.d.ts +6 -0
- package/dist/types/ModalStack.d.ts.map +1 -0
- package/dist/types/core/CustomTemplates/expandCustomTemplate.d.ts +1 -0
- package/dist/types/core/CustomTemplates/expandCustomTemplate.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/replaceSlotWithSlottedBricks.d.ts +4 -0
- package/dist/types/core/CustomTemplates/replaceSlotWithSlottedBricks.d.ts.map +1 -0
- package/dist/types/core/CustomTemplates/setupTemplateProxy.d.ts +1 -1
- package/dist/types/core/CustomTemplates/setupTemplateProxy.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.bundle.js
CHANGED
|
@@ -3238,7 +3238,7 @@
|
|
|
3238
3238
|
}, computedBaseValue);
|
|
3239
3239
|
}
|
|
3240
3240
|
|
|
3241
|
-
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
3241
|
+
function setupTemplateProxy(proxyContext, ref, slots, slotted) {
|
|
3242
3242
|
var computedPropsFromProxy = {};
|
|
3243
3243
|
var refForProxy;
|
|
3244
3244
|
var {
|
|
@@ -3284,6 +3284,9 @@
|
|
|
3284
3284
|
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
3285
3285
|
var quasisMap = new Map();
|
|
3286
3286
|
if (reversedProxies.slots.has(ref)) {
|
|
3287
|
+
if (slotted) {
|
|
3288
|
+
throw new Error("Can not have proxied slot ref when the ref target has a slot element child, check your template \"".concat(proxyBrick.type, "\" and ref \"").concat(ref, "\""));
|
|
3289
|
+
}
|
|
3287
3290
|
for (var item of reversedProxies.slots.get(ref)) {
|
|
3288
3291
|
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
3289
3292
|
if (!quasisMap.has(item.refSlot)) {
|
|
@@ -8435,6 +8438,38 @@
|
|
|
8435
8438
|
}
|
|
8436
8439
|
}
|
|
8437
8440
|
|
|
8441
|
+
function isEvaluable(raw) {
|
|
8442
|
+
return /^\s*<%[~=]?\s/.test(raw) && /\s%>\s*$/.test(raw);
|
|
8443
|
+
}
|
|
8444
|
+
|
|
8445
|
+
function replaceSlotWithSlottedBricks(brickConf, proxyContext, expand) {
|
|
8446
|
+
var _brickConf$properties, _brickConf$properties2, _slots$$bricks, _slots, _slots$;
|
|
8447
|
+
// Currently, no support for `if` in a slot.
|
|
8448
|
+
if (brickConf.if != null && !brickConf.if || typeof brickConf.if === "string") {
|
|
8449
|
+
throw new Error("Can not use \"if\" in a slot currently, check your template \"".concat(proxyContext.proxyBrick.type, "\""));
|
|
8450
|
+
}
|
|
8451
|
+
var slot = String((_brickConf$properties = (_brickConf$properties2 = brickConf.properties) === null || _brickConf$properties2 === void 0 ? void 0 : _brickConf$properties2.name) !== null && _brickConf$properties !== void 0 ? _brickConf$properties : "");
|
|
8452
|
+
|
|
8453
|
+
// Currently, no support for expression as slot name.
|
|
8454
|
+
if (isEvaluable(slot)) {
|
|
8455
|
+
throw new Error("Can not use an expression as slot name \"".concat(slot, "\" currently, check your template \"").concat(proxyContext.proxyBrick.type, "\""));
|
|
8456
|
+
}
|
|
8457
|
+
|
|
8458
|
+
// Do not repeat the same slot name in a template.
|
|
8459
|
+
if (proxyContext.usedSlots.has(slot)) {
|
|
8460
|
+
throw new Error("Can not have multiple slots with the same name \"".concat(slot, "\", check your template \"").concat(proxyContext.proxyBrick.type, "\""));
|
|
8461
|
+
}
|
|
8462
|
+
proxyContext.usedSlots.add(slot);
|
|
8463
|
+
if (proxyContext.externalSlots && brickUtils.hasOwnProperty(proxyContext.externalSlots, slot)) {
|
|
8464
|
+
var _proxyContext$externa;
|
|
8465
|
+
var insertBricks = (_proxyContext$externa = proxyContext.externalSlots[slot].bricks) !== null && _proxyContext$externa !== void 0 ? _proxyContext$externa : [];
|
|
8466
|
+
if (insertBricks.length > 0) {
|
|
8467
|
+
return insertBricks;
|
|
8468
|
+
}
|
|
8469
|
+
}
|
|
8470
|
+
return ((_slots$$bricks = (_slots = brickConf.slots) === null || _slots === void 0 ? void 0 : (_slots$ = _slots[""]) === null || _slots$ === void 0 ? void 0 : _slots$.bricks) !== null && _slots$$bricks !== void 0 ? _slots$$bricks : []).flatMap(item => expand(item, proxyContext));
|
|
8471
|
+
}
|
|
8472
|
+
|
|
8438
8473
|
var _excluded$4 = ["properties", "slots"],
|
|
8439
8474
|
_excluded2 = ["ref", "slots"];
|
|
8440
8475
|
function expandCustomTemplate(brickConf, proxyBrick, context) {
|
|
@@ -8563,38 +8598,48 @@
|
|
|
8563
8598
|
templateProperties,
|
|
8564
8599
|
externalSlots: externalSlots,
|
|
8565
8600
|
templateContextId: tplContext.id,
|
|
8566
|
-
proxyBrick
|
|
8601
|
+
proxyBrick,
|
|
8602
|
+
usedSlots: new Set()
|
|
8567
8603
|
};
|
|
8568
8604
|
newBrickConf.slots = {
|
|
8569
8605
|
"": {
|
|
8570
8606
|
type: "bricks",
|
|
8571
|
-
bricks: bricks.
|
|
8607
|
+
bricks: bricks.flatMap(item => expandBrickInTemplate(item, proxyContext))
|
|
8572
8608
|
}
|
|
8573
8609
|
};
|
|
8574
8610
|
return newBrickConf;
|
|
8575
8611
|
}
|
|
8576
|
-
function expandBrickInTemplate(brickConfInTemplate, proxyContext) {
|
|
8612
|
+
function expandBrickInTemplate(brickConfInTemplate, proxyContext, markSlotted) {
|
|
8577
8613
|
// Ignore `if: null` to make `looseCheckIf` working.
|
|
8578
8614
|
if (brickConfInTemplate.if === null) {
|
|
8579
8615
|
delete brickConfInTemplate.if;
|
|
8580
8616
|
}
|
|
8581
|
-
|
|
8617
|
+
if (brickConfInTemplate.brick === "slot") {
|
|
8618
|
+
markSlotted === null || markSlotted === void 0 ? void 0 : markSlotted();
|
|
8619
|
+
return replaceSlotWithSlottedBricks(brickConfInTemplate, proxyContext, expandBrickInTemplate);
|
|
8620
|
+
}
|
|
8621
|
+
var _ref = brickConfInTemplate,
|
|
8622
|
+
{
|
|
8582
8623
|
ref,
|
|
8583
8624
|
slots: slotsInTemplate
|
|
8584
|
-
} =
|
|
8585
|
-
restBrickConfInTemplate = _objectWithoutProperties__default["default"](
|
|
8586
|
-
var
|
|
8625
|
+
} = _ref,
|
|
8626
|
+
restBrickConfInTemplate = _objectWithoutProperties__default["default"](_ref, _excluded2);
|
|
8627
|
+
var slotted = false;
|
|
8628
|
+
var markChild = () => {
|
|
8629
|
+
slotted = true;
|
|
8630
|
+
};
|
|
8631
|
+
var slots = Object.fromEntries(Object.entries(slotsInTemplate !== null && slotsInTemplate !== void 0 ? slotsInTemplate : {}).map(_ref2 => {
|
|
8587
8632
|
var _slotConf$bricks;
|
|
8588
|
-
var [slotName, slotConf] =
|
|
8633
|
+
var [slotName, slotConf] = _ref2;
|
|
8589
8634
|
return [slotName, {
|
|
8590
8635
|
type: "bricks",
|
|
8591
|
-
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).
|
|
8636
|
+
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).flatMap(item => expandBrickInTemplate(item, proxyContext, markChild))
|
|
8592
8637
|
}];
|
|
8593
8638
|
}));
|
|
8594
8639
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, restBrickConfInTemplate), {}, {
|
|
8595
8640
|
properties: setupUseBrickInTemplate(brickConfInTemplate.properties, proxyContext),
|
|
8596
8641
|
slots
|
|
8597
|
-
}, setupTemplateProxy(proxyContext, ref, slots));
|
|
8642
|
+
}, setupTemplateProxy(proxyContext, ref, slots, slotted));
|
|
8598
8643
|
}
|
|
8599
8644
|
|
|
8600
8645
|
// If it's a custom template, return the tag name of the template.
|
|
@@ -15234,6 +15279,35 @@
|
|
|
15234
15279
|
});
|
|
15235
15280
|
}
|
|
15236
15281
|
|
|
15282
|
+
var stack = [];
|
|
15283
|
+
function instantiateModalStack() {
|
|
15284
|
+
var initialIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
|
|
15285
|
+
var index = -1;
|
|
15286
|
+
var pull = () => {
|
|
15287
|
+
if (index > -1) {
|
|
15288
|
+
var found = stack.indexOf(index);
|
|
15289
|
+
// Assert: found should always be greater than -1
|
|
15290
|
+
// istanbul ignore else
|
|
15291
|
+
if (found > -1) {
|
|
15292
|
+
stack.splice(found, 1);
|
|
15293
|
+
}
|
|
15294
|
+
}
|
|
15295
|
+
};
|
|
15296
|
+
var push = () => {
|
|
15297
|
+
var _stack;
|
|
15298
|
+
// Handle pushes without pull
|
|
15299
|
+
pull();
|
|
15300
|
+
// Find the next available index
|
|
15301
|
+
index = ((_stack = stack[stack.length - 1]) !== null && _stack !== void 0 ? _stack : -1) + 1;
|
|
15302
|
+
stack.push(index);
|
|
15303
|
+
return index + initialIndex;
|
|
15304
|
+
};
|
|
15305
|
+
return {
|
|
15306
|
+
push,
|
|
15307
|
+
pull
|
|
15308
|
+
};
|
|
15309
|
+
}
|
|
15310
|
+
|
|
15237
15311
|
/**
|
|
15238
15312
|
* returns true if the given object is a promise
|
|
15239
15313
|
*/
|
|
@@ -16872,6 +16946,7 @@
|
|
|
16872
16946
|
exports.httpErrorToString = httpErrorToString;
|
|
16873
16947
|
exports.i18nText = i18nText;
|
|
16874
16948
|
exports.initI18n = initI18n;
|
|
16949
|
+
exports.instantiateModalStack = instantiateModalStack;
|
|
16875
16950
|
exports.isLoggedIn = isLoggedIn;
|
|
16876
16951
|
exports.logout = logout;
|
|
16877
16952
|
exports.looseCheckIf = looseCheckIf$1;
|