@odoo/owl 2.5.3 → 2.6.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/compile_templates.mjs +107 -23
- package/dist/owl-devtools.zip +0 -0
- package/dist/owl.cjs.js +111 -34
- package/dist/owl.es.js +111 -34
- package/dist/owl.iife.js +111 -34
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/compiler/code_generator.d.ts +12 -6
- package/dist/types/compiler/parser.d.ts +14 -2
- package/dist/types/owl.d.ts +3 -3
- package/dist/types/runtime/app.d.ts +0 -1
- package/dist/types/runtime/template_set.d.ts +2 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/owl.iife.js
CHANGED
|
@@ -3741,6 +3741,7 @@
|
|
|
3741
3741
|
index: 0,
|
|
3742
3742
|
forceNewBlock: true,
|
|
3743
3743
|
translate: parentCtx.translate,
|
|
3744
|
+
translationCtx: parentCtx.translationCtx,
|
|
3744
3745
|
tKeyExpr: null,
|
|
3745
3746
|
nameSpace: parentCtx.nameSpace,
|
|
3746
3747
|
tModelSelectedExpr: parentCtx.tModelSelectedExpr,
|
|
@@ -3843,6 +3844,7 @@
|
|
|
3843
3844
|
forceNewBlock: false,
|
|
3844
3845
|
isLast: true,
|
|
3845
3846
|
translate: true,
|
|
3847
|
+
translationCtx: "",
|
|
3846
3848
|
tKeyExpr: null,
|
|
3847
3849
|
});
|
|
3848
3850
|
// define blocks and utility functions
|
|
@@ -3980,9 +3982,9 @@
|
|
|
3980
3982
|
})
|
|
3981
3983
|
.join("");
|
|
3982
3984
|
}
|
|
3983
|
-
translate(str) {
|
|
3985
|
+
translate(str, translationCtx) {
|
|
3984
3986
|
const match = translationRE.exec(str);
|
|
3985
|
-
return match[1] + this.translateFn(match[2]) + match[3];
|
|
3987
|
+
return match[1] + this.translateFn(match[2], translationCtx) + match[3];
|
|
3986
3988
|
}
|
|
3987
3989
|
/**
|
|
3988
3990
|
* @returns the newly created block name, if any
|
|
@@ -4023,7 +4025,9 @@
|
|
|
4023
4025
|
return this.compileTSlot(ast, ctx);
|
|
4024
4026
|
case 16 /* TTranslation */:
|
|
4025
4027
|
return this.compileTTranslation(ast, ctx);
|
|
4026
|
-
case 17 /*
|
|
4028
|
+
case 17 /* TTranslationContext */:
|
|
4029
|
+
return this.compileTTranslationContext(ast, ctx);
|
|
4030
|
+
case 18 /* TPortal */:
|
|
4027
4031
|
return this.compileTPortal(ast, ctx);
|
|
4028
4032
|
}
|
|
4029
4033
|
}
|
|
@@ -4061,7 +4065,7 @@
|
|
|
4061
4065
|
let { block, forceNewBlock } = ctx;
|
|
4062
4066
|
let value = ast.value;
|
|
4063
4067
|
if (value && ctx.translate !== false) {
|
|
4064
|
-
value = this.translate(value);
|
|
4068
|
+
value = this.translate(value, ctx.translationCtx);
|
|
4065
4069
|
}
|
|
4066
4070
|
if (!ctx.inPreTag) {
|
|
4067
4071
|
value = value.replace(whitespaceRE, " ");
|
|
@@ -4096,6 +4100,7 @@
|
|
|
4096
4100
|
return `[${modifiersCode}${this.captureExpression(handler)}, ctx]`;
|
|
4097
4101
|
}
|
|
4098
4102
|
compileTDomNode(ast, ctx) {
|
|
4103
|
+
var _a;
|
|
4099
4104
|
let { block, forceNewBlock } = ctx;
|
|
4100
4105
|
const isNewBlock = !block || forceNewBlock || ast.dynamicTag !== null || ast.ns;
|
|
4101
4106
|
let codeIdx = this.target.code.length;
|
|
@@ -4151,7 +4156,8 @@
|
|
|
4151
4156
|
}
|
|
4152
4157
|
}
|
|
4153
4158
|
else if (this.translatableAttributes.includes(key)) {
|
|
4154
|
-
|
|
4159
|
+
const attrTranslationCtx = ((_a = ast.attrsTranslationCtx) === null || _a === void 0 ? void 0 : _a[key]) || ctx.translationCtx;
|
|
4160
|
+
attrs[key] = this.translateFn(ast.attrs[key], attrTranslationCtx);
|
|
4155
4161
|
}
|
|
4156
4162
|
else {
|
|
4157
4163
|
expr = `"${ast.attrs[key]}"`;
|
|
@@ -4595,7 +4601,7 @@
|
|
|
4595
4601
|
else {
|
|
4596
4602
|
let value;
|
|
4597
4603
|
if (ast.defaultValue) {
|
|
4598
|
-
const defaultValue = toStringExpression(ctx.translate ? this.translate(ast.defaultValue) : ast.defaultValue);
|
|
4604
|
+
const defaultValue = toStringExpression(ctx.translate ? this.translate(ast.defaultValue, ctx.translationCtx) : ast.defaultValue);
|
|
4599
4605
|
if (ast.value) {
|
|
4600
4606
|
value = `withDefault(${expr}, ${defaultValue})`;
|
|
4601
4607
|
}
|
|
@@ -4629,9 +4635,10 @@
|
|
|
4629
4635
|
* "some-prop" "state" "'some-prop': ctx['state']"
|
|
4630
4636
|
* "onClick.bind" "onClick" "onClick: bind(ctx, ctx['onClick'])"
|
|
4631
4637
|
*/
|
|
4632
|
-
formatProp(name, value) {
|
|
4638
|
+
formatProp(name, value, attrsTranslationCtx, translationCtx) {
|
|
4633
4639
|
if (name.endsWith(".translate")) {
|
|
4634
|
-
|
|
4640
|
+
const attrTranslationCtx = (attrsTranslationCtx === null || attrsTranslationCtx === void 0 ? void 0 : attrsTranslationCtx[name]) || translationCtx;
|
|
4641
|
+
value = toStringExpression(this.translateFn(value, attrTranslationCtx));
|
|
4635
4642
|
}
|
|
4636
4643
|
else {
|
|
4637
4644
|
value = this.captureExpression(value);
|
|
@@ -4653,8 +4660,8 @@
|
|
|
4653
4660
|
name = /^[a-z_]+$/i.test(name) ? name : `'${name}'`;
|
|
4654
4661
|
return `${name}: ${value || undefined}`;
|
|
4655
4662
|
}
|
|
4656
|
-
formatPropObject(obj) {
|
|
4657
|
-
return Object.entries(obj).map(([k, v]) => this.formatProp(k, v));
|
|
4663
|
+
formatPropObject(obj, attrsTranslationCtx, translationCtx) {
|
|
4664
|
+
return Object.entries(obj).map(([k, v]) => this.formatProp(k, v, attrsTranslationCtx, translationCtx));
|
|
4658
4665
|
}
|
|
4659
4666
|
getPropString(props, dynProps) {
|
|
4660
4667
|
let propString = `{${props.join(",")}}`;
|
|
@@ -4667,7 +4674,9 @@
|
|
|
4667
4674
|
let { block } = ctx;
|
|
4668
4675
|
// props
|
|
4669
4676
|
const hasSlotsProp = "slots" in (ast.props || {});
|
|
4670
|
-
const props = ast.props
|
|
4677
|
+
const props = ast.props
|
|
4678
|
+
? this.formatPropObject(ast.props, ast.propsTranslationCtx, ctx.translationCtx)
|
|
4679
|
+
: [];
|
|
4671
4680
|
// slots
|
|
4672
4681
|
let slotDef = "";
|
|
4673
4682
|
if (ast.slots) {
|
|
@@ -4690,7 +4699,7 @@
|
|
|
4690
4699
|
params.push(`__scope: "${scope}"`);
|
|
4691
4700
|
}
|
|
4692
4701
|
if (ast.slots[slotName].attrs) {
|
|
4693
|
-
params.push(...this.formatPropObject(ast.slots[slotName].attrs));
|
|
4702
|
+
params.push(...this.formatPropObject(ast.slots[slotName].attrs, ast.slots[slotName].attrsTranslationCtx, ctx.translationCtx));
|
|
4694
4703
|
}
|
|
4695
4704
|
const slotInfo = `{${params.join(", ")}}`;
|
|
4696
4705
|
slotStr.push(`'${slotName}': ${slotInfo}`);
|
|
@@ -4795,15 +4804,16 @@
|
|
|
4795
4804
|
isMultiple = isMultiple || this.slotNames.has(ast.name);
|
|
4796
4805
|
this.slotNames.add(ast.name);
|
|
4797
4806
|
}
|
|
4798
|
-
const
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
}
|
|
4807
|
+
const attrs = { ...ast.attrs };
|
|
4808
|
+
const dynProps = attrs["t-props"];
|
|
4809
|
+
delete attrs["t-props"];
|
|
4802
4810
|
let key = this.target.loopLevel ? `key${this.target.loopLevel}` : "key";
|
|
4803
4811
|
if (isMultiple) {
|
|
4804
4812
|
key = this.generateComponentKey(key);
|
|
4805
4813
|
}
|
|
4806
|
-
const props = ast.attrs
|
|
4814
|
+
const props = ast.attrs
|
|
4815
|
+
? this.formatPropObject(attrs, ast.attrsTranslationCtx, ctx.translationCtx)
|
|
4816
|
+
: [];
|
|
4807
4817
|
const scope = this.getPropString(props, dynProps);
|
|
4808
4818
|
if (ast.defaultContent) {
|
|
4809
4819
|
const name = this.compileInNewTarget("defaultContent", ast.defaultContent, ctx);
|
|
@@ -4836,6 +4846,12 @@
|
|
|
4836
4846
|
}
|
|
4837
4847
|
return null;
|
|
4838
4848
|
}
|
|
4849
|
+
compileTTranslationContext(ast, ctx) {
|
|
4850
|
+
if (ast.content) {
|
|
4851
|
+
return this.compileAST(ast.content, Object.assign({}, ctx, { translationCtx: ast.translationCtx }));
|
|
4852
|
+
}
|
|
4853
|
+
return null;
|
|
4854
|
+
}
|
|
4839
4855
|
compileTPortal(ast, ctx) {
|
|
4840
4856
|
if (!this.staticDefs.find((d) => d.id === "Portal")) {
|
|
4841
4857
|
this.staticDefs.push({ id: "Portal", expr: `app.Portal` });
|
|
@@ -4905,6 +4921,7 @@
|
|
|
4905
4921
|
parseTOutNode(node, ctx) ||
|
|
4906
4922
|
parseTKey(node, ctx) ||
|
|
4907
4923
|
parseTTranslation(node, ctx) ||
|
|
4924
|
+
parseTTranslationContext(node, ctx) ||
|
|
4908
4925
|
parseTSlot(node, ctx) ||
|
|
4909
4926
|
parseComponent(node, ctx) ||
|
|
4910
4927
|
parseDOMNode(node, ctx) ||
|
|
@@ -5013,6 +5030,7 @@
|
|
|
5013
5030
|
node.removeAttribute("t-ref");
|
|
5014
5031
|
const nodeAttrsNames = node.getAttributeNames();
|
|
5015
5032
|
let attrs = null;
|
|
5033
|
+
let attrsTranslationCtx = null;
|
|
5016
5034
|
let on = null;
|
|
5017
5035
|
let model = null;
|
|
5018
5036
|
for (let attr of nodeAttrsNames) {
|
|
@@ -5073,6 +5091,11 @@
|
|
|
5073
5091
|
else if (attr === "xmlns") {
|
|
5074
5092
|
ns = value;
|
|
5075
5093
|
}
|
|
5094
|
+
else if (attr.startsWith("t-translation-context-")) {
|
|
5095
|
+
const attrName = attr.slice(22);
|
|
5096
|
+
attrsTranslationCtx = attrsTranslationCtx || {};
|
|
5097
|
+
attrsTranslationCtx[attrName] = value;
|
|
5098
|
+
}
|
|
5076
5099
|
else if (attr !== "t-name") {
|
|
5077
5100
|
if (attr.startsWith("t-") && !attr.startsWith("t-att")) {
|
|
5078
5101
|
throw new OwlError(`Unknown QWeb directive: '${attr}'`);
|
|
@@ -5094,6 +5117,7 @@
|
|
|
5094
5117
|
tag: tagName,
|
|
5095
5118
|
dynamicTag,
|
|
5096
5119
|
attrs,
|
|
5120
|
+
attrsTranslationCtx,
|
|
5097
5121
|
on,
|
|
5098
5122
|
ref,
|
|
5099
5123
|
content: children,
|
|
@@ -5234,7 +5258,15 @@
|
|
|
5234
5258
|
if (ast && ast.type === 11 /* TComponent */) {
|
|
5235
5259
|
return {
|
|
5236
5260
|
...ast,
|
|
5237
|
-
slots: {
|
|
5261
|
+
slots: {
|
|
5262
|
+
default: {
|
|
5263
|
+
content: tcall,
|
|
5264
|
+
scope: null,
|
|
5265
|
+
on: null,
|
|
5266
|
+
attrs: null,
|
|
5267
|
+
attrsTranslationCtx: null,
|
|
5268
|
+
},
|
|
5269
|
+
},
|
|
5238
5270
|
};
|
|
5239
5271
|
}
|
|
5240
5272
|
}
|
|
@@ -5349,9 +5381,15 @@
|
|
|
5349
5381
|
node.removeAttribute("t-slot-scope");
|
|
5350
5382
|
let on = null;
|
|
5351
5383
|
let props = null;
|
|
5384
|
+
let propsTranslationCtx = null;
|
|
5352
5385
|
for (let name of node.getAttributeNames()) {
|
|
5353
5386
|
const value = node.getAttribute(name);
|
|
5354
|
-
if (name.startsWith("t-")) {
|
|
5387
|
+
if (name.startsWith("t-translation-context-")) {
|
|
5388
|
+
const attrName = name.slice(22);
|
|
5389
|
+
propsTranslationCtx = propsTranslationCtx || {};
|
|
5390
|
+
propsTranslationCtx[attrName] = value;
|
|
5391
|
+
}
|
|
5392
|
+
else if (name.startsWith("t-")) {
|
|
5355
5393
|
if (name.startsWith("t-on-")) {
|
|
5356
5394
|
on = on || {};
|
|
5357
5395
|
on[name.slice(5)] = value;
|
|
@@ -5395,6 +5433,7 @@
|
|
|
5395
5433
|
const slotAst = parseNode(slotNode, ctx);
|
|
5396
5434
|
let on = null;
|
|
5397
5435
|
let attrs = null;
|
|
5436
|
+
let attrsTranslationCtx = null;
|
|
5398
5437
|
let scope = null;
|
|
5399
5438
|
for (let attributeName of slotNode.getAttributeNames()) {
|
|
5400
5439
|
const value = slotNode.getAttribute(attributeName);
|
|
@@ -5402,6 +5441,11 @@
|
|
|
5402
5441
|
scope = value;
|
|
5403
5442
|
continue;
|
|
5404
5443
|
}
|
|
5444
|
+
else if (attributeName.startsWith("t-translation-context-")) {
|
|
5445
|
+
const attrName = attributeName.slice(22);
|
|
5446
|
+
attrsTranslationCtx = attrsTranslationCtx || {};
|
|
5447
|
+
attrsTranslationCtx[attrName] = value;
|
|
5448
|
+
}
|
|
5405
5449
|
else if (attributeName.startsWith("t-on-")) {
|
|
5406
5450
|
on = on || {};
|
|
5407
5451
|
on[attributeName.slice(5)] = value;
|
|
@@ -5412,17 +5456,32 @@
|
|
|
5412
5456
|
}
|
|
5413
5457
|
}
|
|
5414
5458
|
slots = slots || {};
|
|
5415
|
-
slots[name] = { content: slotAst, on, attrs, scope };
|
|
5459
|
+
slots[name] = { content: slotAst, on, attrs, attrsTranslationCtx, scope };
|
|
5416
5460
|
}
|
|
5417
5461
|
// default slot
|
|
5418
5462
|
const defaultContent = parseChildNodes(clone, ctx);
|
|
5419
5463
|
slots = slots || {};
|
|
5420
5464
|
// t-set-slot="default" has priority over content
|
|
5421
5465
|
if (defaultContent && !slots.default) {
|
|
5422
|
-
slots.default = {
|
|
5466
|
+
slots.default = {
|
|
5467
|
+
content: defaultContent,
|
|
5468
|
+
on,
|
|
5469
|
+
attrs: null,
|
|
5470
|
+
attrsTranslationCtx: null,
|
|
5471
|
+
scope: defaultSlotScope,
|
|
5472
|
+
};
|
|
5423
5473
|
}
|
|
5424
5474
|
}
|
|
5425
|
-
return {
|
|
5475
|
+
return {
|
|
5476
|
+
type: 11 /* TComponent */,
|
|
5477
|
+
name,
|
|
5478
|
+
isDynamic,
|
|
5479
|
+
dynamicProps,
|
|
5480
|
+
props,
|
|
5481
|
+
propsTranslationCtx,
|
|
5482
|
+
slots,
|
|
5483
|
+
on,
|
|
5484
|
+
};
|
|
5426
5485
|
}
|
|
5427
5486
|
// -----------------------------------------------------------------------------
|
|
5428
5487
|
// Slots
|
|
@@ -5434,6 +5493,7 @@
|
|
|
5434
5493
|
const name = node.getAttribute("t-slot");
|
|
5435
5494
|
node.removeAttribute("t-slot");
|
|
5436
5495
|
let attrs = null;
|
|
5496
|
+
let attrsTranslationCtx = null;
|
|
5437
5497
|
let on = null;
|
|
5438
5498
|
for (let attributeName of node.getAttributeNames()) {
|
|
5439
5499
|
const value = node.getAttribute(attributeName);
|
|
@@ -5441,6 +5501,11 @@
|
|
|
5441
5501
|
on = on || {};
|
|
5442
5502
|
on[attributeName.slice(5)] = value;
|
|
5443
5503
|
}
|
|
5504
|
+
else if (attributeName.startsWith("t-translation-context-")) {
|
|
5505
|
+
const attrName = attributeName.slice(22);
|
|
5506
|
+
attrsTranslationCtx = attrsTranslationCtx || {};
|
|
5507
|
+
attrsTranslationCtx[attrName] = value;
|
|
5508
|
+
}
|
|
5444
5509
|
else {
|
|
5445
5510
|
attrs = attrs || {};
|
|
5446
5511
|
attrs[attributeName] = value;
|
|
@@ -5450,10 +5515,14 @@
|
|
|
5450
5515
|
type: 14 /* TSlot */,
|
|
5451
5516
|
name,
|
|
5452
5517
|
attrs,
|
|
5518
|
+
attrsTranslationCtx,
|
|
5453
5519
|
on,
|
|
5454
5520
|
defaultContent: parseChildNodes(node, ctx),
|
|
5455
5521
|
};
|
|
5456
5522
|
}
|
|
5523
|
+
// -----------------------------------------------------------------------------
|
|
5524
|
+
// Translation
|
|
5525
|
+
// -----------------------------------------------------------------------------
|
|
5457
5526
|
function parseTTranslation(node, ctx) {
|
|
5458
5527
|
if (node.getAttribute("t-translation") !== "off") {
|
|
5459
5528
|
return null;
|
|
@@ -5465,6 +5534,21 @@
|
|
|
5465
5534
|
};
|
|
5466
5535
|
}
|
|
5467
5536
|
// -----------------------------------------------------------------------------
|
|
5537
|
+
// Translation Context
|
|
5538
|
+
// -----------------------------------------------------------------------------
|
|
5539
|
+
function parseTTranslationContext(node, ctx) {
|
|
5540
|
+
const translationCtx = node.getAttribute("t-translation-context");
|
|
5541
|
+
if (!translationCtx) {
|
|
5542
|
+
return null;
|
|
5543
|
+
}
|
|
5544
|
+
node.removeAttribute("t-translation-context");
|
|
5545
|
+
return {
|
|
5546
|
+
type: 17 /* TTranslationContext */,
|
|
5547
|
+
content: parseNode(node, ctx),
|
|
5548
|
+
translationCtx,
|
|
5549
|
+
};
|
|
5550
|
+
}
|
|
5551
|
+
// -----------------------------------------------------------------------------
|
|
5468
5552
|
// Portal
|
|
5469
5553
|
// -----------------------------------------------------------------------------
|
|
5470
5554
|
function parseTPortal(node, ctx) {
|
|
@@ -5481,7 +5565,7 @@
|
|
|
5481
5565
|
};
|
|
5482
5566
|
}
|
|
5483
5567
|
return {
|
|
5484
|
-
type:
|
|
5568
|
+
type: 18 /* TPortal */,
|
|
5485
5569
|
target,
|
|
5486
5570
|
content,
|
|
5487
5571
|
};
|
|
@@ -5623,7 +5707,7 @@
|
|
|
5623
5707
|
}
|
|
5624
5708
|
|
|
5625
5709
|
// do not modify manually. This file is generated by the release script.
|
|
5626
|
-
const version = "2.
|
|
5710
|
+
const version = "2.6.1";
|
|
5627
5711
|
|
|
5628
5712
|
// -----------------------------------------------------------------------------
|
|
5629
5713
|
// Scheduler
|
|
@@ -5718,13 +5802,6 @@
|
|
|
5718
5802
|
Scheduler.requestAnimationFrame = window.requestAnimationFrame.bind(window);
|
|
5719
5803
|
|
|
5720
5804
|
let hasBeenLogged = false;
|
|
5721
|
-
const DEV_MSG = () => {
|
|
5722
|
-
const hash = window.owl ? window.owl.__info__.hash : "master";
|
|
5723
|
-
return `Owl is running in 'dev' mode.
|
|
5724
|
-
|
|
5725
|
-
This is not suitable for production use.
|
|
5726
|
-
See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration for more information.`;
|
|
5727
|
-
};
|
|
5728
5805
|
const apps = new Set();
|
|
5729
5806
|
window.__OWL_DEVTOOLS__ || (window.__OWL_DEVTOOLS__ = { apps, Fiber, RootFiber, toRaw, reactive });
|
|
5730
5807
|
class App extends TemplateSet {
|
|
@@ -5741,7 +5818,7 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
|
|
|
5741
5818
|
}
|
|
5742
5819
|
this.warnIfNoStaticProps = config.warnIfNoStaticProps || false;
|
|
5743
5820
|
if (this.dev && !config.test && !hasBeenLogged) {
|
|
5744
|
-
console.info(
|
|
5821
|
+
console.info(`Owl is running in 'dev' mode.`);
|
|
5745
5822
|
hasBeenLogged = true;
|
|
5746
5823
|
}
|
|
5747
5824
|
const env = config.env || {};
|
|
@@ -6138,8 +6215,8 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
|
|
|
6138
6215
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6139
6216
|
|
|
6140
6217
|
|
|
6141
|
-
__info__.date = '2025-
|
|
6142
|
-
__info__.hash = '
|
|
6218
|
+
__info__.date = '2025-03-05T08:37:58.580Z';
|
|
6219
|
+
__info__.hash = '2b5cea9';
|
|
6143
6220
|
__info__.url = 'https://github.com/odoo/owl';
|
|
6144
6221
|
|
|
6145
6222
|
|