@wavemaker-ai/react-codegen 1.0.0-rc.326 → 1.0.0-rc.328

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.
Files changed (38) hide show
  1. package/dist/transpiler/index.mjs +104 -58
  2. package/dist/transpiler/index.mjs.map +1 -1
  3. package/dist/transpiler/wm-styles.css +3 -0
  4. package/package-lock.json +31 -515
  5. package/package.json +7 -23
  6. package/src/app.generator.js +1 -0
  7. package/src/app.generator.js.map +1 -1
  8. package/src/transpile/bind.ex.transformer.js +42 -14
  9. package/src/transpile/bind.ex.transformer.js.map +1 -1
  10. package/src/transpile/components/container/wizardaction.transformer.js +1 -1
  11. package/src/transpile/components/container/wizardaction.transformer.js.map +1 -1
  12. package/src/transpile/components/container/wizardstep.transformer.js +1 -1
  13. package/src/transpile/components/container/wizardstep.transformer.js.map +1 -1
  14. package/src/transpile/components/data/form/form-field.transformer.js +16 -1
  15. package/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
  16. package/src/transpile/components/data/live-filter-field.transformer.js +13 -1
  17. package/src/transpile/components/data/live-filter-field.transformer.js.map +1 -1
  18. package/src/transpile/components/dialogs/dialog.transformer.js +15 -8
  19. package/src/transpile/components/dialogs/dialog.transformer.js.map +1 -1
  20. package/src/transpile/components/transform-register.js +1 -0
  21. package/src/transpile/components/transform-register.js.map +1 -1
  22. package/src/transpile/components/wmx-component/wmx-component.transformer.js +12 -15
  23. package/src/transpile/components/wmx-component/wmx-component.transformer.js.map +1 -1
  24. package/src/transpile/style.transformer.js +6 -1
  25. package/src/transpile/style.transformer.js.map +1 -1
  26. package/src/transpile/transpile.js +1 -1
  27. package/src/transpile/transpile.js.map +1 -1
  28. package/src/transpile/widget-inline-style-processor.js +5 -1
  29. package/src/transpile/widget-inline-style-processor.js.map +1 -1
  30. package/src/utils.browser.js +5 -4
  31. package/src/utils.browser.js.map +1 -1
  32. package/src/utils.js +4 -4
  33. package/src/utils.js.map +1 -1
  34. package/src/wmx.generator.js +4 -26
  35. package/src/wmx.generator.js.map +1 -1
  36. package/templates/component/app.template.hbs +8 -0
  37. package/templates/project/app/components.css +3 -0
  38. package/templates/project/package.json +4 -4
@@ -4567,9 +4567,9 @@ var require_lodash = __commonJS({
4567
4567
  }
4568
4568
  var camelCase = createCompounder(function(result2, word, index) {
4569
4569
  word = word.toLowerCase();
4570
- return result2 + (index ? capitalize5(word) : word);
4570
+ return result2 + (index ? capitalize4(word) : word);
4571
4571
  });
4572
- function capitalize5(string) {
4572
+ function capitalize4(string) {
4573
4573
  return upperFirst2(toString(string).toLowerCase());
4574
4574
  }
4575
4575
  function deburr(string) {
@@ -5178,7 +5178,7 @@ var require_lodash = __commonJS({
5178
5178
  lodash.add = add;
5179
5179
  lodash.attempt = attempt;
5180
5180
  lodash.camelCase = camelCase;
5181
- lodash.capitalize = capitalize5;
5181
+ lodash.capitalize = capitalize4;
5182
5182
  lodash.ceil = ceil;
5183
5183
  lodash.clamp = clamp;
5184
5184
  lodash.clone = clone2;
@@ -38981,6 +38981,7 @@ var NodeType = import_dist.default.NodeType;
38981
38981
  var esm_default = import_dist.default;
38982
38982
 
38983
38983
  // src/utils.browser.ts
38984
+ var appLocaleRegex = /(fragment\.)?(?:App\.)?appLocale(?:\.messages)?(?:\[(['"])([^'"]+)\2\]|\.([a-zA-Z0-9_]+))/g;
38984
38985
  function isValid(expr) {
38985
38986
  try {
38986
38987
  (0, import_parser.parse)(expr, { sourceType: "module", plugins: ["optionalChaining"] });
@@ -39270,7 +39271,6 @@ var transformAppLocale = (exp) => {
39270
39271
  exp = exp.replace("fragment?.Prefab", "fragment");
39271
39272
  exp = exp.replace("fragment.Prefab", "fragment");
39272
39273
  }
39273
- const appLocaleRegex = /(fragment\.)?appLocale(?:\.messages)?(?:\[(['"])([^'"]+)\2\]|\.([a-zA-Z0-9_]+))/g;
39274
39274
  const replacer = (fullMatch, fragmentPrefix, quoteType, keyFromBrackets, keyFromDot) => {
39275
39275
  const key = keyFromBrackets || keyFromDot;
39276
39276
  if (key) {
@@ -39505,8 +39505,30 @@ var htmlElements = [
39505
39505
  // src/transpile/bind.ex.transformer.ts
39506
39506
  var FORMAT_CONTEXT = "{formatContext:''}";
39507
39507
  var FORMAT_CONTEXT_REGEX = /\{formatContext:''\}/g;
39508
- var FRAGMENT_SCOPED_NAMES = ["appLocale", "Variables"];
39508
+ var FRAGMENT_SCOPED_NAMES = ["appLocale", "Variables", "App"];
39509
39509
  var LIST_SCOPE_VARS = /* @__PURE__ */ new Set(["currentItemWidgets"]);
39510
+ var JS_GLOBALS = /* @__PURE__ */ new Set([
39511
+ "Number",
39512
+ "String",
39513
+ "Boolean",
39514
+ "Array",
39515
+ "Object",
39516
+ "Date",
39517
+ "Math",
39518
+ "JSON",
39519
+ "RegExp",
39520
+ "Promise",
39521
+ "Symbol",
39522
+ "BigInt",
39523
+ "parseInt",
39524
+ "parseFloat",
39525
+ "isNaN",
39526
+ "isFinite",
39527
+ "encodeURIComponent",
39528
+ "decodeURIComponent",
39529
+ "encodeURI",
39530
+ "decodeURI"
39531
+ ]);
39510
39532
  var ExpressionTransformer = class {
39511
39533
  constructor(ctx = "this", mode = "attr") {
39512
39534
  this.ctx = ctx;
@@ -39536,14 +39558,14 @@ var ExpressionTransformer = class {
39536
39558
  if (this.mode === "event" && ast.receiver instanceof ImplicitReceiver && ast.name === "$event") {
39537
39559
  return "$event";
39538
39560
  }
39539
- if (ast.receiver instanceof ImplicitReceiver && LIST_SCOPE_VARS.has(ast.name)) {
39561
+ if (ast.receiver instanceof ImplicitReceiver && (LIST_SCOPE_VARS.has(ast.name) || JS_GLOBALS.has(ast.name))) {
39540
39562
  return ast.name;
39541
39563
  }
39542
39564
  const r = this.build(ast.receiver);
39543
39565
  return `${r}.${ast.name}`;
39544
39566
  }
39545
39567
  processSafePropertyRead(ast) {
39546
- if (ast.receiver instanceof ImplicitReceiver && LIST_SCOPE_VARS.has(ast.name)) {
39568
+ if (ast.receiver instanceof ImplicitReceiver && (LIST_SCOPE_VARS.has(ast.name) || JS_GLOBALS.has(ast.name))) {
39547
39569
  return ast.name;
39548
39570
  }
39549
39571
  const r = this.build(ast.receiver);
@@ -39591,16 +39613,23 @@ var ExpressionTransformer = class {
39591
39613
  const rhs = this.build(ast.value);
39592
39614
  return `${lhs} = ${rhs}`;
39593
39615
  }
39594
- processMethodCall(ast) {
39616
+ buildCallArgs(args) {
39595
39617
  const _args = [];
39596
- for (const arg of ast.args) {
39618
+ for (const arg of args) {
39597
39619
  let argExp = this.build(arg);
39598
- const fragmentScoped = typeof argExp === "string" && FRAGMENT_SCOPED_NAMES.some((name) => argExp.includes(name));
39620
+ const fragmentScoped = typeof argExp === "string" && FRAGMENT_SCOPED_NAMES.some((name) => name !== this.ctx && argExp.includes(name));
39599
39621
  if (this.mode === "event" && !fragmentScoped && argExp.replace) {
39600
39622
  argExp = argExp.replace(`${this.ctx}.`, "");
39601
39623
  }
39602
39624
  _args.push(argExp);
39603
39625
  }
39626
+ return _args;
39627
+ }
39628
+ processMethodCall(ast) {
39629
+ const _args = this.buildCallArgs(ast.args);
39630
+ if (ast.receiver instanceof ImplicitReceiver && JS_GLOBALS.has(ast.name)) {
39631
+ return `${ast.name}(${_args.join(",")})`;
39632
+ }
39604
39633
  const fn2 = this.build(ast.receiver);
39605
39634
  if (_args.includes("currentItemWidgets")) {
39606
39635
  _args.forEach((arg, index) => {
@@ -39612,14 +39641,9 @@ var ExpressionTransformer = class {
39612
39641
  return `${fn2}?.${ast.name}?.(${_args.join(",")})`;
39613
39642
  }
39614
39643
  processSafeMethodCall(ast) {
39615
- const _args = [];
39616
- for (const arg of ast.args) {
39617
- let argExp = this.build(arg);
39618
- const fragmentScoped = typeof argExp === "string" && FRAGMENT_SCOPED_NAMES.some((name) => argExp.includes(name));
39619
- if (this.mode === "event" && !fragmentScoped && argExp.replace) {
39620
- argExp = argExp.replace(`${this.ctx}.`, "");
39621
- }
39622
- _args.push(argExp);
39644
+ const _args = this.buildCallArgs(ast.args);
39645
+ if (ast.receiver instanceof ImplicitReceiver && JS_GLOBALS.has(ast.name)) {
39646
+ return `${ast.name}(${_args.join(",")})`;
39623
39647
  }
39624
39648
  const fn2 = this.build(ast.receiver);
39625
39649
  return `${fn2}?.${ast.name}?.(${_args.join(",")})`;
@@ -40840,7 +40864,10 @@ var style_transformer_default = (element, isStyleProperty) => {
40840
40864
  StyleProps.forEach((parser, k) => {
40841
40865
  if (!!element.hasAttribute(k) && isStyleProperty && isStyleProperty(k)) {
40842
40866
  const value = element.getAttribute(k);
40843
- element.removeAttribute(k);
40867
+ const isFillDimension = (k === "width" || k === "height") && value === "fill";
40868
+ if (!isFillDimension) {
40869
+ element.removeAttribute(k);
40870
+ }
40844
40871
  if (value) {
40845
40872
  if (value.startsWith("bind:")) {
40846
40873
  if (k === "backgroundimage" && value.startsWith('bind:"') && value.endsWith('"')) {
@@ -41905,7 +41932,9 @@ var AutolayoutCodegen = class {
41905
41932
  }
41906
41933
  this.collectSizeFlexProps(element, dimKey, raw, flexProps);
41907
41934
  classNames.push(...this.registerSizeClass(element, dimKey, raw));
41908
- element.removeAttribute(dimKey);
41935
+ if (raw !== "fill") {
41936
+ element.removeAttribute(dimKey);
41937
+ }
41909
41938
  }
41910
41939
  for (const [prop, value] of Object.entries(flexProps)) {
41911
41940
  classNames.push(this.registerClass(prop, value));
@@ -43017,7 +43046,7 @@ var _Transpiler = class _Transpiler {
43017
43046
  if (name === "conditionalclass") {
43018
43047
  return "";
43019
43048
  }
43020
- } else if (name === "width" || name === "height") {
43049
+ } else if ((name === "width" || name === "height") && value != "fill") {
43021
43050
  `${value.substring(5)}`;
43022
43051
  value = `{${value}}`;
43023
43052
  } else {
@@ -44549,6 +44578,7 @@ var getWidgetMarkup = (widgetType, widgetName, commonFields, element) => {
44549
44578
  const timeconfirmationtitle = isDateTimeTag && element.getAttribute("timeconfirmationtitle") ? `timeconfirmationtitle="${(_f = element.getAttribute("timeconfirmationtitle")) == null ? void 0 : _f.replace(/"/g, """)}"` : "";
44550
44579
  const timecanceltitle = isDateTimeTag && element.getAttribute("timecanceltitle") ? `timecanceltitle="${(_g = element.getAttribute("timecanceltitle")) == null ? void 0 : _g.replace(/"/g, """)}"` : "";
44551
44580
  const outputformat = element.getAttribute("outputformat") ? `outputformat="${(_h = element.getAttribute("outputformat")) == null ? void 0 : _h.replace(/"/g, """)}"` : ``;
44581
+ const hyphenatedToComponentName = (str) => str.split("-").map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("") || "";
44552
44582
  switch (widgetType) {
44553
44583
  case "text":
44554
44584
  case "password":
@@ -44733,6 +44763,13 @@ var getWidgetMarkup = (widgetType, widgetName, commonFields, element) => {
44733
44763
  ${floatinglabel}>
44734
44764
  </wm-colorpicker>`;
44735
44765
  break;
44766
+ default:
44767
+ if (widgetType.toLowerCase().includes("wmx")) {
44768
+ const fromAttr = widgetType == null ? void 0 : widgetType.split("-").at(-1);
44769
+ const componentName = hyphenatedToComponentName((fromAttr || "customwidget").trim()) || "Customwidget";
44770
+ tmpl = `<wmx-component componentname="${componentName}" ${commonFields} ${displayExp}></wmx-component>`;
44771
+ }
44772
+ break;
44736
44773
  }
44737
44774
  return tmpl;
44738
44775
  };
@@ -44768,7 +44805,8 @@ var form_field_transformer_default = {
44768
44805
  element.setAttribute("key", strippedKey);
44769
44806
  }
44770
44807
  }
44771
- if (DATASET_WIDGETS.includes(widgetType)) {
44808
+ const usesDatasetBindings = DATASET_WIDGETS.includes(widgetType) || widgetType.toLowerCase().includes("wmx");
44809
+ if (usesDatasetBindings) {
44772
44810
  if (element.attrs["primary-key"]) {
44773
44811
  element.setAttribute("primaryKey", element.attrs["primary-key"]);
44774
44812
  }
@@ -45140,22 +45178,27 @@ var imports36 = [
45140
45178
  var dialog_transformer_default = {
45141
45179
  pre: (element, context) => {
45142
45180
  element.getAttribute("name");
45143
- const content = new HTMLElement(
45144
- "wm-dialogbody",
45145
- {},
45146
- null,
45147
- element,
45148
- [0, 41]
45149
- );
45150
- content.nodeType = NodeType.ELEMENT_NODE;
45151
- const actionsIndex = element.childNodes.findIndex(
45152
- (e) => isHTMLElement(e) && e.tagName.toLowerCase() === "wm-dialogactions"
45181
+ const hasExplicitBody = element.childNodes.some(
45182
+ (e) => isHTMLElement(e) && ["wm-dialogcontent", "wm-dialogbody"].includes(e.tagName.toLowerCase())
45153
45183
  );
45154
- content.childNodes = element.childNodes;
45155
- element.childNodes = [content];
45156
- if (actionsIndex >= 0) {
45157
- const actions = content.childNodes.splice(actionsIndex, 1);
45158
- actions && element.childNodes.push(actions[0]);
45184
+ if (!hasExplicitBody) {
45185
+ const content = new HTMLElement(
45186
+ "wm-dialogbody",
45187
+ {},
45188
+ null,
45189
+ element,
45190
+ [0, 41]
45191
+ );
45192
+ content.nodeType = NodeType.ELEMENT_NODE;
45193
+ const actionsIndex = element.childNodes.findIndex(
45194
+ (e) => isHTMLElement(e) && e.tagName.toLowerCase() === "wm-dialogactions"
45195
+ );
45196
+ content.childNodes = element.childNodes;
45197
+ element.childNodes = [content];
45198
+ if (actionsIndex >= 0) {
45199
+ const actions = content.childNodes.splice(actionsIndex, 1);
45200
+ actions && element.childNodes.push(actions[0]);
45201
+ }
45159
45202
  }
45160
45203
  return `<WmDialog listener={fragment} ${transformAttrs(element, context)}>`;
45161
45204
  },
@@ -46385,7 +46428,7 @@ function getNearestWizardType(element) {
46385
46428
  while (current) {
46386
46429
  current = current.parentNode;
46387
46430
  if (!current) break;
46388
- if (((_a = current.tagName) == null ? void 0 : _a.toLowerCase()) === "wm-wizard") {
46431
+ if (((_a = current == null ? void 0 : current.tagName) == null ? void 0 : _a.toLowerCase()) === "wm-wizard") {
46389
46432
  const type = current.getAttribute("type");
46390
46433
  if (type) {
46391
46434
  return type;
@@ -46430,7 +46473,7 @@ var imports87 = [
46430
46473
  function getNearestWizardName(element) {
46431
46474
  var _a;
46432
46475
  let current = element.parentNode || null;
46433
- if (((_a = current.tagName) == null ? void 0 : _a.toLowerCase()) === "wm-wizard") {
46476
+ if (((_a = current == null ? void 0 : current.tagName) == null ? void 0 : _a.toLowerCase()) === "wm-wizard") {
46434
46477
  const n = current.getAttribute("name");
46435
46478
  if (n) {
46436
46479
  return n;
@@ -47275,6 +47318,14 @@ var getWidgetMarkup2 = (widgetType, widgetName, commonFields, element) => {
47275
47318
  ${floatinglabel}>
47276
47319
  </wm-colorpicker>`;
47277
47320
  break;
47321
+ default:
47322
+ if (widgetType.toLowerCase().includes("wmx")) {
47323
+ const fromAttr = widgetType == null ? void 0 : widgetType.split("-").at(-1);
47324
+ const hyphenatedToComponentName = (str) => str.split("-").map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("") || "";
47325
+ const componentName = hyphenatedToComponentName((fromAttr || "customwidget").trim()) || "Customwidget";
47326
+ tmpl = `<wmx-component componentname="${componentName}" ${commonFields} ${displayExp}></wmx-component>`;
47327
+ }
47328
+ break;
47278
47329
  }
47279
47330
  return tmpl;
47280
47331
  };
@@ -47295,7 +47346,7 @@ var live_filter_field_transformer_default = {
47295
47346
  } else {
47296
47347
  filterName = currentNode.getAttribute("name");
47297
47348
  }
47298
- if (DATASET_WIDGETS.includes(widgetType)) {
47349
+ if (DATASET_WIDGETS.includes(widgetType) || widgetType.toLowerCase().includes("wmx")) {
47299
47350
  if (element.attrs["primary-key"]) {
47300
47351
  element.setAttribute("primaryKey", element.attrs["primary-key"]);
47301
47352
  }
@@ -47415,27 +47466,21 @@ var linear_layout_item_default = {
47415
47466
  };
47416
47467
 
47417
47468
  // src/transpile/components/wmx-component/wmx-component.transformer.ts
47418
- var capitalize4 = (str) => {
47419
- return str ? str.split("-").map((s) => s.charAt(0).toUpperCase() + s.substring(1)).join("") : str;
47420
- };
47421
47469
  var wmx_component_transformer_default = {
47422
47470
  pre: (element, context) => {
47423
- const componentName = capitalize4(element.getAttribute("componentname"));
47424
- return `<Wmx${componentName} ${transformAttrs(element, context, inferTypeAndParseProperty)}>`;
47425
- },
47426
- post: (element, context) => {
47427
- const componentName = capitalize4(element.getAttribute("componentname"));
47428
- return `</Wmx${componentName}>`;
47429
- },
47430
- imports: (element, context) => {
47431
- const componentName = capitalize4(element.getAttribute("componentname"));
47432
- return [
47433
- {
47434
- name: `{Wmx${componentName}}`,
47435
- from: `@wavemaker-ai/wmx-components`
47436
- }
47437
- ];
47471
+ const isFormField = element.getAttribute("formfield") === "true";
47472
+ if (isFormField) {
47473
+ element.removeAttribute("formfield");
47474
+ }
47475
+ return `<WmxRenderer listener={fragment} ${transformAttrs(element, context, inferTypeAndParseProperty)} ${isFormField ? " {...$formField}" : ""}/>`;
47438
47476
  },
47477
+ post: () => "",
47478
+ imports: () => [
47479
+ {
47480
+ name: `WmxRenderer`,
47481
+ from: `@wavemaker-ai/react-runtime/components/wmx/WmxRenderer`
47482
+ }
47483
+ ],
47439
47484
  wmxcomponents: (element, context) => [
47440
47485
  element.getAttribute("componentname")
47441
47486
  ]
@@ -47523,6 +47568,7 @@ var transform_register_default = () => {
47523
47568
  registerTransformer("wm-dialog", dialog_transformer_default);
47524
47569
  registerTransformer("wm-dialogactions", dialog_actions_transformer_default);
47525
47570
  registerTransformer("wm-dialogbody", dialog_body_transformer_default);
47571
+ registerTransformer("wm-dialogcontent", dialog_body_transformer_default);
47526
47572
  registerTransformer("wm-logindialog", login_dialog_transformer_default);
47527
47573
  registerTransformer("wm-list", list_transformer_default);
47528
47574
  registerTransformer("wm-listtemplate", list_template_transformer_default);