@wavemaker-ai/react-codegen 1.0.0-rc.319 → 1.0.0-rc.324
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/transpiler/index.d.mts +6 -0
- package/dist/transpiler/index.mjs +77 -22
- package/dist/transpiler/index.mjs.map +1 -1
- package/dist/transpiler/wm-styles.css +119 -5
- package/package-lock.json +87 -87
- package/package.json +1 -1
- package/src/app.generator.js +3 -0
- package/src/app.generator.js.map +1 -1
- package/src/transpile/bind.ex.transformer.js +12 -4
- package/src/transpile/bind.ex.transformer.js.map +1 -1
- package/src/transpile/components/data/form/form-action.transformer.js +8 -3
- package/src/transpile/components/data/form/form-action.transformer.js.map +1 -1
- package/src/transpile/components/data/form/form-field.transformer.js +8 -5
- package/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
- package/src/transpile/components/data/list/list-transformer.js +1 -1
- package/src/transpile/components/data/list/list-transformer.js.map +1 -1
- package/src/transpile/components/data/table/table.transformer.js +20 -10
- package/src/transpile/components/data/table/table.transformer.js.map +1 -1
- package/src/transpile/components/dialogs/dialog-actions.transformer.js +1 -1
- package/src/transpile/components/dialogs/dialog-actions.transformer.js.map +1 -1
- package/src/transpile/components/input/chips.transformer.js +1 -0
- package/src/transpile/components/input/chips.transformer.js.map +1 -1
- package/src/transpile/components/page/build-partial-markup.js +12 -1
- package/src/transpile/components/page/build-partial-markup.js.map +1 -1
- package/src/transpile/components/utils.js +9 -4
- package/src/transpile/components/utils.js.map +1 -1
- package/src/transpile/property/property-parser.js +2 -0
- package/src/transpile/property/property-parser.js.map +1 -1
- package/src/transpile/transpile.js +44 -4
- package/src/transpile/transpile.js.map +1 -1
- package/templates/component/component.hbs +1 -0
- package/templates/component/partial.hbs +1 -0
- package/templates/project/app/components.css +110 -0
- package/templates/project/app/widgetInlineStylesOverride.css +9 -5
- package/templates/project/package.json +4 -4
|
@@ -14,6 +14,12 @@ interface TranspiledOutput {
|
|
|
14
14
|
imports: Import[];
|
|
15
15
|
pageEvents?: Record<string, string>;
|
|
16
16
|
autolayoutCss?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Dependency paths this component reads cross-context from the active page, e.g.
|
|
19
|
+
* `Variables.PageDataInvoke1.dataSet.content` or `Widgets.button1.caption`. The runtime
|
|
20
|
+
* value-gates re-renders to exactly these. Empty for components with no such bindings.
|
|
21
|
+
*/
|
|
22
|
+
activePageDeps?: string[];
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
declare const transform: (expr: string, scopeName?: string, mode?: "event" | "attr") => string;
|
|
@@ -39328,6 +39328,7 @@ var htmlElements = [
|
|
|
39328
39328
|
var FORMAT_CONTEXT = "{formatContext:''}";
|
|
39329
39329
|
var FORMAT_CONTEXT_REGEX = /\{formatContext:''\}/g;
|
|
39330
39330
|
var FRAGMENT_SCOPED_NAMES = ["appLocale", "Variables"];
|
|
39331
|
+
var LIST_SCOPE_VARS = /* @__PURE__ */ new Set(["currentItemWidgets"]);
|
|
39331
39332
|
var ExpressionTransformer = class {
|
|
39332
39333
|
constructor(ctx = "this", mode = "attr") {
|
|
39333
39334
|
this.ctx = ctx;
|
|
@@ -39357,10 +39358,16 @@ var ExpressionTransformer = class {
|
|
|
39357
39358
|
if (this.mode === "event" && ast.receiver instanceof ImplicitReceiver && ast.name === "$event") {
|
|
39358
39359
|
return "$event";
|
|
39359
39360
|
}
|
|
39361
|
+
if (ast.receiver instanceof ImplicitReceiver && LIST_SCOPE_VARS.has(ast.name)) {
|
|
39362
|
+
return ast.name;
|
|
39363
|
+
}
|
|
39360
39364
|
const r = this.build(ast.receiver);
|
|
39361
39365
|
return `${r}.${ast.name}`;
|
|
39362
39366
|
}
|
|
39363
39367
|
processSafePropertyRead(ast) {
|
|
39368
|
+
if (ast.receiver instanceof ImplicitReceiver && LIST_SCOPE_VARS.has(ast.name)) {
|
|
39369
|
+
return ast.name;
|
|
39370
|
+
}
|
|
39364
39371
|
const r = this.build(ast.receiver);
|
|
39365
39372
|
return `${r}?.${ast.name}`;
|
|
39366
39373
|
}
|
|
@@ -40399,14 +40406,16 @@ var transformRepeatChildAttr = (element, replace2, replaceWith) => {
|
|
|
40399
40406
|
if (isList) {
|
|
40400
40407
|
return;
|
|
40401
40408
|
}
|
|
40402
|
-
|
|
40403
|
-
value = removeOptionChaining(value);
|
|
40409
|
+
const value = element.attributes[name];
|
|
40404
40410
|
const regex = new RegExp(
|
|
40405
40411
|
replace2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "(?![a-zA-Z_$0-9])",
|
|
40406
40412
|
"g"
|
|
40407
40413
|
);
|
|
40408
|
-
|
|
40409
|
-
|
|
40414
|
+
const stripped = removeOptionChaining(value);
|
|
40415
|
+
const replaced = stripped.replace(regex, replaceWith);
|
|
40416
|
+
if (replaced !== stripped) {
|
|
40417
|
+
element.setAttribute(name, replaced);
|
|
40418
|
+
}
|
|
40410
40419
|
});
|
|
40411
40420
|
element.childNodes.forEach((c) => {
|
|
40412
40421
|
if (isHTMLElement(c)) {
|
|
@@ -40806,6 +40815,7 @@ var PARSER_MAP = /* @__PURE__ */ new Map([
|
|
|
40806
40815
|
["flexshrink", NUMERIC_PARSER],
|
|
40807
40816
|
["hastwowaybinding", BOOLEAN_PARSER],
|
|
40808
40817
|
["headernavigation", BOOLEAN_PARSER],
|
|
40818
|
+
["hidden", BOOLEAN_PARSER],
|
|
40809
40819
|
["hideclose", BOOLEAN_PARSER],
|
|
40810
40820
|
["iconsize", STRING_PARSER],
|
|
40811
40821
|
["imageheight", STRING_PARSER],
|
|
@@ -40889,7 +40899,8 @@ var PARSER_MAP = /* @__PURE__ */ new Map([
|
|
|
40889
40899
|
["fastload", BOOLEAN_PARSER],
|
|
40890
40900
|
["enablescroll", BOOLEAN_PARSER],
|
|
40891
40901
|
["showactions", BOOLEAN_PARSER],
|
|
40892
|
-
["popoverarrow", BOOLEAN_PARSER]
|
|
40902
|
+
["popoverarrow", BOOLEAN_PARSER],
|
|
40903
|
+
["enablefullscreen", BOOLEAN_PARSER]
|
|
40893
40904
|
])
|
|
40894
40905
|
],
|
|
40895
40906
|
[
|
|
@@ -42017,6 +42028,18 @@ function extractVariableNamesFromElement(e) {
|
|
|
42017
42028
|
});
|
|
42018
42029
|
return Array.from(vars);
|
|
42019
42030
|
}
|
|
42031
|
+
function extractActivePageDeps(source) {
|
|
42032
|
+
const deps = /* @__PURE__ */ new Set();
|
|
42033
|
+
const pattern = /fragment(?:\?\.|\.)App(?:\?\.|\.)activePage((?:(?:\?\.|\.)[a-zA-Z0-9_$]+)+)/g;
|
|
42034
|
+
for (const m of source.matchAll(pattern)) {
|
|
42035
|
+
const path = m[1].replace(/\?\./g, ".").replace(/^\./, "");
|
|
42036
|
+
if (path) {
|
|
42037
|
+
deps.add(path);
|
|
42038
|
+
}
|
|
42039
|
+
}
|
|
42040
|
+
const all = Array.from(deps);
|
|
42041
|
+
return all.filter((path) => !all.some((other) => other !== path && other.startsWith(`${path}.`)));
|
|
42042
|
+
}
|
|
42020
42043
|
var EVENT_NAME_MAP = {
|
|
42021
42044
|
"on-dblclick": "on-doubleClick",
|
|
42022
42045
|
"on-mouseenter": "on-mouseEnter",
|
|
@@ -42354,7 +42377,8 @@ var _Transpiler = class _Transpiler {
|
|
|
42354
42377
|
transformStyles(e, context) {
|
|
42355
42378
|
var _a, _b;
|
|
42356
42379
|
let rawStylesObj = {};
|
|
42357
|
-
const
|
|
42380
|
+
const style_attr = e.getAttribute("style");
|
|
42381
|
+
const rawStyles = e.getAttribute("styles") || style_attr;
|
|
42358
42382
|
if (rawStyles && !rawStyles.startsWith("bind:") && !rawStyles.startsWith("{")) {
|
|
42359
42383
|
rawStyles.split(";").forEach((rule) => {
|
|
42360
42384
|
const colonIdx = rule.indexOf(":");
|
|
@@ -42368,6 +42392,9 @@ var _Transpiler = class _Transpiler {
|
|
|
42368
42392
|
}
|
|
42369
42393
|
});
|
|
42370
42394
|
e.removeAttribute("styles");
|
|
42395
|
+
if (style_attr) {
|
|
42396
|
+
e.removeAttribute("style");
|
|
42397
|
+
}
|
|
42371
42398
|
}
|
|
42372
42399
|
const hasConditionalStyles = e.getAttribute("conditionalstyle");
|
|
42373
42400
|
if (hasConditionalStyles) {
|
|
@@ -42866,7 +42893,9 @@ _Transpiler.SKELETON_ATTR_RENAME = {
|
|
|
42866
42893
|
_Transpiler.FRAGMENT_CALLEE_REF = /^fragment(?:\??\.[a-zA-Z_$][\w$]*|(?:\?\.)?\[[^\]]*\])*$/;
|
|
42867
42894
|
// Callee paths rooted at runtime instance objects (Actions, Variables) whose methods
|
|
42868
42895
|
// (invoke, navigate, setData, …) rely on `this` and must not be emitted as detached refs.
|
|
42869
|
-
|
|
42896
|
+
// Anchored to `fragment` so `fragment?.myService?.Actions?.run` (custom object that happens
|
|
42897
|
+
// to have an Actions property) is NOT incorrectly forced into an arrow wrapper.
|
|
42898
|
+
_Transpiler.INSTANCE_BOUND_CALLEE = /^fragment(?:\?\.|\.)(?:Actions|Variables)(?:\?\.|\.|\[|$)/;
|
|
42870
42899
|
var Transpiler = _Transpiler;
|
|
42871
42900
|
var transpiler = new Transpiler();
|
|
42872
42901
|
var registerTransformer = transpiler.registerTransformer.bind(transpiler);
|
|
@@ -42928,6 +42957,8 @@ var transpileMarkup = (markup, isPartOfPrefab, splitCode, variables, preview, in
|
|
|
42928
42957
|
}
|
|
42929
42958
|
});
|
|
42930
42959
|
finalResult.autolayoutCss = autolayoutCodegen.getDynamicCssRules();
|
|
42960
|
+
const generatedSource = [finalResult.markup, ...Object.values(finalResult.components)].join("\n");
|
|
42961
|
+
finalResult.activePageDeps = extractActivePageDeps(generatedSource);
|
|
42931
42962
|
return finalResult;
|
|
42932
42963
|
};
|
|
42933
42964
|
var transformAttrs = transpiler.transformAttrs.bind(transpiler);
|
|
@@ -42974,7 +43005,7 @@ var createExpression = (element, attrName) => {
|
|
|
42974
43005
|
}
|
|
42975
43006
|
displayexpression = displayexpression.replace(
|
|
42976
43007
|
/fragment\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g,
|
|
42977
|
-
|
|
43008
|
+
(match, name) => FRAGMENT_SCOPED_NAMES.includes(name) ? match : `$item.${name}`
|
|
42978
43009
|
);
|
|
42979
43010
|
displayexpression = addOptionalChaining(displayexpression);
|
|
42980
43011
|
const exp = (0, import_lodash5.includes)(displayexpression, "(") ? `${displayexpression}` : displayexpression;
|
|
@@ -43415,10 +43446,12 @@ function buildPartialMarkup(element, context, componentName) {
|
|
|
43415
43446
|
});
|
|
43416
43447
|
}
|
|
43417
43448
|
const watch = [];
|
|
43449
|
+
const typedParams = /* @__PURE__ */ new Set();
|
|
43418
43450
|
element.childNodes.filter((node) => isHTMLElement(node) && node.tagName === "WM-PARAM").forEach((node) => {
|
|
43419
43451
|
const e = node;
|
|
43420
43452
|
const name2 = e.getAttribute("name") || "";
|
|
43421
43453
|
let value = e.getAttribute("value") || "";
|
|
43454
|
+
const type = e.getAttribute("type") || "";
|
|
43422
43455
|
if (value.includes("currentItem")) {
|
|
43423
43456
|
const match = value.match(/currentItem\..+/);
|
|
43424
43457
|
if (match) {
|
|
@@ -43426,14 +43459,23 @@ function buildPartialMarkup(element, context, componentName) {
|
|
|
43426
43459
|
}
|
|
43427
43460
|
}
|
|
43428
43461
|
params[name2] = value;
|
|
43462
|
+
if (type && ["string", "boolean", "number"].includes(type)) {
|
|
43463
|
+
typedParams.add(name2);
|
|
43464
|
+
}
|
|
43429
43465
|
watch.push(name2);
|
|
43430
43466
|
});
|
|
43431
43467
|
const syntheticTag = componentName.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
|
43432
43468
|
let paramStr = Object.keys(params).filter((k) => k !== "on-load").map((k) => `${k}="${(0, import_html_entities.encode)(params[k])}"`).join(" ");
|
|
43469
|
+
const typeAwareInfer = (name2, valWithQuotes) => {
|
|
43470
|
+
if (typedParams.has(name2)) {
|
|
43471
|
+
return valWithQuotes;
|
|
43472
|
+
}
|
|
43473
|
+
return inferTypeAndParseProperty(name2, valWithQuotes);
|
|
43474
|
+
};
|
|
43433
43475
|
paramStr = transformAttrs(
|
|
43434
43476
|
parse5(`<${syntheticTag} ${paramStr}/>`).firstChild,
|
|
43435
43477
|
context,
|
|
43436
|
-
|
|
43478
|
+
typeAwareInfer
|
|
43437
43479
|
);
|
|
43438
43480
|
paramStr += ` content={props.content}`;
|
|
43439
43481
|
if (context.isPartOfPrefab) {
|
|
@@ -43854,7 +43896,7 @@ var buildItemAttrsFromListTemplate = (template, context) => {
|
|
|
43854
43896
|
if (autoLayoutResult && autolayout) {
|
|
43855
43897
|
parts.push(`layoutClassName: ${autolayout.buildItemAttrsClassName(autoLayoutResult)}`);
|
|
43856
43898
|
}
|
|
43857
|
-
const skipAttrs = /* @__PURE__ */ new Set(["name", "data-widget-id", "item-id"]);
|
|
43899
|
+
const skipAttrs = /* @__PURE__ */ new Set(["name", "data-widget-id", "item-id", "layout"]);
|
|
43858
43900
|
if (autoLayoutResult) {
|
|
43859
43901
|
for (const name of LAYOUT_ATTR_NAMES) skipAttrs.add(name);
|
|
43860
43902
|
}
|
|
@@ -44177,13 +44219,15 @@ var getFormWidgetTemplate = (widgetType, widgetName, element, formDataVariable)
|
|
|
44177
44219
|
widgetName = widgetName.replace(".", "_");
|
|
44178
44220
|
(_b = (_a = getAttribute(element, "key")) == null ? void 0 : _a.split(".")) == null ? void 0 : _b.at(-1);
|
|
44179
44221
|
const formfieldName = getAttribute(element, "name");
|
|
44180
|
-
|
|
44222
|
+
const displayname = getAttribute(element, "displayname");
|
|
44223
|
+
var labelMarkup = `<wm-label
|
|
44181
44224
|
required="bind:$formField.required"
|
|
44182
44225
|
htmlFor="${formfieldName}_formWidget"
|
|
44183
44226
|
caption="bind:$formField.displayname"
|
|
44184
44227
|
class="app-label control-label formfield-label"
|
|
44185
44228
|
conditionalclass="bind:$formField.captionCls + ' ' + $formField.invalidCls"
|
|
44186
|
-
name="${widgetName}_formLabel"
|
|
44229
|
+
name="${widgetName}_formLabel"
|
|
44230
|
+
${!displayname ? 'hidden="true"' : ""}></wm-label>`;
|
|
44187
44231
|
const onFocus = getAttribute(element, "on-focus");
|
|
44188
44232
|
if (onFocus) {
|
|
44189
44233
|
element.removeAttribute("on-focus");
|
|
@@ -44312,6 +44356,7 @@ var getWidgetMarkup = (widgetType, widgetName, commonFields, element) => {
|
|
|
44312
44356
|
></wm-search>`;
|
|
44313
44357
|
break;
|
|
44314
44358
|
case "chips":
|
|
44359
|
+
const chipsDatasource = getDatasourceExpr(element);
|
|
44315
44360
|
const chipsKeyAttribute = element.getAttribute("key");
|
|
44316
44361
|
if (chipsKeyAttribute) {
|
|
44317
44362
|
element.setAttribute("searchkey", chipsKeyAttribute);
|
|
@@ -44325,6 +44370,7 @@ var getWidgetMarkup = (widgetType, widgetName, commonFields, element) => {
|
|
|
44325
44370
|
dataset="bind:$formField.dataset || 'Option 1, Option 2, Option 3'"
|
|
44326
44371
|
displayfield="bind:$formField.displayfield"
|
|
44327
44372
|
datafield="bind:$formField.datafield"
|
|
44373
|
+
${chipsDatasource ? `datasource="${chipsDatasource}"` : ""}
|
|
44328
44374
|
></wm-chips>`;
|
|
44329
44375
|
break;
|
|
44330
44376
|
case "checkbox":
|
|
@@ -44452,7 +44498,8 @@ var form_field_transformer_default = {
|
|
|
44452
44498
|
formName = currentNode.getAttribute("dynamicForm");
|
|
44453
44499
|
formScope = `formScope={() => fragment?.Widgets?.${formName}}`;
|
|
44454
44500
|
} else {
|
|
44455
|
-
|
|
44501
|
+
const itemId = currentNode == null ? void 0 : currentNode.getAttribute("item-id");
|
|
44502
|
+
formName = itemId || (currentNode == null ? void 0 : currentNode.getAttribute("name"));
|
|
44456
44503
|
}
|
|
44457
44504
|
const formdataPrefix = currentNode == null ? void 0 : currentNode.getAttribute("formdataprefix");
|
|
44458
44505
|
if (formdataPrefix) {
|
|
@@ -44748,13 +44795,16 @@ var form_action_transformer_default = {
|
|
|
44748
44795
|
formName = formName.replace("bind:", "");
|
|
44749
44796
|
isDynamicFormName = true;
|
|
44750
44797
|
}
|
|
44751
|
-
const actionType = element.getAttribute("type");
|
|
44798
|
+
const actionType = element.getAttribute("type") || "button";
|
|
44799
|
+
if (!element.getAttribute("type")) {
|
|
44800
|
+
element.setAttribute("type", "button");
|
|
44801
|
+
}
|
|
44752
44802
|
const name = element.getAttribute("name");
|
|
44753
44803
|
let action = element.getAttribute("action");
|
|
44754
|
-
let btnClass = "btn-default";
|
|
44755
44804
|
const listPrefix = "list.itemWidgets[$index]";
|
|
44756
44805
|
const fragmentPrefix = "fragment?.Widgets";
|
|
44757
44806
|
const widgetsPrefix = "Widgets";
|
|
44807
|
+
let btnClass = "btn-default";
|
|
44758
44808
|
if (actionType === "submit") {
|
|
44759
44809
|
btnClass = "btn-primary";
|
|
44760
44810
|
action = listName ? getWidgetAccessor(listPrefix, formName, "?.submit();", isDynamicFormName) + (action || "") : getWidgetAccessor(widgetsPrefix, formName, "?.submit();", isDynamicFormName) + (action || "");
|
|
@@ -44795,7 +44845,9 @@ var form_action_transformer_default = {
|
|
|
44795
44845
|
}
|
|
44796
44846
|
}).join(";");
|
|
44797
44847
|
}
|
|
44798
|
-
element.
|
|
44848
|
+
if (!element.hasAttribute("class")) {
|
|
44849
|
+
element.setAttribute("class", btnClass);
|
|
44850
|
+
}
|
|
44799
44851
|
element.removeAttribute("formKey");
|
|
44800
44852
|
element.removeAttribute("action");
|
|
44801
44853
|
element.setAttribute("name", name || key || formName);
|
|
@@ -44888,7 +44940,7 @@ var dialog_actions_transformer_default = {
|
|
|
44888
44940
|
applyAttr(
|
|
44889
44941
|
element,
|
|
44890
44942
|
new RegExp("closeDialog(\\?\\.)?\\(\\)", "g"),
|
|
44891
|
-
`Widgets?.${widgetName}?.close()`
|
|
44943
|
+
`Widgets?.${widgetName}?.close?.()`
|
|
44892
44944
|
);
|
|
44893
44945
|
}
|
|
44894
44946
|
return `<WmDialogActions ${transformAttrs(element, context)}>`;
|
|
@@ -45912,6 +45964,7 @@ var chips_transformer_default = {
|
|
|
45912
45964
|
if (getDisplayExpression2) {
|
|
45913
45965
|
element.removeAttribute("displayexpression");
|
|
45914
45966
|
}
|
|
45967
|
+
getDatasourceExpr(element);
|
|
45915
45968
|
return `<WmChips listener={fragment} ${isFormField ? " {...$formField}" : ""} ${getDisplayExpression2 ? `displayexpression=${getDisplayExpression2}` : ""} ${extractDatasetInfo(element)} ${transformAttrs(element, context)}>`;
|
|
45916
45969
|
},
|
|
45917
45970
|
post: (element, context) => "</WmChips>",
|
|
@@ -46591,18 +46644,20 @@ var table_transformer_default = {
|
|
|
46591
46644
|
const datasetAttr = element.getAttribute("dataset");
|
|
46592
46645
|
const datasourceAttr = element.getAttribute("datasource");
|
|
46593
46646
|
const binddatasetAttr = element.getAttribute("binddataset");
|
|
46594
|
-
if (datasetAttr && datasetAttr.
|
|
46647
|
+
if (datasetAttr && datasetAttr.includes(".dataSet")) {
|
|
46595
46648
|
const match = datasetAttr.match(
|
|
46596
|
-
/^bind:fragment\.Variables\.([^.]+)\.dataSet(?=[^A-Za-z0-9_]|$)/
|
|
46649
|
+
/^bind:fragment\.((?:App\.activePage\.|App\.)?Variables)\.([^.]+)\.dataSet(?=[^A-Za-z0-9_]|$)/
|
|
46597
46650
|
);
|
|
46598
46651
|
if (match) {
|
|
46599
|
-
const
|
|
46652
|
+
const scopePath = match[1];
|
|
46653
|
+
const variableName = match[2];
|
|
46600
46654
|
context.set("tableDatasetVariableName", variableName);
|
|
46601
46655
|
if (!datasourceAttr) {
|
|
46602
|
-
|
|
46656
|
+
const datasourceExpr = `fragment.${scopePath}.${variableName}`.split(".").join("?.");
|
|
46657
|
+
element.setAttribute("datasource", `{${datasourceExpr}}`);
|
|
46603
46658
|
}
|
|
46604
46659
|
if (!binddatasetAttr) {
|
|
46605
|
-
element.setAttribute("binddataset",
|
|
46660
|
+
element.setAttribute("binddataset", `${scopePath}.${variableName}.dataSet`);
|
|
46606
46661
|
}
|
|
46607
46662
|
}
|
|
46608
46663
|
}
|