From 3eb9e2dacc36c38bc4452c75a4311f75e47a4c9a Mon Sep 17 00:00:00 2001 From: Nicolas Merget Date: Thu, 11 Jul 2024 09:14:50 +0200 Subject: [PATCH 1/2] fix: issue with angular build missing package.json --- .github/workflows/01-build-stencil-targets.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/01-build-stencil-targets.yml b/.github/workflows/01-build-stencil-targets.yml index bffbcad98..893def202 100644 --- a/.github/workflows/01-build-stencil-targets.yml +++ b/.github/workflows/01-build-stencil-targets.yml @@ -32,6 +32,7 @@ jobs: run: | if echo ${{ matrix.targets }} | grep -c "ngx-elements" then + cat ./packages/db-ui-elements-angular/dist/lib/package.json echo "framework=angular" >> $GITHUB_OUTPUT elif echo ${{ matrix.targets }} | grep -c "react-elements" then From 82987712e5286912aeeff3f296da808ab7cf7e95 Mon Sep 17 00:00:00 2001 From: Nicolas Merget Date: Fri, 12 Jul 2024 14:13:09 +0200 Subject: [PATCH 2/2] feat: convert angular output to standalone --- .../projects/lib/src/config.testing.ts | 24 ---- .../projects/lib/src/db-ui-elements-module.ts | 102 ----------------- .../projects/lib/src/index.ts | 3 - .../projects/lib/src/jestGlobalMocks.ts | 40 ------- .../projects/lib/src/public_api.ts | 9 -- .../db-mainnavigation/db-mainnavigation.tsx | 65 ++++++++--- .../components/db-sidenavi/db-sidenavi.tsx | 4 +- .../src/components/db-table/db-table.tsx | 2 +- .../db-ui-elements-stencil/stencil.config.ts | 9 +- .../src/app/app.component.ts | 3 +- .../src/app/app.module.ts | 4 +- showcase/angular-lts-showcase/angular.json | 96 +++++++--------- .../src/app/app.component.html | 11 +- .../src/app/app.component.ts | 42 +++++-- .../src/app/app.module.ts | 35 ------ .../src/app/app.routing.module.ts | 25 ++--- .../app/components/form/form.component.html | 22 ++-- .../src/app/components/form/form.component.ts | 42 +++++-- .../navigation/navigation.component.html | 12 +- .../navigation/navigation.component.ts | 9 +- .../other-components.component.html | 40 +++---- .../other-components.component.ts | 21 +++- .../other-elements.component.ts | 13 ++- .../components/tab-bar/tab-bar.component.ts | 21 +++- .../app/components/tables/tables.component.ts | 12 +- showcase/angular-lts-showcase/src/main.ts | 20 ++-- .../angular-lts-showcase/tsconfig.app.json | 9 +- .../angular-lts-showcase/tsconfig.base.json | 17 --- showcase/angular-lts-showcase/tsconfig.json | 43 +++++--- .../angular-lts-showcase/tsconfig.spec.json | 12 -- showcase/angular-lts-showcase/tslint.json | 104 ------------------ 31 files changed, 332 insertions(+), 539 deletions(-) delete mode 100644 packages/db-ui-elements-angular/projects/lib/src/config.testing.ts delete mode 100644 packages/db-ui-elements-angular/projects/lib/src/db-ui-elements-module.ts delete mode 100644 packages/db-ui-elements-angular/projects/lib/src/jestGlobalMocks.ts delete mode 100644 packages/db-ui-elements-angular/projects/lib/src/public_api.ts delete mode 100644 showcase/angular-lts-showcase/src/app/app.module.ts delete mode 100644 showcase/angular-lts-showcase/tsconfig.base.json delete mode 100644 showcase/angular-lts-showcase/tsconfig.spec.json delete mode 100644 showcase/angular-lts-showcase/tslint.json diff --git a/packages/db-ui-elements-angular/projects/lib/src/config.testing.ts b/packages/db-ui-elements-angular/projects/lib/src/config.testing.ts deleted file mode 100644 index 5138c7719..000000000 --- a/packages/db-ui-elements-angular/projects/lib/src/config.testing.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -type CompilerOptions = Partial<{ - providers: any[]; - useJit: boolean; - preserveWhitespaces: boolean; -}>; -export type ConfigureFn = (testBed: typeof TestBed) => void; - -export const configureTests = ( - configure: ConfigureFn, - compilerOptions: CompilerOptions = {} -) => { - const compilerConfig: CompilerOptions = { - preserveWhitespaces: false, - ...compilerOptions - }; - - const configuredTestBed = TestBed.configureCompiler(compilerConfig); - - configure(configuredTestBed); - - return configuredTestBed.compileComponents().then(() => configuredTestBed); -}; diff --git a/packages/db-ui-elements-angular/projects/lib/src/db-ui-elements-module.ts b/packages/db-ui-elements-angular/projects/lib/src/db-ui-elements-module.ts deleted file mode 100644 index 841552b7a..000000000 --- a/packages/db-ui-elements-angular/projects/lib/src/db-ui-elements-module.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; -import { defineCustomElements } from '@db-ui/elements/loader'; - -import { BooleanValueAccessor } from './boolean-value-accessor'; -import { - DbBrand, - DbBreadcrumb, - DbButton, - DbChip, - DbCheckbox, - DbDropdown, - DbAccordion, - DbFooter, - DbHeader, - DbIcon, - DbImage, - DbInput, - DbLink, - DbLinklist, - DbLogo, - DbMeta, - DbMetanavigation, - DbOverflowMenu, - DbPage, - DbProgress, - DbRadio, - DbSelect, - DbSidenavi, - DbTabBar, - DbTable, - DbTag, - DbTextarea, - DbToggle, - DbPagination, - DbCards, - DbCard, - DbTab, - DbHeadline, - DbLanguageSwitcher, - DbMainnavigation, - DbNotification, - DbNotifications -} from './components'; -import { SelectValueAccessor } from './select-value-accessor'; -import { TextValueAccessor } from './text-value-accessor'; - -defineCustomElements(window); - -const DECLARATIONS = [ - // proxies - DbBrand, - DbBreadcrumb, - DbButton, - DbCard, - DbCards, - DbChip, - DbCheckbox, - DbDropdown, - DbAccordion, - DbFooter, - DbHeader, - DbHeadline, - DbIcon, - DbImage, - DbInput, - DbLanguageSwitcher, - DbLink, - DbLinklist, - DbLogo, - DbMainnavigation, - DbMeta, - DbMetanavigation, - DbNotification, - DbNotifications, - DbOverflowMenu, - DbPage, - DbPagination, - DbProgress, - DbRadio, - DbSelect, - DbSidenavi, - DbTab, - DbTabBar, - DbTable, - DbTag, - DbTextarea, - DbToggle, - - // Value Accessors - BooleanValueAccessor, - SelectValueAccessor, - TextValueAccessor -]; - -@NgModule({ - declarations: DECLARATIONS, - exports: DECLARATIONS, - imports: [], - providers: [], - schemas: [CUSTOM_ELEMENTS_SCHEMA] -}) -export class DBUIElementsModule {} diff --git a/packages/db-ui-elements-angular/projects/lib/src/index.ts b/packages/db-ui-elements-angular/projects/lib/src/index.ts index 85ce3d295..2db7acc71 100644 --- a/packages/db-ui-elements-angular/projects/lib/src/index.ts +++ b/packages/db-ui-elements-angular/projects/lib/src/index.ts @@ -10,6 +10,3 @@ export * from './text-value-accessor'; export * from './select-value-accessor'; export * from './value-accessor'; export * from './index'; - -// PACKAGE MODULE -export { DBUIElementsModule } from './db-ui-elements-module'; diff --git a/packages/db-ui-elements-angular/projects/lib/src/jestGlobalMocks.ts b/packages/db-ui-elements-angular/projects/lib/src/jestGlobalMocks.ts deleted file mode 100644 index 487896f63..000000000 --- a/packages/db-ui-elements-angular/projects/lib/src/jestGlobalMocks.ts +++ /dev/null @@ -1,40 +0,0 @@ -Object.defineProperty(window, 'CSS', { value: null }); -Object.defineProperty(document, 'doctype', { - value: '' -}); -Object.defineProperty(window, 'getComputedStyle', { - value: () => { - return { - display: 'none', - appearance: ['-webkit-appearance'] - }; - } -}); -/** - * ISSUE: https://github.com/angular/material2/issues/7101 - * Workaround for JSDOM missing transform property - */ -Object.defineProperty(document.body.style, 'transform', { - value: () => { - return { - enumerable: true, - configurable: true - }; - } -}); - -window.matchMedia = - window.matchMedia || - (function () { - return { - matches: false, - addListener() {}, - removeListener() {} - }; - } as any); - -(window as any).CSSStyleSheet = class { - constructor() { - throw Error(); - } -} as any; diff --git a/packages/db-ui-elements-angular/projects/lib/src/public_api.ts b/packages/db-ui-elements-angular/projects/lib/src/public_api.ts deleted file mode 100644 index 8dbcfd7c9..000000000 --- a/packages/db-ui-elements-angular/projects/lib/src/public_api.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Public API Surface of lib - */ - -export * from './boolean-value-accessor'; -export * from './text-value-accessor'; -export * from './select-value-accessor'; -export * from './value-accessor'; -export * from './index'; diff --git a/packages/db-ui-elements-stencil/src/components/db-mainnavigation/db-mainnavigation.tsx b/packages/db-ui-elements-stencil/src/components/db-mainnavigation/db-mainnavigation.tsx index 6aeb495a8..ec5630c8c 100644 --- a/packages/db-ui-elements-stencil/src/components/db-mainnavigation/db-mainnavigation.tsx +++ b/packages/db-ui-elements-stencil/src/components/db-mainnavigation/db-mainnavigation.tsx @@ -99,6 +99,33 @@ const addAreaPopupsRecursive = (children: Element[]) => { styleUrl: 'db-mainnavigation.scss' }) export class DbMainnavigation { + get onlyLinks(): DbMainnavigationItemType[] { + return this._onlyLinks; + } + + set onlyLinks(value: DbMainnavigationItemType[]) { + this._onlyLinks = value; + } + get hasItemsWrapper(): boolean { + return this._hasItemsWrapper; + } + + set hasItemsWrapper(value: boolean) { + this._hasItemsWrapper = value; + } + get compData(): DbMainnavigationDataType[] { + return this._compData; + } + + set compData(value: DbMainnavigationDataType[]) { + this._compData = value; + } + set children(value: Element[]) { + this._children = value; + } + get children(): Element[] { + return this._children; + } /** * The site-name attribute can be set to have the site name for small screens. */ @@ -109,24 +136,26 @@ export class DbMainnavigation { */ @Prop({ reflect: true }) data?: string; - private hasItemsWrapper: boolean; + private _hasItemsWrapper: boolean; - private compData: DbMainnavigationDataType[]; + private _compData: DbMainnavigationDataType[]; - private children: Element[]; - private onlyLinks: DbMainnavigationItemType[]; + private _children: Element[]; + private _onlyLinks: DbMainnavigationItemType[]; @Element() host: HTMLDbMainnavigationElement; componentWillLoad() { if (this.data) { - this.compData = parseData(this.data); - } else { - this.children = Array.from(this.host.children); - this.onlyLinks = setupOnlyDbLinkNavigation(this.children); - if (this.children.find((child) => child.tagName.toLowerCase() === 'li')) { - this.hasItemsWrapper = true; - addAreaPopupsRecursive(this.children); + this._compData = parseData(this.data); + } else if (this.host) { + this._children = Array.from(this.host.children); + this._onlyLinks = setupOnlyDbLinkNavigation(this._children); + if ( + this._children.find((child) => child.tagName.toLowerCase() === 'li') + ) { + this._hasItemsWrapper = true; + addAreaPopupsRecursive(this._children); } else { this.host.innerHTML = ''; } @@ -144,19 +173,19 @@ export class DbMainnavigation { > {this.siteName} - {this.compData &&