From 597538787133729691a0e72627b62cf11a5b4266 Mon Sep 17 00:00:00 2001 From: "( Nechiforel David-Samuel ) NsdHSO" Date: Mon, 30 Oct 2023 17:36:43 +0200 Subject: [PATCH] =?UTF-8?q?chore:=F0=9F=8C=BB=20extract=20demo=20component?= =?UTF-8?q?=20into=20a=20separate=20library?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ftx-demo/.eslintrc.json | 36 ++++++++++ ftx-demo/README.md | 7 ++ ftx-demo/jest.config.ts | 22 ++++++ ftx-demo/ng-package.json | 7 ++ ftx-demo/package.json | 12 ++++ ftx-demo/project.json | 47 +++++++++++++ ftx-demo/src/index.ts | 1 + .../infoUser/info-user.component.html | 0 .../infoUser/info-user.component.scss | 0 .../infoUser/info-user.component.spec.ts | 0 .../infoUser/info-user.component.stories.ts | 0 .../infoUser/info-user.component.ts | 0 .../contentSteps/intro/intro.component.html | 0 .../contentSteps/intro/intro.component.scss | 0 .../intro/intro.component.spec.ts | 0 .../intro/intro.component.stories.ts | 0 .../contentSteps/intro/intro.component.ts | 0 .../reserveBook/reserve-book.component.html | 0 .../reserveBook/reserve-book.component.scss | 0 .../reserve-book.component.spec.ts | 0 .../reserve-book.component.stories.ts | 0 .../reserveBook/reserve-book.component.ts | 0 .../spendMoney/spend-money.component.html | 0 .../spendMoney/spend-money.component.scss | 0 .../spendMoney/spend-money.component.spec.ts | 0 .../spend-money.component.stories.ts | 0 .../spendMoney/spend-money.component.ts | 0 .../services/stepper.service.spec.ts | 0 .../components/services/stepper.service.ts | 0 .../stepper-steps.component.html | 0 .../stepper-steps.component.scss | 3 + .../stepper-steps.component.spec.ts | 0 .../stepper-steps.component.stories.ts | 0 .../stepper-steps/stepper-steps.component.ts | 0 .../components/stepper/stepper.component.html | 0 .../components/stepper/stepper.component.scss | 0 .../stepper/stepper.component.spec.ts | 0 .../stepper/stepper.component.stories.ts | 0 .../components/stepper/stepper.component.ts | 0 ftx-demo/src/lib/ftx-demo/demo-core.module.ts | 22 ++++++ ftx-demo/src/lib/ftx-demo/demo.module.ts | 8 +++ ftx-demo/src/lib/ftx-demo/demo.routing.ts | 69 +++++++++++++++++++ ftx-demo/src/test-setup.ts | 8 +++ ftx-demo/tsconfig.json | 29 ++++++++ ftx-demo/tsconfig.lib.json | 17 +++++ ftx-demo/tsconfig.lib.prod.json | 9 +++ ftx-demo/tsconfig.spec.json | 16 +++++ src/app/app.routes.ts | 64 ++--------------- .../stepper-steps.component.scss | 3 - src/app/loaders/demo-loader.module.ts | 7 ++ tsconfig.base.json | 1 + 51 files changed, 325 insertions(+), 63 deletions(-) create mode 100644 ftx-demo/.eslintrc.json create mode 100644 ftx-demo/README.md create mode 100644 ftx-demo/jest.config.ts create mode 100644 ftx-demo/ng-package.json create mode 100644 ftx-demo/package.json create mode 100644 ftx-demo/project.json create mode 100644 ftx-demo/src/index.ts rename {src/app => ftx-demo/src/lib}/components/contentSteps/infoUser/info-user.component.html (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/infoUser/info-user.component.scss (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/infoUser/info-user.component.spec.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/infoUser/info-user.component.stories.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/infoUser/info-user.component.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/intro/intro.component.html (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/intro/intro.component.scss (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/intro/intro.component.spec.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/intro/intro.component.stories.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/intro/intro.component.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/reserveBook/reserve-book.component.html (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/reserveBook/reserve-book.component.scss (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/reserveBook/reserve-book.component.spec.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/reserveBook/reserve-book.component.stories.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/reserveBook/reserve-book.component.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/spendMoney/spend-money.component.html (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/spendMoney/spend-money.component.scss (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/spendMoney/spend-money.component.spec.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/spendMoney/spend-money.component.stories.ts (100%) rename {src/app => ftx-demo/src/lib}/components/contentSteps/spendMoney/spend-money.component.ts (100%) rename {src/app => ftx-demo/src/lib}/components/services/stepper.service.spec.ts (100%) rename {src/app => ftx-demo/src/lib}/components/services/stepper.service.ts (100%) rename {src/app => ftx-demo/src/lib}/components/stepper-steps/stepper-steps.component.html (100%) create mode 100644 ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.scss rename {src/app => ftx-demo/src/lib}/components/stepper-steps/stepper-steps.component.spec.ts (100%) rename {src/app => ftx-demo/src/lib}/components/stepper-steps/stepper-steps.component.stories.ts (100%) rename {src/app => ftx-demo/src/lib}/components/stepper-steps/stepper-steps.component.ts (100%) rename {src/app => ftx-demo/src/lib}/components/stepper/stepper.component.html (100%) rename {src/app => ftx-demo/src/lib}/components/stepper/stepper.component.scss (100%) rename {src/app => ftx-demo/src/lib}/components/stepper/stepper.component.spec.ts (100%) rename {src/app => ftx-demo/src/lib}/components/stepper/stepper.component.stories.ts (100%) rename {src/app => ftx-demo/src/lib}/components/stepper/stepper.component.ts (100%) create mode 100644 ftx-demo/src/lib/ftx-demo/demo-core.module.ts create mode 100644 ftx-demo/src/lib/ftx-demo/demo.module.ts create mode 100644 ftx-demo/src/lib/ftx-demo/demo.routing.ts create mode 100644 ftx-demo/src/test-setup.ts create mode 100644 ftx-demo/tsconfig.json create mode 100644 ftx-demo/tsconfig.lib.json create mode 100644 ftx-demo/tsconfig.lib.prod.json create mode 100644 ftx-demo/tsconfig.spec.json delete mode 100644 src/app/components/stepper-steps/stepper-steps.component.scss create mode 100644 src/app/loaders/demo-loader.module.ts diff --git a/ftx-demo/.eslintrc.json b/ftx-demo/.eslintrc.json new file mode 100644 index 0000000..676217b --- /dev/null +++ b/ftx-demo/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../.eslintrc.base.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "coagulu", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "coagulu", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/ftx-demo/README.md b/ftx-demo/README.md new file mode 100644 index 0000000..562568d --- /dev/null +++ b/ftx-demo/README.md @@ -0,0 +1,7 @@ +# ftx-demo + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test ftx-demo` to execute the unit tests. diff --git a/ftx-demo/jest.config.ts b/ftx-demo/jest.config.ts new file mode 100644 index 0000000..55b48af --- /dev/null +++ b/ftx-demo/jest.config.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ +export default { + displayName: 'ftx-demo', + preset: '../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: '../coverage/ftx-demo', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/ftx-demo/ng-package.json b/ftx-demo/ng-package.json new file mode 100644 index 0000000..824c3a3 --- /dev/null +++ b/ftx-demo/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../dist/ftx-demo", + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/ftx-demo/package.json b/ftx-demo/package.json new file mode 100644 index 0000000..0d20fad --- /dev/null +++ b/ftx-demo/package.json @@ -0,0 +1,12 @@ +{ + "name": "ngx-demo", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^16.1.0", + "@angular/core": "^16.1.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "sideEffects": false +} diff --git a/ftx-demo/project.json b/ftx-demo/project.json new file mode 100644 index 0000000..d95ef3c --- /dev/null +++ b/ftx-demo/project.json @@ -0,0 +1,47 @@ +{ + "name": "ftx-demo", + "$schema": "../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "ftx-demo/src", + "prefix": "coagulu", + "tags": [], + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/angular:package", + "outputs": ["{workspaceRoot}/dist/{projectRoot}"], + "options": { + "project": "ftx-demo/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "ftx-demo/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "ftx-demo/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "ftx-demo/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["ftx-demo/**/*.ts", "ftx-demo/**/*.html"] + } + } + } +} diff --git a/ftx-demo/src/index.ts b/ftx-demo/src/index.ts new file mode 100644 index 0000000..cfc79d6 --- /dev/null +++ b/ftx-demo/src/index.ts @@ -0,0 +1 @@ +export * from './lib/ftx-demo/demo-core.module'; diff --git a/src/app/components/contentSteps/infoUser/info-user.component.html b/ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.html similarity index 100% rename from src/app/components/contentSteps/infoUser/info-user.component.html rename to ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.html diff --git a/src/app/components/contentSteps/infoUser/info-user.component.scss b/ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.scss similarity index 100% rename from src/app/components/contentSteps/infoUser/info-user.component.scss rename to ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.scss diff --git a/src/app/components/contentSteps/infoUser/info-user.component.spec.ts b/ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.spec.ts similarity index 100% rename from src/app/components/contentSteps/infoUser/info-user.component.spec.ts rename to ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.spec.ts diff --git a/src/app/components/contentSteps/infoUser/info-user.component.stories.ts b/ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.stories.ts similarity index 100% rename from src/app/components/contentSteps/infoUser/info-user.component.stories.ts rename to ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.stories.ts diff --git a/src/app/components/contentSteps/infoUser/info-user.component.ts b/ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.ts similarity index 100% rename from src/app/components/contentSteps/infoUser/info-user.component.ts rename to ftx-demo/src/lib/components/contentSteps/infoUser/info-user.component.ts diff --git a/src/app/components/contentSteps/intro/intro.component.html b/ftx-demo/src/lib/components/contentSteps/intro/intro.component.html similarity index 100% rename from src/app/components/contentSteps/intro/intro.component.html rename to ftx-demo/src/lib/components/contentSteps/intro/intro.component.html diff --git a/src/app/components/contentSteps/intro/intro.component.scss b/ftx-demo/src/lib/components/contentSteps/intro/intro.component.scss similarity index 100% rename from src/app/components/contentSteps/intro/intro.component.scss rename to ftx-demo/src/lib/components/contentSteps/intro/intro.component.scss diff --git a/src/app/components/contentSteps/intro/intro.component.spec.ts b/ftx-demo/src/lib/components/contentSteps/intro/intro.component.spec.ts similarity index 100% rename from src/app/components/contentSteps/intro/intro.component.spec.ts rename to ftx-demo/src/lib/components/contentSteps/intro/intro.component.spec.ts diff --git a/src/app/components/contentSteps/intro/intro.component.stories.ts b/ftx-demo/src/lib/components/contentSteps/intro/intro.component.stories.ts similarity index 100% rename from src/app/components/contentSteps/intro/intro.component.stories.ts rename to ftx-demo/src/lib/components/contentSteps/intro/intro.component.stories.ts diff --git a/src/app/components/contentSteps/intro/intro.component.ts b/ftx-demo/src/lib/components/contentSteps/intro/intro.component.ts similarity index 100% rename from src/app/components/contentSteps/intro/intro.component.ts rename to ftx-demo/src/lib/components/contentSteps/intro/intro.component.ts diff --git a/src/app/components/contentSteps/reserveBook/reserve-book.component.html b/ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.html similarity index 100% rename from src/app/components/contentSteps/reserveBook/reserve-book.component.html rename to ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.html diff --git a/src/app/components/contentSteps/reserveBook/reserve-book.component.scss b/ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.scss similarity index 100% rename from src/app/components/contentSteps/reserveBook/reserve-book.component.scss rename to ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.scss diff --git a/src/app/components/contentSteps/reserveBook/reserve-book.component.spec.ts b/ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.spec.ts similarity index 100% rename from src/app/components/contentSteps/reserveBook/reserve-book.component.spec.ts rename to ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.spec.ts diff --git a/src/app/components/contentSteps/reserveBook/reserve-book.component.stories.ts b/ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.stories.ts similarity index 100% rename from src/app/components/contentSteps/reserveBook/reserve-book.component.stories.ts rename to ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.stories.ts diff --git a/src/app/components/contentSteps/reserveBook/reserve-book.component.ts b/ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.ts similarity index 100% rename from src/app/components/contentSteps/reserveBook/reserve-book.component.ts rename to ftx-demo/src/lib/components/contentSteps/reserveBook/reserve-book.component.ts diff --git a/src/app/components/contentSteps/spendMoney/spend-money.component.html b/ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.html similarity index 100% rename from src/app/components/contentSteps/spendMoney/spend-money.component.html rename to ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.html diff --git a/src/app/components/contentSteps/spendMoney/spend-money.component.scss b/ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.scss similarity index 100% rename from src/app/components/contentSteps/spendMoney/spend-money.component.scss rename to ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.scss diff --git a/src/app/components/contentSteps/spendMoney/spend-money.component.spec.ts b/ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.spec.ts similarity index 100% rename from src/app/components/contentSteps/spendMoney/spend-money.component.spec.ts rename to ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.spec.ts diff --git a/src/app/components/contentSteps/spendMoney/spend-money.component.stories.ts b/ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.stories.ts similarity index 100% rename from src/app/components/contentSteps/spendMoney/spend-money.component.stories.ts rename to ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.stories.ts diff --git a/src/app/components/contentSteps/spendMoney/spend-money.component.ts b/ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.ts similarity index 100% rename from src/app/components/contentSteps/spendMoney/spend-money.component.ts rename to ftx-demo/src/lib/components/contentSteps/spendMoney/spend-money.component.ts diff --git a/src/app/components/services/stepper.service.spec.ts b/ftx-demo/src/lib/components/services/stepper.service.spec.ts similarity index 100% rename from src/app/components/services/stepper.service.spec.ts rename to ftx-demo/src/lib/components/services/stepper.service.spec.ts diff --git a/src/app/components/services/stepper.service.ts b/ftx-demo/src/lib/components/services/stepper.service.ts similarity index 100% rename from src/app/components/services/stepper.service.ts rename to ftx-demo/src/lib/components/services/stepper.service.ts diff --git a/src/app/components/stepper-steps/stepper-steps.component.html b/ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.html similarity index 100% rename from src/app/components/stepper-steps/stepper-steps.component.html rename to ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.html diff --git a/ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.scss b/ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.scss new file mode 100644 index 0000000..d249b65 --- /dev/null +++ b/ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.scss @@ -0,0 +1,3 @@ +:host { + @apply w-full; +} diff --git a/src/app/components/stepper-steps/stepper-steps.component.spec.ts b/ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.spec.ts similarity index 100% rename from src/app/components/stepper-steps/stepper-steps.component.spec.ts rename to ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.spec.ts diff --git a/src/app/components/stepper-steps/stepper-steps.component.stories.ts b/ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.stories.ts similarity index 100% rename from src/app/components/stepper-steps/stepper-steps.component.stories.ts rename to ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.stories.ts diff --git a/src/app/components/stepper-steps/stepper-steps.component.ts b/ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.ts similarity index 100% rename from src/app/components/stepper-steps/stepper-steps.component.ts rename to ftx-demo/src/lib/components/stepper-steps/stepper-steps.component.ts diff --git a/src/app/components/stepper/stepper.component.html b/ftx-demo/src/lib/components/stepper/stepper.component.html similarity index 100% rename from src/app/components/stepper/stepper.component.html rename to ftx-demo/src/lib/components/stepper/stepper.component.html diff --git a/src/app/components/stepper/stepper.component.scss b/ftx-demo/src/lib/components/stepper/stepper.component.scss similarity index 100% rename from src/app/components/stepper/stepper.component.scss rename to ftx-demo/src/lib/components/stepper/stepper.component.scss diff --git a/src/app/components/stepper/stepper.component.spec.ts b/ftx-demo/src/lib/components/stepper/stepper.component.spec.ts similarity index 100% rename from src/app/components/stepper/stepper.component.spec.ts rename to ftx-demo/src/lib/components/stepper/stepper.component.spec.ts diff --git a/src/app/components/stepper/stepper.component.stories.ts b/ftx-demo/src/lib/components/stepper/stepper.component.stories.ts similarity index 100% rename from src/app/components/stepper/stepper.component.stories.ts rename to ftx-demo/src/lib/components/stepper/stepper.component.stories.ts diff --git a/src/app/components/stepper/stepper.component.ts b/ftx-demo/src/lib/components/stepper/stepper.component.ts similarity index 100% rename from src/app/components/stepper/stepper.component.ts rename to ftx-demo/src/lib/components/stepper/stepper.component.ts diff --git a/ftx-demo/src/lib/ftx-demo/demo-core.module.ts b/ftx-demo/src/lib/ftx-demo/demo-core.module.ts new file mode 100644 index 0000000..f7ff9bc --- /dev/null +++ b/ftx-demo/src/lib/ftx-demo/demo-core.module.ts @@ -0,0 +1,22 @@ +import { + ModuleWithProviders, + NgModule, + Optional, + SkipSelf, +} from '@angular/core'; +import { DemoModule } from './demo.module'; + +@NgModule({}) +export class DemoCoreModule { + constructor(@Optional() @SkipSelf() parentModule: DemoModule) { + if (parentModule) { + throw new Error(`Demo module Is already loaded`); + } + } + + static forRoot(): ModuleWithProviders { + return { + ngModule: DemoModule, + }; + } +} diff --git a/ftx-demo/src/lib/ftx-demo/demo.module.ts b/ftx-demo/src/lib/ftx-demo/demo.module.ts new file mode 100644 index 0000000..559161f --- /dev/null +++ b/ftx-demo/src/lib/ftx-demo/demo.module.ts @@ -0,0 +1,8 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { demoRouting } from './demo.routing'; + +@NgModule({ + imports: [RouterModule.forChild(demoRouting)], +}) +export class DemoModule {} diff --git a/ftx-demo/src/lib/ftx-demo/demo.routing.ts b/ftx-demo/src/lib/ftx-demo/demo.routing.ts new file mode 100644 index 0000000..f6e3a9d --- /dev/null +++ b/ftx-demo/src/lib/ftx-demo/demo.routing.ts @@ -0,0 +1,69 @@ +import { NavigationEnd, Route, Router } from '@angular/router'; +import { inject } from '@angular/core'; +import { catchError, filter, map, of, tap } from 'rxjs'; +import { StepperService } from '../components/services/stepper.service'; + +export const demoRouting: Route[] = [ + { + path: '', + loadComponent: () => + import('./../components/stepper/stepper.component').then( + (c) => c.StepperComponent + ), + resolve: [ + () => { + const stepperService = inject(StepperService); + const router = inject(Router); + router.events + .pipe( + filter((event: any) => event instanceof NavigationEnd), //eslint-disable-line + map((v: NavigationEnd) => v.url.split('/')[1]), + tap((url) => stepperService.flagUrl$.next(url)), + catchError((err) => { + console.warn(err); + return of(false); + }) + ) + .subscribe(); + }, + ], + children: [ + { + path: 'intro', + loadComponent: () => + import('./../components/contentSteps/intro/intro.component').then( + (c) => c.IntroComponent + ), + }, + { + path: 'infoUser', + loadComponent: () => + import( + './../components/contentSteps/infoUser/info-user.component' + ).then((c) => c.InfoUserComponent), + }, + { + path: 'spendMoney', + loadComponent: () => + import( + './../components/contentSteps/spendMoney/spend-money.component' + ).then((c) => c.SpendMoneyComponent), + }, + { + path: 'reserveBook', + loadComponent: () => + import( + './../components/contentSteps/reserveBook/reserve-book.component' + ).then((c) => c.ReserveBookComponent), + }, + { + path: '**', + redirectTo: 'spendMoney', + }, + ], + }, + { + path: '**', + redirectTo: '', + }, +]; diff --git a/ftx-demo/src/test-setup.ts b/ftx-demo/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/ftx-demo/src/test-setup.ts @@ -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'; diff --git a/ftx-demo/tsconfig.json b/ftx-demo/tsconfig.json new file mode 100644 index 0000000..292b8f8 --- /dev/null +++ b/ftx-demo/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "extends": "../tsconfig.base.json", + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/ftx-demo/tsconfig.lib.json b/ftx-demo/tsconfig.lib.json new file mode 100644 index 0000000..64216c9 --- /dev/null +++ b/ftx-demo/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../dist/out-tsc", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [] + }, + "exclude": [ + "src/**/*.spec.ts", + "src/test-setup.ts", + "jest.config.ts", + "src/**/*.test.ts" + ], + "include": ["src/**/*.ts"] +} diff --git a/ftx-demo/tsconfig.lib.prod.json b/ftx-demo/tsconfig.lib.prod.json new file mode 100644 index 0000000..2a2faa8 --- /dev/null +++ b/ftx-demo/tsconfig.lib.prod.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} diff --git a/ftx-demo/tsconfig.spec.json b/ftx-demo/tsconfig.spec.json new file mode 100644 index 0000000..2894252 --- /dev/null +++ b/ftx-demo/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../dist/out-tsc", + "module": "commonjs", + "target": "es2016", + "types": ["jest", "node"] + }, + "files": ["src/test-setup.ts"], + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 8a99ca7..046378e 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,66 +1,10 @@ -import { NavigationEnd, Route, Router } from '@angular/router'; -import { inject } from '@angular/core'; -import { catchError, filter, map, of, tap } from 'rxjs'; -import { StepperService } from './components/services/stepper.service'; +import { Route } from '@angular/router'; export const appRoutes: Route[] = [ { - path: '', - loadComponent: () => - import('./components/stepper/stepper.component').then( - (c) => c.StepperComponent - ), - resolve: [ - () => { - const stepperService = inject(StepperService); - const router = inject(Router); - router.events - .pipe( - filter((event: any) => event instanceof NavigationEnd), //eslint-disable-line - map((v: NavigationEnd) => v.url.split('/')[1]), - tap((url) => stepperService.flagUrl$.next(url)), - catchError((err) => { - console.warn(err); - return of(false); - }) - ) - .subscribe(); - }, - ], - children: [ - { - path: 'intro', - loadComponent: () => - import('./components/contentSteps/intro/intro.component').then( - (c) => c.IntroComponent - ), - }, - { - path: 'infoUser', - loadComponent: () => - import('./components/contentSteps/infoUser/info-user.component').then( - (c) => c.InfoUserComponent - ), - }, - { - path: 'spendMoney', - loadComponent: () => - import( - './components/contentSteps/spendMoney/spend-money.component' - ).then((c) => c.SpendMoneyComponent), - }, - { - path: 'reserveBook', - loadComponent: () => - import( - './components/contentSteps/reserveBook/reserve-book.component' - ).then((c) => c.ReserveBookComponent), - }, - { - path: '**', - redirectTo: 'spendMoney', - }, - ], + path: 'demo', + loadChildren: () => + import('./loaders/demo-loader.module').then((m) => m.DemoLoaderModule), }, { path: '**', diff --git a/src/app/components/stepper-steps/stepper-steps.component.scss b/src/app/components/stepper-steps/stepper-steps.component.scss deleted file mode 100644 index 06d06f9..0000000 --- a/src/app/components/stepper-steps/stepper-steps.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -:host{ - @apply w-full -} \ No newline at end of file diff --git a/src/app/loaders/demo-loader.module.ts b/src/app/loaders/demo-loader.module.ts new file mode 100644 index 0000000..6887c71 --- /dev/null +++ b/src/app/loaders/demo-loader.module.ts @@ -0,0 +1,7 @@ +import { NgModule } from '@angular/core'; +import { DemoCoreModule } from 'ngx-demo'; + +@NgModule({ + imports: [DemoCoreModule.forRoot()], +}) +export class DemoLoaderModule {} diff --git a/tsconfig.base.json b/tsconfig.base.json index e1c2676..a418746 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -15,6 +15,7 @@ "skipDefaultLibCheck": true, "baseUrl": ".", "paths": { + "ngx-demo": ["ftx-demo/src/index.ts"], "ngx-ftm": ["ftx-ftm/src/index.ts"], "ngx-fts-tooltip": ["ftx-tooltip/src/index.ts"], "ngx-ftx-forms": ["ftx-forms/src/index.ts"],