@jay-framework/compiler-jay-html 0.7.0 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.js +20 -8
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -10394,7 +10394,8 @@ function renderInterface(aType) {
10394
10394
  genInterface += Object.keys(aType.props).map((prop) => {
10395
10395
  let childType = aType.props[prop];
10396
10396
  if (childType instanceof JayImportedType) {
10397
- return ` ${prop}: ${childType.name}`;
10397
+ const optional = childType.isOptional ? "?" : "";
10398
+ return ` ${prop}${optional}: ${childType.name}`;
10398
10399
  } else if (isObjectType$1(childType)) {
10399
10400
  childInterfaces.push(renderInterface(childType));
10400
10401
  return ` ${prop}: ${childType.name}`;
@@ -11281,7 +11282,8 @@ ${indent.curr}return ${childElement.rendered}}, '${trackBy}')`,
11281
11282
  `${indent.firstLine}${asyncType.name}${resolvedGenericTypes}(${getPromiseFragment.rendered}, () => ${childElement.rendered.trim()})`,
11282
11283
  childElement.imports.plus(asyncType.import),
11283
11284
  [...getPromiseFragment.validations, ...childElement.validations],
11284
- childElement.refs
11285
+ childElement.refs,
11286
+ [...getPromiseFragment.recursiveRegions, ...childElement.recursiveRegions]
11285
11287
  );
11286
11288
  }
11287
11289
  function renderNestedComponent(htmlElement, newContext) {
@@ -11341,12 +11343,13 @@ ${indent.curr}return ${childElement.rendered}}, '${trackBy}')`,
11341
11343
  indent
11342
11344
  });
11343
11345
  const accessorFunction = `(${variables.currentVar}: ${variables.currentType.name}) => ${accessorExpr.render().rendered}`;
11346
+ const nestedChildElement = nestRefs(accessorExpr.terms, childElement);
11344
11347
  return new RenderFragment(
11345
- `${indent.firstLine}withData(${accessorFunction}, () => ${childElement.rendered})`,
11346
- childElement.imports.plus(Import.withData).plus(accessorExpr.render().imports),
11347
- [...accessorExpr.validations, ...childElement.validations],
11348
- childElement.refs,
11349
- childElement.recursiveRegions
11348
+ `${indent.firstLine}withData(${accessorFunction}, () => ${nestedChildElement.rendered})`,
11349
+ nestedChildElement.imports.plus(Import.withData).plus(accessorExpr.render().imports),
11350
+ [...accessorExpr.validations, ...nestedChildElement.validations],
11351
+ nestedChildElement.refs,
11352
+ nestedChildElement.recursiveRegions
11350
11353
  );
11351
11354
  } else if (isRecurse(htmlElement)) {
11352
11355
  const refAttr = htmlElement.getAttribute("ref");
@@ -15968,6 +15971,12 @@ function validateRecursivePath(referencePath, rootData, currentPath) {
15968
15971
  const traversedPath = ["data"];
15969
15972
  for (let i = 1; i < pathParts.length; i++) {
15970
15973
  const part = pathParts[i];
15974
+ if (Array.isArray(currentData)) {
15975
+ if (currentData.length === 0) {
15976
+ return `Cannot navigate through empty array at path "$/` + traversedPath.join("/") + `"`;
15977
+ }
15978
+ currentData = currentData[0];
15979
+ }
15971
15980
  if (!currentData || typeof currentData !== "object" || !(part in currentData)) {
15972
15981
  const availableKeys = currentData && typeof currentData === "object" ? Object.keys(currentData) : [];
15973
15982
  return `Property "${part}" not found at path "$/` + traversedPath.join("/") + `"` + (availableKeys.length > 0 ? `. Available properties: ${availableKeys.join(", ")}` : "");
@@ -16090,7 +16099,10 @@ function parseTypes(jayYaml, validations, baseElementName, imports, headlessImpo
16090
16099
  // Pass root data for recursive reference validation
16091
16100
  );
16092
16101
  const headlessImportedTypes = Object.fromEntries(
16093
- headlessImports.map((_) => [_.key, new JayImportedType(_.rootType.name, _.rootType)])
16102
+ headlessImports.map((_) => [
16103
+ _.key,
16104
+ new JayImportedType(_.rootType.name, _.rootType, true)
16105
+ ])
16094
16106
  );
16095
16107
  const finalType = new JayObjectType(resolvedType.name, {
16096
16108
  ...headlessImportedTypes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/compiler-jay-html",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "author": "",
36
36
  "dependencies": {
37
- "@jay-framework/compiler-analyze-exported-types": "^0.7.0",
38
- "@jay-framework/compiler-shared": "^0.7.0",
39
- "@jay-framework/component": "^0.7.0",
40
- "@jay-framework/runtime": "^0.7.0",
41
- "@jay-framework/secure": "^0.7.0",
37
+ "@jay-framework/compiler-analyze-exported-types": "^0.8.0",
38
+ "@jay-framework/compiler-shared": "^0.8.0",
39
+ "@jay-framework/component": "^0.8.0",
40
+ "@jay-framework/runtime": "^0.8.0",
41
+ "@jay-framework/secure": "^0.8.0",
42
42
  "@types/js-yaml": "^4.0.9",
43
43
  "change-case": "^4.1.2",
44
44
  "js-yaml": "^4.1.0",
@@ -50,8 +50,8 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@caiogondim/strip-margin": "^1.0.0",
53
- "@jay-framework/4-react": "^0.7.0",
54
- "@jay-framework/dev-environment": "^0.7.0",
53
+ "@jay-framework/4-react": "^0.8.0",
54
+ "@jay-framework/dev-environment": "^0.8.0",
55
55
  "@testing-library/jest-dom": "^6.2.0",
56
56
  "@types/js-beautify": "^1",
57
57
  "@types/node": "^20.11.5",