diff --git a/.changeset/clean-cobras-know.md b/.changeset/clean-cobras-know.md new file mode 100644 index 0000000000..7e55cccc2e --- /dev/null +++ b/.changeset/clean-cobras-know.md @@ -0,0 +1,31 @@ +--- +'@builder.io/mitosis': patch +--- + +[All] Refactored `useMetadata` hook to enable import resolution instead of simple `JSON5` parsing. + +You could use a normal JS `Object` and import it inside your `*.lite.tsx` file like this: + +```ts +// data.ts + +export const myMetadata: Record = { + a: 'b', + c: 1, +}; +``` + +```tsx +// my-button.lite.tsx +import { useMetadata } from '@builder.io/mitosis'; +import { myMetadata } from './data.ts'; + +useMetadata({ + x: 'y', + my: myMetadata, +}); + +export default function MyButton() { + return ; +} +``` diff --git a/examples/metdata/.eslintrc.js b/examples/metdata/.eslintrc.js new file mode 100644 index 0000000000..6251926add --- /dev/null +++ b/examples/metdata/.eslintrc.js @@ -0,0 +1,18 @@ +module.exports = { + env: { + browser: true, + }, + plugins: ["@builder.io/mitosis"], + parser: "@typescript-eslint/parser", + extends: [], + parserOptions: { + ecmaVersion: 2018, + sourceType: "module", + ecmaFeatures: { + jsx: true, + }, + }, + rules: { + "@builder.io/mitosis/no-conditional-render": "warn", + }, +}; diff --git a/examples/metdata/.gitignore b/examples/metdata/.gitignore new file mode 100644 index 0000000000..6caf68aff4 --- /dev/null +++ b/examples/metdata/.gitignore @@ -0,0 +1 @@ +output \ No newline at end of file diff --git a/examples/metdata/README.md b/examples/metdata/README.md new file mode 100644 index 0000000000..9e598a89e6 --- /dev/null +++ b/examples/metdata/README.md @@ -0,0 +1,3 @@ +# Metadata example for Mitosis + +This is an example to showcase the ``useMetadata`` hook. You can use this to set predefined configuration parameters for each component. Or you can add additional parameters to use them in a plugin. diff --git a/examples/metdata/mitosis.config.js b/examples/metdata/mitosis.config.js new file mode 100644 index 0000000000..217056e20c --- /dev/null +++ b/examples/metdata/mitosis.config.js @@ -0,0 +1,37 @@ +const metadataPlugin = () => ({ + code: { + pre: (code, json) => { + if (json.meta.useMetadata) { + return ` + /** + useMetadata: + ${JSON.stringify(json.meta.useMetadata)} + */ + + ${code}`; + } + + return code; + }, + }, +}); + +module.exports = { + files: 'src/**', + commonOptions: { + plugins: [metadataPlugin], + }, + targets: [ + 'react', + // still unsupported + // 'qwik', + // 'builder', + 'vue', + 'html', + // TO-DO: fix error causing svelte output not to work + // 'svelte', + 'solid', + 'angular', + 'webcomponent', + ], +}; diff --git a/examples/metdata/package.json b/examples/metdata/package.json new file mode 100644 index 0000000000..64e6eb4d19 --- /dev/null +++ b/examples/metdata/package.json @@ -0,0 +1,22 @@ +{ + "name": "@builder.io/metadata-example", + "private": true, + "scripts": { + "build": "mitosis build", + "lint": "eslint" + }, + "exports": { + "./react/*": "./dist/react/src/*", + "./qwik/*": "./dist/qwik/src/*", + "./vue/*": "./dist/vue/src/*", + "./svelte/*": "./dist/svelte/src/*", + "./angular/*": "./dist/angular/src/*", + "./html/*": "./dist/html/src/*", + "./solid/*": "./dist/solid/src/*" + }, + "dependencies": { + "@builder.io/mitosis": "workspace:*", + "@builder.io/mitosis-cli": "workspace:*", + "eslint": "^7.21.0" + } +} diff --git a/examples/metdata/src/components/data.ts b/examples/metdata/src/components/data.ts new file mode 100644 index 0000000000..a363ffeec9 --- /dev/null +++ b/examples/metdata/src/components/data.ts @@ -0,0 +1,13 @@ +import { ComponentMetadata } from '@builder.io/mitosis'; +import { customMetaData } from '../shared/data'; + +export const metadata: ComponentMetadata = { + regularKey: 'abc', + 'some-key': customMetaData, + react: { + forwardRef: 'xxx', + }, + vue: { + customKey: 'yyy', + }, +}; diff --git a/examples/metdata/src/components/metadata.lite.tsx b/examples/metdata/src/components/metadata.lite.tsx new file mode 100644 index 0000000000..a143f9a0b1 --- /dev/null +++ b/examples/metdata/src/components/metadata.lite.tsx @@ -0,0 +1,8 @@ +import { useMetadata } from '@builder.io/mitosis'; +import { metadata } from './data'; + +useMetadata({ ...metadata }); + +export default function MetadataExample() { + return
Metadata
; +} diff --git a/examples/metdata/src/shared/data.ts b/examples/metdata/src/shared/data.ts new file mode 100644 index 0000000000..e44cb48def --- /dev/null +++ b/examples/metdata/src/shared/data.ts @@ -0,0 +1,11 @@ +import { CustomMetadata } from './model'; + +export const customMetaData: CustomMetadata = { + a: 'custom', + b: 1, + c: { + d: 'nested', + }, +}; + + diff --git a/examples/metdata/src/shared/model.ts b/examples/metdata/src/shared/model.ts new file mode 100644 index 0000000000..1a9c259e05 --- /dev/null +++ b/examples/metdata/src/shared/model.ts @@ -0,0 +1,5 @@ +export type CustomMetadata = { + a: string; + b: number; + c: Object; +}; diff --git a/examples/metdata/tsconfig.json b/examples/metdata/tsconfig.json new file mode 100644 index 0000000000..372ba40607 --- /dev/null +++ b/examples/metdata/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ESNext", + "strict": true, + "jsx": "preserve", + "moduleResolution": "node", + "jsxImportSource": "@builder.io/mitosis" + }, + "include": ["src"] +} diff --git a/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap b/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap index 108b6731e1..45a64dd9a7 100644 --- a/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap @@ -241,7 +241,10 @@ exports[`Alpine.js > jsx > Javascript Test > Basic Outputs 1`] = ` `; exports[`Alpine.js > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"
+"/** useMetadata: {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside +component\\"} */ + +
+" +`; + exports[`Alpine.js > jsx > Javascript Test > componentWithContext 1`] = ` "
@@ -1908,6 +1927,35 @@ exports[`Alpine.js > jsx > Javascript Test > expressionState 1`] = ` " `; +exports[`Alpine.js > jsx > Javascript Test > figmaMeta 1`] = ` +"/** useMetadata: +{\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 +Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon +Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ +Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ +Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive +State\\",\\"value\\":{\\"(Def) +Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) +Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) +Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} */ + + + +" +`; + exports[`Alpine.js > jsx > Javascript Test > getterState 1`] = ` "

@@ -3305,7 +3353,10 @@ exports[`Alpine.js > jsx > Typescript Test > Basic Outputs 1`] = ` `; exports[`Alpine.js > jsx > Typescript Test > Basic Outputs Meta 1`] = ` -"
+"/** useMetadata: {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside +component\\"} */ + +
+" +`; + exports[`Alpine.js > jsx > Typescript Test > componentWithContext 1`] = ` "
@@ -4961,6 +5028,35 @@ exports[`Alpine.js > jsx > Typescript Test > expressionState 1`] = ` " `; +exports[`Alpine.js > jsx > Typescript Test > figmaMeta 1`] = ` +"/** useMetadata: +{\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 +Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon +Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ +Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ +Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive +State\\",\\"value\\":{\\"(Def) +Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) +Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) +Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} */ + + + +" +`; + exports[`Alpine.js > jsx > Typescript Test > getterState 1`] = ` "

diff --git a/packages/core/src/__tests__/__snapshots__/angular.import.test.ts.snap b/packages/core/src/__tests__/__snapshots__/angular.import.test.ts.snap index 030255a311..7f3d89de82 100644 --- a/packages/core/src/__tests__/__snapshots__/angular.import.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/angular.import.test.ts.snap @@ -392,7 +392,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -3553,7 +3558,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -3831,6 +3841,41 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -3946,7 +3991,12 @@ export class RenderContentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -4463,6 +4513,54 @@ export class MyComponentModule {} " `; +exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon; + @Input() interactiveState; + @Input() width; + @Input() size; + @Input() label; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -4753,7 +4851,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; @@ -7798,7 +7901,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -11227,7 +11335,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -11517,6 +11630,41 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -11640,7 +11788,12 @@ export class RenderContentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -12182,6 +12335,54 @@ export class MyComponentModule {} " `; +exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon!: any; + @Input() interactiveState!: any; + @Input() width!: any; + @Input() size!: any; + @Input() label!: any; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -12489,7 +12690,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; diff --git a/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap b/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap index 0811f115af..4ceec5bcb7 100644 --- a/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/angular.mapper.test.ts.snap @@ -399,7 +399,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -3603,7 +3608,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Javascript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -3888,6 +3898,42 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with Import Mapper Tests > jsx > Javascript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], + bootstrap: [SomeOtherComponent], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with Import Mapper Tests > jsx > Javascript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -4006,7 +4052,12 @@ export class RenderContentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Javascript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -4531,6 +4582,55 @@ export class MyComponentModule {} " `; +exports[`Angular with Import Mapper Tests > jsx > Javascript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon; + @Input() interactiveState; + @Input() width; + @Input() size; + @Input() label; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], + bootstrap: [SomeOtherComponent], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with Import Mapper Tests > jsx > Javascript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -4827,7 +4927,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Javascript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; @@ -7931,7 +8036,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Typescript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -11403,7 +11513,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Typescript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -11700,6 +11815,42 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with Import Mapper Tests > jsx > Typescript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], + bootstrap: [SomeOtherComponent], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with Import Mapper Tests > jsx > Typescript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -11826,7 +11977,12 @@ export class RenderContentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Typescript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -12376,6 +12532,55 @@ export class MyComponentModule {} " `; +exports[`Angular with Import Mapper Tests > jsx > Typescript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon!: any; + @Input() interactiveState!: any; + @Input() width!: any; + @Input() size!: any; + @Input() label!: any; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], + bootstrap: [SomeOtherComponent], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with Import Mapper Tests > jsx > Typescript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -12691,7 +12896,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with Import Mapper Tests > jsx > Typescript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; diff --git a/packages/core/src/__tests__/__snapshots__/angular.state.test.ts.snap b/packages/core/src/__tests__/__snapshots__/angular.state.test.ts.snap index 70854852df..844a632639 100644 --- a/packages/core/src/__tests__/__snapshots__/angular.state.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/angular.state.test.ts.snap @@ -415,7 +415,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -3691,7 +3696,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -3967,6 +3977,41 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -4080,7 +4125,12 @@ export class RenderContentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -4637,6 +4687,54 @@ export class MyComponentModule {} " `; +exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon; + @Input() interactiveState; + @Input() width; + @Input() size; + @Input() label; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -4953,7 +5051,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; @@ -8072,7 +8175,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -11641,7 +11749,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -11929,6 +12042,41 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -12050,7 +12198,12 @@ export class RenderContentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -12633,6 +12786,54 @@ export class MyComponentModule {} " `; +exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon!: any; + @Input() interactiveState!: any; + @Input() width!: any; + @Input() size!: any; + @Input() label!: any; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -12966,7 +13167,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; diff --git a/packages/core/src/__tests__/__snapshots__/angular.styles.test.ts.snap b/packages/core/src/__tests__/__snapshots__/angular.styles.test.ts.snap index e074ed773a..e4538142f1 100644 --- a/packages/core/src/__tests__/__snapshots__/angular.styles.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/angular.styles.test.ts.snap @@ -351,7 +351,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -3235,7 +3240,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -3482,6 +3492,34 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -3574,7 +3612,12 @@ export class RenderContentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -4039,6 +4082,47 @@ export class MyComponentModule {} " `; +exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, +}) +export default class FigmaButton { + @Input() icon; + @Input() interactiveState; + @Input() width; + @Input() size; + @Input() label; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -4287,7 +4371,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; @@ -6951,7 +7040,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -10103,7 +10197,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -10362,6 +10461,34 @@ export class MyBasicComponentModule {} " `; +exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -10462,7 +10589,12 @@ export class RenderContentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -10952,6 +11084,47 @@ export class MyComponentModule {} " `; +exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, +}) +export default class FigmaButton { + @Input() icon!: any; + @Input() interactiveState!: any; + @Input() width!: any; + @Input() size!: any; + @Input() label!: any; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -11217,7 +11390,12 @@ export class MyBasicComponentModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; diff --git a/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap b/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap index e40044e65c..2cc818ce4d 100644 --- a/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/angular.test.ts.snap @@ -734,7 +734,12 @@ export default class MyBasicOutputsComponent { `; exports[`Angular > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -778,7 +783,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular > jsx > Javascript Test > Basic Outputs Meta 2`] = ` -"import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ @@ -6751,7 +6761,12 @@ export default class MyBasicForwardRefComponent { `; exports[`Angular > jsx > Javascript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -6792,7 +6807,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular > jsx > Javascript Test > basicForwardRefMetadata 2`] = ` -"import { Component } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { Component } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ @@ -7257,6 +7277,69 @@ export default class MyBasicComponent { " `; +exports[`Angular > jsx > Javascript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + +exports[`Angular > jsx > Javascript Test > complexMeta 2`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { Component } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], + standalone: true, + imports: [CommonModule], +}) +export default class ComplexMetaRaw {} +" +`; + exports[`Angular > jsx > Javascript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -7463,7 +7546,12 @@ export default class RenderContent { `; exports[`Angular > jsx > Javascript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -7493,7 +7581,12 @@ export class MyComponentModule {} `; exports[`Angular > jsx > Javascript Test > customSelector 2`] = ` -"import { Component } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { Component } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ @@ -8442,6 +8535,95 @@ export default class MyComponent { " `; +exports[`Angular > jsx > Javascript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon; + @Input() interactiveState; + @Input() width; + @Input() size; + @Input() label; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + +exports[`Angular > jsx > Javascript Test > figmaMeta 2`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { Component, Input } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], + standalone: true, + imports: [CommonModule], +}) +export default class FigmaButton { + @Input() icon; + @Input() interactiveState; + @Input() width; + @Input() size; + @Input() label; +} +" +`; + exports[`Angular > jsx > Javascript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -8979,7 +9161,12 @@ export default class MyBasicComponent { `; exports[`Angular > jsx > Javascript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; @@ -9016,7 +9203,12 @@ export class MyComponentModule {} `; exports[`Angular > jsx > Javascript Test > nativeAttributes 2`] = ` -"import { Component, Input } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { Component, Input } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ @@ -14632,7 +14824,12 @@ export default class MyBasicOutputsComponent { `; exports[`Angular > jsx > Typescript Test > Basic Outputs Meta 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; @@ -14676,7 +14873,12 @@ export class MyBasicOutputsComponentModule {} `; exports[`Angular > jsx > Typescript Test > Basic Outputs Meta 2`] = ` -"import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside component\\"} + */ + +import { Output, EventEmitter, Component, Input } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ @@ -21185,7 +21387,12 @@ export default class MyBasicForwardRefComponent { `; exports[`Angular > jsx > Typescript Test > basicForwardRefMetadata 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -21231,7 +21438,12 @@ export class MyBasicForwardRefComponentModule {} `; exports[`Angular > jsx > Typescript Test > basicForwardRefMetadata 2`] = ` -"import { Component } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + +import { Component } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; export interface Props { @@ -21715,6 +21927,69 @@ export default class MyBasicComponent { " `; +exports[`Angular > jsx > Typescript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component } from \\"@angular/core\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class ComplexMetaRaw {} + +@NgModule({ + declarations: [ComplexMetaRaw], + imports: [CommonModule], + exports: [ComplexMetaRaw], +}) +export class ComplexMetaRawModule {} +" +`; + +exports[`Angular > jsx > Typescript Test > complexMeta 2`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + +import { Component } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +@Component({ + selector: \\"complex-meta-raw\\", + template: \` +
+ \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], + standalone: true, + imports: [CommonModule], +}) +export default class ComplexMetaRaw {} +" +`; + exports[`Angular > jsx > Typescript Test > componentWithContext 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -21937,7 +22212,12 @@ export default class RenderContent { `; exports[`Angular > jsx > Typescript Test > customSelector 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -21967,7 +22247,12 @@ export class MyComponentModule {} `; exports[`Angular > jsx > Typescript Test > customSelector 2`] = ` -"import { Component } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"selector\\":\\"not-my-component\\"}} + */ + +import { Component } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ @@ -22966,6 +23251,95 @@ export default class MyComponent { " `; +exports[`Angular > jsx > Typescript Test > figmaMeta 1`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { NgModule } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +import { Component, Input } from \\"@angular/core\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], +}) +export default class FigmaButton { + @Input() icon!: any; + @Input() interactiveState!: any; + @Input() width!: any; + @Input() size!: any; + @Input() label!: any; +} + +@NgModule({ + declarations: [FigmaButton], + imports: [CommonModule], + exports: [FigmaButton], +}) +export class FigmaButtonModule {} +" +`; + +exports[`Angular > jsx > Typescript Test > figmaMeta 2`] = ` +"/** + useMetadata: + {\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive State\\",\\"value\\":{\\"(Def) Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} + */ + +import { Component, Input } from \\"@angular/core\\"; +import { CommonModule } from \\"@angular/common\\"; + +@Component({ + selector: \\"figma-button\\", + template: \` + + \`, + styles: [ + \` + :host { + display: contents; + } + \`, + ], + standalone: true, + imports: [CommonModule], +}) +export default class FigmaButton { + @Input() icon!: any; + @Input() interactiveState!: any; + @Input() width!: any; + @Input() size!: any; + @Input() label!: any; +} +" +`; + exports[`Angular > jsx > Typescript Test > getterState 1`] = ` "import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @@ -23537,7 +23911,12 @@ export default class MyBasicComponent { `; exports[`Angular > jsx > Typescript Test > nativeAttributes 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component, Input } from \\"@angular/core\\"; @@ -23574,7 +23953,12 @@ export class MyComponentModule {} `; exports[`Angular > jsx > Typescript Test > nativeAttributes 2`] = ` -"import { Component, Input } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeAttributes\\":[\\"disabled\\"]}} + */ + +import { Component, Input } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ diff --git a/packages/core/src/__tests__/__snapshots__/html.test.ts.snap b/packages/core/src/__tests__/__snapshots__/html.test.ts.snap index 0f0e3aee95..f587064940 100644 --- a/packages/core/src/__tests__/__snapshots__/html.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/html.test.ts.snap @@ -825,7 +825,10 @@ exports[`Html > jsx > Javascript Test > Basic Outputs 1`] = ` `; exports[`Html > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"
+"/** useMetadata: {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside +component\\"} */ + +
+" +`; + exports[`Html > jsx > Javascript Test > getterState 1`] = ` "

@@ -8538,7 +8629,10 @@ exports[`Html > jsx > Typescript Test > Basic Outputs 1`] = ` `; exports[`Html > jsx > Typescript Test > Basic Outputs Meta 1`] = ` -"

+"/** useMetadata: {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside +component\\"} */ + +
+" +`; + exports[`Html > jsx > Typescript Test > getterState 1`] = ` "

diff --git a/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap b/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap index b8259e55be..358fabef23 100644 --- a/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap +++ b/packages/core/src/__tests__/__snapshots__/liquid.test.ts.snap @@ -55,7 +55,10 @@ exports[`Liquid > jsx > Javascript Test > Basic Outputs 1`] = ` `; exports[`Liquid > jsx > Javascript Test > Basic Outputs Meta 1`] = ` -"

+"/** useMetadata: {\\"outputs\\":[\\"onMessage\\",\\"onEvent\\"],\\"baz\\":\\"metadata inside +component\\"} */ + +
" `; @@ -464,7 +467,9 @@ exports[`Liquid > jsx > Javascript Test > basicForwardRef 1`] = ` `; exports[`Liquid > jsx > Javascript Test > basicForwardRefMetadata 1`] = ` -"
+"/** useMetadata: {\\"forwardRef\\":\\"inputRef\\"} */ + +
" + + + + + + + + export let inputRef; + + + + + + + + + let name = 'PatrickJS'; + + + + + + + + + + + +
+ + " `; exports[`Svelte > jsx > Javascript Test > basicOnUpdateReturn 1`] = ` @@ -1740,6 +1796,47 @@ exports[`Svelte > jsx > Javascript Test > classState 1`] = ` " `; +exports[`Svelte > jsx > Javascript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + + + +
" +`; + exports[`Svelte > jsx > Javascript Test > componentWithContext 1`] = ` " + +" +`; + exports[`Svelte > jsx > Javascript Test > getterState 1`] = ` " -
" +
" `; exports[`Svelte > jsx > Typescript Test > BasicAttribute 1`] = ` @@ -5038,26 +5205,60 @@ exports[`Svelte > jsx > Typescript Test > basicForwardRef 1`] = ` `; exports[`Svelte > jsx > Typescript Test > basicForwardRefMetadata 1`] = ` -" +"/** + useMetadata: + {\\"forwardRef\\":\\"inputRef\\"} + */ + + + - let name = \\"PatrickJS\\"; - + + + +
+ + " `; exports[`Svelte > jsx > Typescript Test > basicOnUpdateReturn 1`] = ` @@ -5184,6 +5385,47 @@ exports[`Svelte > jsx > Typescript Test > classState 1`] = ` " `; +exports[`Svelte > jsx > Typescript Test > complexMeta 1`] = ` +"/** + useMetadata: + {\\"x\\":\\"y\\",\\"asdf\\":{\\"stringValue\\":\\"d\\",\\"booleanValue\\":true,\\"numberValue\\":1,\\"innerObject\\":{\\"stringValue\\":\\"inner\\",\\"numberValue\\":2,\\"booleanValue\\":false}}} + */ + + + +
" +`; + exports[`Svelte > jsx > Typescript Test > componentWithContext 1`] = ` " + +" +`; + exports[`Svelte > jsx > Typescript Test > getterState 1`] = ` "" `; +exports[`Vue > jsx > Javascript Test > figmaMeta 1`] = ` +"/** useMetadata: +{\\"figma\\":{\\"name\\":\\"def-button-beta-outlined\\",\\"url\\":\\"https://www.figma.com/xxx\\",\\"props\\":{\\"iconSmall\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 +Icon Small\\"},\\"iconMedium\\":{\\"type\\":\\"instance\\",\\"key\\":\\"📍 Icon +Medium\\"},\\"label\\":{\\"type\\":\\"string\\",\\"key\\":\\"✏️ +Label\\"},\\"icon\\":{\\"type\\":\\"boolean\\",\\"key\\":\\"👁️ +Icon\\",\\"value\\":{\\"false\\":false,\\"true\\":\\"placeholder\\"}},\\"interactiveState\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Interactive +State\\",\\"value\\":{\\"(Def) +Enabled\\":false,\\"Hovered\\":false,\\"Pressed\\":false,\\"Focused\\":false,\\"Disabled\\":\\"true\\"}},\\"size\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Size\\",\\"value\\":{\\"(Def) +Medium\\":false,\\"Small\\":\\"small\\"}},\\"width\\":{\\"type\\":\\"enum\\",\\"key\\":\\"Width\\",\\"value\\":{\\"(Def) +Auto Width\\":false,\\"Full Width\\":\\"full\\"}}}}} */ + + + +" +`; + exports[`Vue > jsx > Javascript Test > getterState 1`] = ` "