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 435fd037c3..09c985ebb8 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`] = ` "
@@ -1922,6 +1941,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`] = ` "

@@ -3319,7 +3367,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`] = ` "
@@ -4989,6 +5056,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 5587defbd3..9eae1c7824 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\\"; @@ -3574,7 +3579,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\\"; @@ -3852,6 +3862,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -3967,7 +4012,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\\"; @@ -4484,6 +4534,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\\"; @@ -4774,7 +4872,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\\"; @@ -5230,7 +5333,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -7821,7 +7929,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\\"; @@ -11271,7 +11384,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\\"; @@ -11561,6 +11679,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -11684,7 +11837,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\\"; @@ -12226,6 +12384,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\\"; @@ -12533,7 +12739,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\\"; @@ -13002,7 +13213,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } 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 0fa4c40421..e240c67e28 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\\"; @@ -3624,7 +3629,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\\"; @@ -3909,6 +3919,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -4027,7 +4073,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\\"; @@ -4552,6 +4603,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\\"; @@ -4848,7 +4948,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\\"; @@ -5315,7 +5420,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with Import Mapper Tests > jsx > Javascript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -7954,7 +8064,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\\"; @@ -11447,7 +11562,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\\"; @@ -11744,6 +11864,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -11870,7 +12026,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\\"; @@ -12420,6 +12581,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\\"; @@ -12735,7 +12945,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\\"; @@ -13215,7 +13430,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with Import Mapper Tests > jsx > Typescript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } 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 de23dc6e71..ca8e43d62e 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\\"; @@ -3712,7 +3717,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\\"; @@ -3988,6 +3998,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -4101,7 +4146,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\\"; @@ -4658,6 +4708,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\\"; @@ -4974,7 +5072,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\\"; @@ -5430,7 +5533,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Javascript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -8095,7 +8203,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\\"; @@ -11685,7 +11798,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\\"; @@ -11973,6 +12091,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -12094,7 +12247,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\\"; @@ -12677,6 +12835,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\\"; @@ -13010,7 +13216,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\\"; @@ -13479,7 +13690,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with manually creating and handling class properties as bindings (more stable) > jsx > Typescript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } 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 48f5cc8285..e11df639ef 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\\"; @@ -3256,7 +3261,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\\"; @@ -3503,6 +3513,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -3595,7 +3633,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\\"; @@ -4060,6 +4103,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\\"; @@ -4308,7 +4392,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\\"; @@ -4691,7 +4780,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Javascript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -6974,7 +7068,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\\"; @@ -10147,7 +10246,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\\"; @@ -10406,6 +10510,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -10506,7 +10638,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\\"; @@ -10996,6 +11133,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\\"; @@ -11261,7 +11439,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\\"; @@ -11657,7 +11840,12 @@ export class OnUpdateWithDepsModule {} `; exports[`Angular with visuallyIgnoreHostElement = false > jsx > Typescript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } 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 7c285bc01d..2f51bbbf88 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({ @@ -6793,7 +6803,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\\"; @@ -6834,7 +6849,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({ @@ -7299,6 +7319,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -7505,7 +7588,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\\"; @@ -7535,7 +7623,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({ @@ -8484,6 +8577,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\\"; @@ -9021,7 +9203,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\\"; @@ -9058,7 +9245,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({ @@ -9856,7 +10048,12 @@ export default class OnUpdateWithDeps { `; exports[`Angular > jsx > Javascript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -9898,7 +10095,12 @@ export class MyComponentModule {} `; exports[`Angular > jsx > Javascript Test > outputEventBinding 2`] = ` -"import { Component } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { Component } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; @Component({ @@ -14678,7 +14880,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\\"; @@ -14722,7 +14929,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({ @@ -21273,7 +21485,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\\"; @@ -21319,7 +21536,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 { @@ -21803,6 +22025,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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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},\\"spreadStringValue\\":\\"f\\"}} + */ + +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\\"; @@ -22025,7 +22310,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\\"; @@ -22055,7 +22345,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({ @@ -23054,6 +23349,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\\"; @@ -23625,7 +24009,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\\"; @@ -23662,7 +24051,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({ @@ -24486,7 +24880,12 @@ export default class OnUpdateWithDeps { `; exports[`Angular > jsx > Typescript Test > outputEventBinding 1`] = ` -"import { NgModule } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { NgModule } from \\"@angular/core\\"; import { CommonModule } from \\"@angular/common\\"; import { Component } from \\"@angular/core\\"; @@ -24528,7 +24927,12 @@ export class MyComponentModule {} `; exports[`Angular > jsx > Typescript Test > outputEventBinding 2`] = ` -"import { Component } from \\"@angular/core\\"; +"/** + useMetadata: + {\\"angular\\":{\\"nativeEvents\\":[\\"onFakeNative\\"]}} + */ + +import { Component } 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 754830f4af..8d57f9a86c 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`] = ` "

@@ -8579,7 +8670,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 4907f9241c..a34f841bd7 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\\"} */ + +
" `; @@ -466,7 +469,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`] = ` @@ -1753,6 +1809,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},\\"spreadStringValue\\":\\"f\\"}} + */ + + + +
" +`; + exports[`Svelte > jsx > Javascript Test > componentWithContext 1`] = ` " + +" +`; + exports[`Svelte > jsx > Javascript Test > getterState 1`] = ` " -
" +
" `; exports[`Svelte > jsx > Typescript Test > BasicAttribute 1`] = ` @@ -5061,26 +5228,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`] = ` @@ -5207,6 +5408,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},\\"spreadStringValue\\":\\"f\\"}} + */ + + + +
" +`; + 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`] = ` "