@teleporthq/teleport-plugin-common 0.40.9 → 0.40.11

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 (28) hide show
  1. package/__tests__/node-handlers/node-to-jsx/utils.ts +14 -1
  2. package/dist/cjs/node-handlers/node-to-jsx/index.js +1 -1
  3. package/dist/cjs/node-handlers/node-to-jsx/index.js.map +1 -1
  4. package/dist/cjs/node-handlers/node-to-jsx/types.d.ts +1 -0
  5. package/dist/cjs/node-handlers/node-to-jsx/types.d.ts.map +1 -1
  6. package/dist/cjs/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
  7. package/dist/cjs/node-handlers/node-to-jsx/utils.js +11 -0
  8. package/dist/cjs/node-handlers/node-to-jsx/utils.js.map +1 -1
  9. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  10. package/dist/cjs/utils/ast-utils.d.ts.map +1 -1
  11. package/dist/cjs/utils/ast-utils.js +5 -1
  12. package/dist/cjs/utils/ast-utils.js.map +1 -1
  13. package/dist/esm/node-handlers/node-to-jsx/index.js +1 -1
  14. package/dist/esm/node-handlers/node-to-jsx/index.js.map +1 -1
  15. package/dist/esm/node-handlers/node-to-jsx/types.d.ts +1 -0
  16. package/dist/esm/node-handlers/node-to-jsx/types.d.ts.map +1 -1
  17. package/dist/esm/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
  18. package/dist/esm/node-handlers/node-to-jsx/utils.js +11 -0
  19. package/dist/esm/node-handlers/node-to-jsx/utils.js.map +1 -1
  20. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  21. package/dist/esm/utils/ast-utils.d.ts.map +1 -1
  22. package/dist/esm/utils/ast-utils.js +5 -1
  23. package/dist/esm/utils/ast-utils.js.map +1 -1
  24. package/package.json +4 -4
  25. package/src/node-handlers/node-to-jsx/index.ts +4 -1
  26. package/src/node-handlers/node-to-jsx/types.ts +6 -0
  27. package/src/node-handlers/node-to-jsx/utils.ts +12 -0
  28. package/src/utils/ast-utils.ts +5 -1
@@ -640,7 +640,10 @@ const generateCMSListRepeaterNode: NodeToJSX<UIDLCMSListRepeaterNode, types.JSXE
640
640
  types.jsxExpressionContainer(
641
641
  types.arrowFunctionExpression(
642
642
  [types.identifier(node.content.renderPropIdentifier)],
643
- generateNode(node.content.nodes.list, params, options)[0] as types.JSXElement
643
+ generateNode(node.content.nodes.list, params, {
644
+ ...options,
645
+ localIdentifier: node.content.renderPropIdentifier,
646
+ })[0] as types.JSXElement
644
647
  )
645
648
  )
646
649
  )
@@ -56,6 +56,12 @@ export interface JSXGenerationOptions {
56
56
  slotHandling?: 'native' | 'props'
57
57
  customElementTag?: (name: string) => string
58
58
  domHTMLInjection?: (content: string) => types.JSXElement
59
+ /*
60
+ The local context identifier for references inside repeaters/loops
61
+ For example, in a cms-list-repeater with renderPropIdentifier="conditions",
62
+ local references should resolve to properties of "conditions"
63
+ */
64
+ localIdentifier?: string
59
65
  }
60
66
 
61
67
  export type NodeToJSX<NodeType, ReturnType> = (
@@ -207,6 +207,18 @@ export const createConditionIdentifier = (
207
207
 
208
208
  const { id, referenceType, refPath } = dynamicReference.content
209
209
 
210
+ // Handle local references (from repeaters/loops) - they don't have an id
211
+ if (referenceType === 'local') {
212
+ // For local references, the identifier comes from the refPath
213
+ const key = refPath && refPath.length > 0 ? refPath.join('.') : ''
214
+ const prefix = options.localIdentifier || ''
215
+ return {
216
+ key,
217
+ type: 'string', // Default to string, actual type will be determined at runtime
218
+ prefix,
219
+ }
220
+ }
221
+
210
222
  // in case the id is a member expression: eg: fields.name
211
223
  const referenceRoot = id.split('.')[0]
212
224
  const currentType =
@@ -345,8 +345,12 @@ export const objectToObjectExpression = (
345
345
  return acc
346
346
  }
347
347
 
348
+ // Handle null values explicitly - they are valid in array mappers with different schemas
349
+ if (value === null) {
350
+ computedLiteralValue = t.nullLiteral()
351
+ }
348
352
  // This is for function props that have successfully been parsed.
349
- if (typeof value === 'object' && 'functionExpressionParseResult' in value) {
353
+ else if (typeof value === 'object' && 'functionExpressionParseResult' in value) {
350
354
  computedLiteralValue = value.functionExpressionParseResult
351
355
  } else if (value instanceof ParsedASTNode || value.constructor.name === 'ParsedASTNode') {
352
356
  computedLiteralValue = (value as ParsedASTNode).ast