@wavemaker-ai/react-codegen 1.0.0-rc.647565 → 1.0.0-rc.647582
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.mjs +100 -91
- package/dist/transpiler/index.mjs.map +1 -1
- package/package-lock.json +91 -91
- package/package.json +1 -1
- package/src/transpile/transform-markup.js +2 -2
- package/src/transpile/transform-markup.js.map +1 -1
- package/src/transpile/transpile.js +11 -6
- package/src/transpile/transpile.js.map +1 -1
- package/src/utils/grouping-util.js +41 -13
- package/src/utils/grouping-util.js.map +1 -1
- package/templates/project/package.json +4 -4
|
@@ -41876,6 +41876,88 @@ var AutolayoutCodegen = class {
|
|
|
41876
41876
|
}
|
|
41877
41877
|
};
|
|
41878
41878
|
|
|
41879
|
+
// src/transpile/components/data/table/utils.ts
|
|
41880
|
+
var CUSTOM_PIPE_REGEX = /(custom(\s*:))/;
|
|
41881
|
+
function checkIsCustomPipeExpression(exp) {
|
|
41882
|
+
return CUSTOM_PIPE_REGEX.test(exp);
|
|
41883
|
+
}
|
|
41884
|
+
function findNearestElement(element, tagName) {
|
|
41885
|
+
var _a, _b;
|
|
41886
|
+
let current = element.parentNode;
|
|
41887
|
+
const target = tagName.toLowerCase();
|
|
41888
|
+
while (current) {
|
|
41889
|
+
if (((_a = current.tagName) == null ? void 0 : _a.toLowerCase()) === target) {
|
|
41890
|
+
return (_b = current.getAttribute("name")) != null ? _b : void 0;
|
|
41891
|
+
}
|
|
41892
|
+
current = current.parentNode;
|
|
41893
|
+
}
|
|
41894
|
+
return void 0;
|
|
41895
|
+
}
|
|
41896
|
+
function convertActionToClickHandler(actionAttr, tableName, liveTableName) {
|
|
41897
|
+
const statements = actionAttr.split(";").map((s) => s.trim()).filter(Boolean);
|
|
41898
|
+
const converted = statements.map((statement) => {
|
|
41899
|
+
statement = convertHyphenatedPropsToBracketNotation(statement);
|
|
41900
|
+
let cleaned = statement.replace(/\$event/g, "event");
|
|
41901
|
+
if (cleaned.startsWith("event.")) return cleaned;
|
|
41902
|
+
if (cleaned.startsWith("Actions") || cleaned.startsWith("Variables") || cleaned.startsWith("Widgets")) {
|
|
41903
|
+
return `fragment.${cleaned}`;
|
|
41904
|
+
}
|
|
41905
|
+
if (cleaned.includes("(")) {
|
|
41906
|
+
const funcName = cleaned.split("(")[0];
|
|
41907
|
+
if (tableName && funcName.startsWith(`${tableName}_`)) {
|
|
41908
|
+
return `fragment.${cleaned}`;
|
|
41909
|
+
}
|
|
41910
|
+
if (cleaned.includes("(event)")) {
|
|
41911
|
+
cleaned = cleaned.replace("(event)", "(event, widget, row)");
|
|
41912
|
+
}
|
|
41913
|
+
if (liveTableName && (funcName.endsWith("addNewRow") || funcName.endsWith("editRow"))) {
|
|
41914
|
+
return `fragment.Widgets.${liveTableName}.${cleaned}`;
|
|
41915
|
+
}
|
|
41916
|
+
return tableName ? `fragment.Widgets.${tableName}.${cleaned}` : `fragment.${cleaned}`;
|
|
41917
|
+
}
|
|
41918
|
+
return `fragment.${cleaned}`;
|
|
41919
|
+
});
|
|
41920
|
+
return `onClick={(event, widget, row) => {
|
|
41921
|
+
${converted.join("\n ")}
|
|
41922
|
+
}}`;
|
|
41923
|
+
}
|
|
41924
|
+
function transformTableColumnClassExpression(expression) {
|
|
41925
|
+
if (!expression) return "";
|
|
41926
|
+
let transformed = expression.replace(/fragment\??\.row/g, "rowData");
|
|
41927
|
+
transformed = transformed.replace(/\brow\./g, "rowData.");
|
|
41928
|
+
transformed = transformed.replace(/\brow\[/g, "rowData[");
|
|
41929
|
+
transformed = addOptionalChaining(transformed);
|
|
41930
|
+
transformed = transformed.replace(/(\w+)\?\.\s*\(/g, "$1(");
|
|
41931
|
+
transformed = transformed.replace(/"([^"]*)"/g, "'$1'");
|
|
41932
|
+
return transformed;
|
|
41933
|
+
}
|
|
41934
|
+
function getFormatCellExpression(element, context) {
|
|
41935
|
+
const binding = element.getAttribute("binding");
|
|
41936
|
+
if (!binding || binding === "rowOperations") {
|
|
41937
|
+
return null;
|
|
41938
|
+
}
|
|
41939
|
+
let formatPattern = element.getAttribute("custompipeformat") || element.getAttribute("formatpattern");
|
|
41940
|
+
if (!formatPattern || formatPattern === "None") {
|
|
41941
|
+
return null;
|
|
41942
|
+
}
|
|
41943
|
+
const columnValue = `row.getProperty('${binding}')`;
|
|
41944
|
+
let pipeExpression = "";
|
|
41945
|
+
if (checkIsCustomPipeExpression(formatPattern)) {
|
|
41946
|
+
pipeExpression = `${columnValue} | ${formatPattern} : row`;
|
|
41947
|
+
}
|
|
41948
|
+
if (!pipeExpression) {
|
|
41949
|
+
return null;
|
|
41950
|
+
}
|
|
41951
|
+
let transformed = bind_ex_transformer_default(pipeExpression, "fragment", "attr");
|
|
41952
|
+
transformed = transformed.replace(/fragment\??\.row/g, "rowData");
|
|
41953
|
+
transformed = transformed.replace(/\brow\./g, "rowData.");
|
|
41954
|
+
transformed = transformed.replace(/\brow\b(?![a-zA-Z_$0-9])/g, "rowData");
|
|
41955
|
+
transformed = resolveFormatContext(transformed, context);
|
|
41956
|
+
transformed = addOptionalChaining(transformed);
|
|
41957
|
+
transformed = transformed.replace(/(\w+)\?\.\s*\(/g, "$1(");
|
|
41958
|
+
return transformed;
|
|
41959
|
+
}
|
|
41960
|
+
|
|
41879
41961
|
// src/transpile/transpile.ts
|
|
41880
41962
|
var generateRandomString = (length = 10) => Math.random().toString(20).substr(2, length);
|
|
41881
41963
|
var EVENT_NAME_MAP = {
|
|
@@ -42403,7 +42485,7 @@ var _Transpiler = class _Transpiler {
|
|
|
42403
42485
|
return false;
|
|
42404
42486
|
}
|
|
42405
42487
|
findArgs(str, context) {
|
|
42406
|
-
var _a;
|
|
42488
|
+
var _a, _b;
|
|
42407
42489
|
let argStr = "";
|
|
42408
42490
|
let maxSplits = 0;
|
|
42409
42491
|
(_a = str.match(/\([^;]*\)/g)) == null ? void 0 : _a.forEach((s) => {
|
|
@@ -42414,7 +42496,7 @@ var _Transpiler = class _Transpiler {
|
|
|
42414
42496
|
}
|
|
42415
42497
|
});
|
|
42416
42498
|
argStr = argStr.replace(/\(|\)/g, "");
|
|
42417
|
-
if (context == null ? void 0 : context.get("isInsideList")) {
|
|
42499
|
+
if ((_b = context == null ? void 0 : context.get) == null ? void 0 : _b.call(context, "isInsideList")) {
|
|
42418
42500
|
argStr = argStr.split(",").filter((s) => !(0, import_lodash5.includes)(["$item", "currentItemWidgets"], s.trim())).join(",");
|
|
42419
42501
|
}
|
|
42420
42502
|
const parsedArgs = this.parseArguments(argStr);
|
|
@@ -42535,6 +42617,7 @@ var _Transpiler = class _Transpiler {
|
|
|
42535
42617
|
return attrName.endsWith("url") || attrName.endsWith("src");
|
|
42536
42618
|
}
|
|
42537
42619
|
transformAttr(tagName, name, value, context, tx) {
|
|
42620
|
+
var _a, _b, _c;
|
|
42538
42621
|
if (name === "styles" || name === "style" || name === "className") ; else if (name === "groupby" && value.includes("(")) {
|
|
42539
42622
|
value = `${this.findArgs(value, context)} => ${value}`;
|
|
42540
42623
|
value = `{${value}}`;
|
|
@@ -42543,12 +42626,12 @@ var _Transpiler = class _Transpiler {
|
|
|
42543
42626
|
value = value.replace(/item,/g, "$item,");
|
|
42544
42627
|
value = value.replace(/item\./g, "$item.");
|
|
42545
42628
|
value = value.replace(/item\)/g, "$item)");
|
|
42546
|
-
if (context == null ? void 0 : context.get("isInsideList")) {
|
|
42629
|
+
if ((_a = context == null ? void 0 : context.get) == null ? void 0 : _a.call(context, "isInsideList")) {
|
|
42547
42630
|
value = value.replace(/;+\s*$/, "").trim();
|
|
42548
42631
|
value = addFragmentOptionalChaining(value, false);
|
|
42549
42632
|
}
|
|
42550
42633
|
const args = this.findArgs(value, context);
|
|
42551
|
-
if (context == null ? void 0 : context.get("isInsideTableColumn")) {
|
|
42634
|
+
if ((_b = context == null ? void 0 : context.get) == null ? void 0 : _b.call(context, "isInsideTableColumn")) {
|
|
42552
42635
|
value = value.replace(/\brow\b/g, "rowData");
|
|
42553
42636
|
}
|
|
42554
42637
|
const arrowParams = this.parseArrowParamNames(args);
|
|
@@ -42571,7 +42654,7 @@ var _Transpiler = class _Transpiler {
|
|
|
42571
42654
|
let exp = `${value.substring(5)}`;
|
|
42572
42655
|
exp = exp.replace("fragment.Page", "fragment");
|
|
42573
42656
|
const isProgressCircleDatavalue = tagName === "wm-progress-circle" && name === "datavalue";
|
|
42574
|
-
exp = modifyExpression(exp);
|
|
42657
|
+
exp = ((_c = context == null ? void 0 : context.get) == null ? void 0 : _c.call(context, "isInsideTableColumn")) ? transformTableColumnClassExpression(exp) : modifyExpression(exp);
|
|
42575
42658
|
exp = resolveFormatContext(exp, context);
|
|
42576
42659
|
exp = this.convertStringBooleanTernary(exp);
|
|
42577
42660
|
if (!exp) {
|
|
@@ -42696,7 +42779,7 @@ _Transpiler.INSTANCE_BOUND_CALLEE = /(?:\?\.|\.)(?:Actions|Variables)(?:\?\.|\.|
|
|
|
42696
42779
|
var Transpiler = _Transpiler;
|
|
42697
42780
|
var transpiler = new Transpiler();
|
|
42698
42781
|
var registerTransformer = transpiler.registerTransformer.bind(transpiler);
|
|
42699
|
-
var transpileMarkup = (markup, isPartOfPrefab, splitCode, variables, preview) => {
|
|
42782
|
+
var transpileMarkup = (markup, isPartOfPrefab, splitCode, variables, preview, insideTableColumn) => {
|
|
42700
42783
|
const parsed = parse5(markup, {
|
|
42701
42784
|
blockTextElements: {}
|
|
42702
42785
|
});
|
|
@@ -42725,7 +42808,8 @@ var transpileMarkup = (markup, isPartOfPrefab, splitCode, variables, preview) =>
|
|
|
42725
42808
|
data: {
|
|
42726
42809
|
twoWayBindingVariables,
|
|
42727
42810
|
autolayoutCodegen,
|
|
42728
|
-
preview: preview === true
|
|
42811
|
+
preview: preview === true,
|
|
42812
|
+
...insideTableColumn ? { isInsideTableColumn: true } : {}
|
|
42729
42813
|
}
|
|
42730
42814
|
});
|
|
42731
42815
|
parsed.childNodes.forEach((node) => {
|
|
@@ -46193,88 +46277,6 @@ var liveform_transformer_default = {
|
|
|
46193
46277
|
imports: (element, context) => imports89
|
|
46194
46278
|
};
|
|
46195
46279
|
|
|
46196
|
-
// src/transpile/components/data/table/utils.ts
|
|
46197
|
-
var CUSTOM_PIPE_REGEX = /(custom(\s*:))/;
|
|
46198
|
-
function checkIsCustomPipeExpression(exp) {
|
|
46199
|
-
return CUSTOM_PIPE_REGEX.test(exp);
|
|
46200
|
-
}
|
|
46201
|
-
function findNearestElement(element, tagName) {
|
|
46202
|
-
var _a, _b;
|
|
46203
|
-
let current = element.parentNode;
|
|
46204
|
-
const target = tagName.toLowerCase();
|
|
46205
|
-
while (current) {
|
|
46206
|
-
if (((_a = current.tagName) == null ? void 0 : _a.toLowerCase()) === target) {
|
|
46207
|
-
return (_b = current.getAttribute("name")) != null ? _b : void 0;
|
|
46208
|
-
}
|
|
46209
|
-
current = current.parentNode;
|
|
46210
|
-
}
|
|
46211
|
-
return void 0;
|
|
46212
|
-
}
|
|
46213
|
-
function convertActionToClickHandler(actionAttr, tableName, liveTableName) {
|
|
46214
|
-
const statements = actionAttr.split(";").map((s) => s.trim()).filter(Boolean);
|
|
46215
|
-
const converted = statements.map((statement) => {
|
|
46216
|
-
statement = convertHyphenatedPropsToBracketNotation(statement);
|
|
46217
|
-
let cleaned = statement.replace(/\$event/g, "event");
|
|
46218
|
-
if (cleaned.startsWith("event.")) return cleaned;
|
|
46219
|
-
if (cleaned.startsWith("Actions") || cleaned.startsWith("Variables") || cleaned.startsWith("Widgets")) {
|
|
46220
|
-
return `fragment.${cleaned}`;
|
|
46221
|
-
}
|
|
46222
|
-
if (cleaned.includes("(")) {
|
|
46223
|
-
const funcName = cleaned.split("(")[0];
|
|
46224
|
-
if (tableName && funcName.startsWith(`${tableName}_`)) {
|
|
46225
|
-
return `fragment.${cleaned}`;
|
|
46226
|
-
}
|
|
46227
|
-
if (cleaned.includes("(event)")) {
|
|
46228
|
-
cleaned = cleaned.replace("(event)", "(event, widget, row)");
|
|
46229
|
-
}
|
|
46230
|
-
if (liveTableName && (funcName.endsWith("addNewRow") || funcName.endsWith("editRow"))) {
|
|
46231
|
-
return `fragment.Widgets.${liveTableName}.${cleaned}`;
|
|
46232
|
-
}
|
|
46233
|
-
return tableName ? `fragment.Widgets.${tableName}.${cleaned}` : `fragment.${cleaned}`;
|
|
46234
|
-
}
|
|
46235
|
-
return `fragment.${cleaned}`;
|
|
46236
|
-
});
|
|
46237
|
-
return `onClick={(event, widget, row) => {
|
|
46238
|
-
${converted.join("\n ")}
|
|
46239
|
-
}}`;
|
|
46240
|
-
}
|
|
46241
|
-
function transformTableColumnClassExpression(expression) {
|
|
46242
|
-
if (!expression) return "";
|
|
46243
|
-
let transformed = expression.replace(/fragment\??\.row/g, "rowData");
|
|
46244
|
-
transformed = transformed.replace(/\brow\./g, "rowData.");
|
|
46245
|
-
transformed = transformed.replace(/\brow\[/g, "rowData[");
|
|
46246
|
-
transformed = addOptionalChaining(transformed);
|
|
46247
|
-
transformed = transformed.replace(/(\w+)\?\.\s*\(/g, "$1(");
|
|
46248
|
-
transformed = transformed.replace(/"([^"]*)"/g, "'$1'");
|
|
46249
|
-
return transformed;
|
|
46250
|
-
}
|
|
46251
|
-
function getFormatCellExpression(element, context) {
|
|
46252
|
-
const binding = element.getAttribute("binding");
|
|
46253
|
-
if (!binding || binding === "rowOperations") {
|
|
46254
|
-
return null;
|
|
46255
|
-
}
|
|
46256
|
-
let formatPattern = element.getAttribute("custompipeformat") || element.getAttribute("formatpattern");
|
|
46257
|
-
if (!formatPattern || formatPattern === "None") {
|
|
46258
|
-
return null;
|
|
46259
|
-
}
|
|
46260
|
-
const columnValue = `row.getProperty('${binding}')`;
|
|
46261
|
-
let pipeExpression = "";
|
|
46262
|
-
if (checkIsCustomPipeExpression(formatPattern)) {
|
|
46263
|
-
pipeExpression = `${columnValue} | ${formatPattern} : row`;
|
|
46264
|
-
}
|
|
46265
|
-
if (!pipeExpression) {
|
|
46266
|
-
return null;
|
|
46267
|
-
}
|
|
46268
|
-
let transformed = bind_ex_transformer_default(pipeExpression, "fragment", "attr");
|
|
46269
|
-
transformed = transformed.replace(/fragment\??\.row/g, "rowData");
|
|
46270
|
-
transformed = transformed.replace(/\brow\./g, "rowData.");
|
|
46271
|
-
transformed = transformed.replace(/\brow\b(?![a-zA-Z_$0-9])/g, "rowData");
|
|
46272
|
-
transformed = resolveFormatContext(transformed, context);
|
|
46273
|
-
transformed = addOptionalChaining(transformed);
|
|
46274
|
-
transformed = transformed.replace(/(\w+)\?\.\s*\(/g, "$1(");
|
|
46275
|
-
return transformed;
|
|
46276
|
-
}
|
|
46277
|
-
|
|
46278
46280
|
// src/transpile/components/data/table/table-column.transformer.ts
|
|
46279
46281
|
var imports90 = [
|
|
46280
46282
|
{ name: "WmTableColumn", from: "@wavemaker-ai/react-runtime/components/data/table/table-column" }
|
|
@@ -47690,8 +47692,15 @@ export default (${scope}:any) => {
|
|
|
47690
47692
|
`;
|
|
47691
47693
|
}
|
|
47692
47694
|
function transformMarkup(markup, options = { appUrl: "", prefabName: "", isPartOfPrefab: false }) {
|
|
47693
|
-
const { isPartOfPrefab = false, variables, appUrl, prefabName } = options;
|
|
47694
|
-
const transpiledOutput = transpileMarkup(
|
|
47695
|
+
const { isPartOfPrefab = false, variables, appUrl, prefabName, insideTableColumn } = options;
|
|
47696
|
+
const transpiledOutput = transpileMarkup(
|
|
47697
|
+
markup,
|
|
47698
|
+
isPartOfPrefab,
|
|
47699
|
+
void 0,
|
|
47700
|
+
variables,
|
|
47701
|
+
true,
|
|
47702
|
+
insideTableColumn
|
|
47703
|
+
);
|
|
47695
47704
|
const transpiledVars = transpileVariableDefinitions(variables, appUrl, "Page");
|
|
47696
47705
|
const variablesCode = serializeVariablesToCode(transpiledVars, "Page", {
|
|
47697
47706
|
isPrefabApp: isPartOfPrefab,
|