Skip to content

Commit

Permalink
Merge pull request #291 from markuczy/feat/webcomponents-props
Browse files Browse the repository at this point in the history
feat: props passing to webcomponents
  • Loading branch information
markuczy authored Jun 26, 2024
2 parents d622db9 + 488a65c commit 7fde13f
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/angular-remote-components/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './lib/model/remote-component'
export * from './lib/model/remote-webcomponent'
export * from './lib/model/remote-component-config.model'
export * from './lib/model/injection-tokens'
export * from './lib/components/slot/slot.component'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { BehaviorSubject, Subscription, Observable, combineLatest } from 'rxjs'
import { RemoteComponentInfo, SLOT_SERVICE, SlotComponentConfiguration, SlotService } from '../../services/slot.service'
import { ocxRemoteComponent } from '../../model/remote-component'
import { Technologies } from '@onecx/integration-interface'
import { RemoteComponentConfig } from '../../model/remote-component-config.model'

@Component({
selector: 'ocx-slot[name]',
Expand Down Expand Up @@ -84,6 +85,12 @@ export class SlotComponent implements OnInit, OnDestroy {
) {
if (componentInfo.remoteComponent.elementName) {
const element = document.createElement(componentInfo.remoteComponent.elementName)
;(element as any)['ocxRemoteComponentConfig'] = {
appId: componentInfo.remoteComponent.appId,
productName: componentInfo.remoteComponent.productName,
baseUrl: componentInfo.remoteComponent.baseUrl,
permissions: permissions,
} satisfies RemoteComponentConfig
viewContainer?.element.nativeElement.appendChild(element)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RemoteComponentConfig } from './remote-component-config.model'

export interface ocxRemoteWebcomponent {
ocxRemoteComponentConfig: RemoteComponentConfig
}
46 changes: 46 additions & 0 deletions libs/angular-webcomponents/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "ocx",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "ocx",
"style": "kebab-case"
}
],
"no-restricted-syntax": [
"off",
{
"selector": "CallExpression[callee.object.name=\"console\"][callee.property.name=/^(debug|info|time|timeEnd|trace)$/]"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
7 changes: 7 additions & 0 deletions libs/angular-webcomponents/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# angular-webcomponents

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test angular-webcomponents` to execute the unit tests.
22 changes: 22 additions & 0 deletions libs/angular-webcomponents/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'angular-webcomponents',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/libs/angular-webcomponents',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
}
7 changes: 7 additions & 0 deletions libs/angular-webcomponents/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/libs/angular-webcomponents",
"lib": {
"entryFile": "src/index.ts"
}
}
10 changes: 10 additions & 0 deletions libs/angular-webcomponents/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@onecx/angular-webcomponents",
"version": "4.33.0",
"peerDependencies": {
},
"dependencies": {},
"publishConfig": {
"access": "public"
}
}
55 changes: 55 additions & 0 deletions libs/angular-webcomponents/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "angular-webcomponents",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/angular-webcomponents/src",
"prefix": "onecx",
"tags": [],
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/angular:package",
"outputs": [
"{workspaceRoot}/dist/{projectRoot}"
],
"options": {
"project": "libs/angular-webcomponents/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "libs/angular-webcomponents/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "libs/angular-webcomponents/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/angular-webcomponents/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/angular-webcomponents/**/*.ts", "libs/angular-webcomponents/**/*.html"]
}
},
"release": {
"executor": "nx-release:build-update-publish",
"options": {
"libName": "angular-webcomponents"
}
}
}
}
1 change: 1 addition & 0 deletions libs/angular-webcomponents/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/utils/webcomponent-router-initializer.utils'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function initializeRouter() {
console.log('tmp')
}
8 changes: 8 additions & 0 deletions libs/angular-webcomponents/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
}
import 'jest-preset-angular/setup-jest'
31 changes: 31 additions & 0 deletions libs/angular-webcomponents/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es2022",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.lib.prod.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json",
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
14 changes: 14 additions & 0 deletions libs/angular-webcomponents/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"target": "es2022",
"useDefineForClassFields": false
},
"exclude": ["**/*.spec.ts", "src/test-setup.ts", "jest.config.ts", "**/*.test.ts", "**/*.stories.ts", "jest.config.ts"],
"include": ["**/*.ts"]
}
13 changes: 13 additions & 0 deletions libs/angular-webcomponents/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false,
"target": "es2022",
"useDefineForClassFields": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
},
"exclude": ["jest.config.ts"]
}

11 changes: 11 additions & 0 deletions libs/angular-webcomponents/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
}
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@onecx/angular-remote-components": ["libs/angular-remote-components/src/index.ts"],
"@onecx/angular-standalone-shell": ["libs/angular-standalone-shell/src/index.ts"],
"@onecx/angular-testing": ["libs/angular-testing/src/index.ts"],
"@onecx/angular-webcomponents": ["libs/angular-webcomponents/src/index.ts"],
"@onecx/integration-interface": ["libs/integration-interface/src/index.ts"],
"@onecx/keycloak-auth": ["libs/keycloak-auth/src/index.ts"],
"@onecx/portal-integration-angular": ["libs/portal-integration-angular/src/index.ts"],
Expand Down

0 comments on commit 7fde13f

Please sign in to comment.