diff --git a/.github/workflows/ci_release.yml b/.github/workflows/ci_release.yml index 0183e7bc..9f500176 100644 --- a/.github/workflows/ci_release.yml +++ b/.github/workflows/ci_release.yml @@ -22,6 +22,7 @@ on: - time-picker - tooltip - user-card + - user-tooltip dry-run: description: --dry-run type: boolean diff --git a/.github/workflows/ci_test_core.yml b/.github/workflows/ci_test_core.yml index 29d31f45..fe1544fe 100644 --- a/.github/workflows/ci_test_core.yml +++ b/.github/workflows/ci_test_core.yml @@ -25,7 +25,7 @@ jobs: node-versions: '[18, 20]' # - # Not needed here because will be triggered by `ci_test_sidenav` + # Not needed here because it will be triggered by `ci_test_sidenav` # # ci_test_layout: # needs: ci_test_core @@ -52,14 +52,14 @@ jobs: uses: ./.github/workflows/ci_test_splitter.yml # - # Not needed here because will be triggered by `ci_test_snackbar` + # Not needed here because it will be triggered by `ci_test_snackbar` # # ci_test_status: # needs: ci_test_core # uses: ./.github/workflows/ci_test_status.yml # - # Not needed here because will be triggered by `ci_test_numeric-stepper` + # Not needed here because it will be triggered by `ci_test_numeric-stepper` # # ci_test_time-picker: # needs: ci_test_core @@ -68,3 +68,10 @@ jobs: ci_test_tooltip: needs: ci_test_core uses: ./.github/workflows/ci_test_tooltip.yml + + # + # Not needed here because it will be triggered by `ci_test_tooltip` + # + # ci_test_user-tooltip: + # needs: ci_test_core + # uses: ./.github/workflows/ci_test_user-tooltip.yml diff --git a/.github/workflows/ci_test_tooltip.yml b/.github/workflows/ci_test_tooltip.yml index 307d59b8..0f96d16d 100644 --- a/.github/workflows/ci_test_tooltip.yml +++ b/.github/workflows/ci_test_tooltip.yml @@ -24,3 +24,7 @@ jobs: working-directory: projects/tooltip runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + + ci_test_user-tooltip: + needs: ci_test_tooltip + uses: ./.github/workflows/ci_test_user-tooltip.yml diff --git a/.github/workflows/ci_test_user-card.yml b/.github/workflows/ci_test_user-card.yml index 08c6fe61..5df6dc8d 100644 --- a/.github/workflows/ci_test_user-card.yml +++ b/.github/workflows/ci_test_user-card.yml @@ -24,3 +24,7 @@ jobs: working-directory: projects/user-card runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' node-versions: '[18, 20]' + + ci_test_user-tooltip: + needs: ci_test_user-card + uses: ./.github/workflows/ci_test_user-tooltip.yml diff --git a/.github/workflows/ci_test_user-tooltip.yml b/.github/workflows/ci_test_user-tooltip.yml new file mode 100644 index 00000000..88c14d6b --- /dev/null +++ b/.github/workflows/ci_test_user-tooltip.yml @@ -0,0 +1,26 @@ +name: Test user-tooltip + +on: + workflow_dispatch: + workflow_call: + push: + branches: + - '**' + tags-ignore: + - '**' + paths: + - '.github/workflows/ci_test_user-tooltip.yml' + - 'projects/user-tooltip/**' + +concurrency: + group: ci-test-user-tooltip-group-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci_test_user-tooltip: + if: "${{ !contains(github.event.head_commit.message, 'chore(release): publish') }}" + uses: dsi-hug/action/.github/workflows/action.yml@v1 + with: + working-directory: projects/user-tooltip + runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' + node-versions: '[18, 20]' diff --git a/README.md b/README.md index 09004c09..cd2d39bc 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Package | Version | Downloads | Tests [@hug/ngx-time-picker](/projects/time-picker) | [![npm version][npm-logo-time-picker]][npm-time-picker] | [![npm downloads][npm-dl-logo-time-picker]][npm-dl-time-picker] | [![build status][tests-logo-time-picker]][tests-time-picker] [@hug/ngx-tooltip](/projects/tooltip) | [![npm version][npm-logo-tooltip]][npm-tooltip] | [![npm downloads][npm-dl-logo-tooltip]][npm-dl-tooltip] | [![build status][tests-logo-tooltip]][tests-tooltip] [@hug/ngx-user-card](/projects/user-card) | [![npm version][npm-logo-user-card]][npm-user-card] | [![npm downloads][npm-dl-logo-user-card]][npm-dl-user-card] | [![build status][tests-logo-user-card]][tests-user-card] +[@hug/ngx-user-tooltip](/projects/user-tooltip) | [![npm version][npm-logo-user-tooltip]][npm-user-tooltip] | [![npm downloads][npm-dl-logo-user-tooltip]][npm-dl-user-tooltip] | [![build status][tests-logo-user-tooltip]][tests-user-tooltip] @@ -167,3 +168,10 @@ Copyright (C) 2024 [HUG - Hôpitaux Universitaires Genève][dsi-hug] [npm-dl-logo-user-card]: https://img.shields.io/npm/dw/@hug/ngx-user-card.svg?color=7986CB&logo=npm&label=npm [tests-user-card]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_user-card.yml [tests-logo-user-card]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_user-card.yml/badge.svg + +[npm-user-tooltip]: https://www.npmjs.com/package/@hug/ngx-user-tooltip +[npm-logo-user-tooltip]: https://img.shields.io/npm/v/@hug/ngx-user-tooltip.svg?color=blue&logo=npm +[npm-dl-user-tooltip]: https://npmcharts.com/compare/@hug/ngx-user-tooltip?minimal=true +[npm-dl-logo-user-tooltip]: https://img.shields.io/npm/dw/@hug/ngx-user-tooltip.svg?color=7986CB&logo=npm&label=npm +[tests-user-tooltip]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_user-tooltip.yml +[tests-logo-user-tooltip]: https://github.com/dsi-hug/ngx-components/actions/workflows/ci_test_user-tooltip.yml/badge.svg diff --git a/angular.json b/angular.json index a0e97f66..a18edab6 100644 --- a/angular.json +++ b/angular.json @@ -507,6 +507,37 @@ } } } + }, + "user-tooltip": { + "projectType": "library", + "root": "projects/user-tooltip", + "sourceRoot": "projects/user-tooltip/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:ng-packagr", + "options": { + "project": "projects/user-tooltip/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "projects/user-tooltip/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "projects/user-tooltip/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/user-tooltip/src/test.ts", + "tsConfig": "projects/user-tooltip/tsconfig.spec.json", + "karmaConfig": "projects/user-tooltip/karma.conf.js" + } + } + } } } } diff --git a/package-lock.json b/package-lock.json index b008de98..ec6ccf2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "ngx-components", + "name": "@hug/ngx-components", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 0ad1bce6..822cdbcf 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "projects/status", "projects/time-picker", "projects/tooltip", - "projects/user-card" + "projects/user-card", + "projects/user-tooltip" ], "dependencies": { "@angular/animations": "~14.3.0", diff --git a/projects/user-tooltip/README.md b/projects/user-tooltip/README.md new file mode 100644 index 00000000..47bcd53e --- /dev/null +++ b/projects/user-tooltip/README.md @@ -0,0 +1,6 @@ +@hug/user-tooltip +======= + +The sources for this package are in the main [DSI-HUG/ngx-components](https://github.com/dsi-hug/ngx-components) repo. Please file issues and pull requests against that repo. + +License: GPL-3.0-only diff --git a/projects/user-tooltip/karma.conf.js b/projects/user-tooltip/karma.conf.js new file mode 100644 index 00000000..2e574898 --- /dev/null +++ b/projects/user-tooltip/karma.conf.js @@ -0,0 +1,45 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = config => { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, '../../coverage/user-tooltip'), + subdir: '.', + reporters: [ + { type: 'html' }, + { type: 'text-summary' } + ] + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + failOnEmptyTestSuite: false, + restartOnFileChange: true + }); +}; diff --git a/projects/user-tooltip/ng-package.json b/projects/user-tooltip/ng-package.json new file mode 100644 index 00000000..4a726467 --- /dev/null +++ b/projects/user-tooltip/ng-package.json @@ -0,0 +1,10 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/user-tooltip", + "assets": [ + "CHANGELOG.md" + ], + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/projects/user-tooltip/package.json b/projects/user-tooltip/package.json new file mode 100644 index 00000000..feb05138 --- /dev/null +++ b/projects/user-tooltip/package.json @@ -0,0 +1,46 @@ +{ + "name": "@hug/ngx-user-tooltip", + "version": "1.0.0", + "description": "HUG Angular - user-tooltip component", + "homepage": "https://github.com/dsi-hug/ngx-components", + "license": "GPL-3.0-only", + "author": "HUG - Hôpitaux Universitaires Genève", + "contributors": [ + "badisi (https://github.com/badisi)", + "vapkse (https://github.com/vapkse)" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/dsi-hug/ngx-components.git" + }, + "keywords": [ + "angular", + "material", + "material design", + "components" + ], + "sideEffects": false, + "scripts": { + "lint": "eslint . --fix", + "test": "ng test user-tooltip", + "test:ci": "ng test user-tooltip --watch=false --browsers=ChromeHeadless", + "build:ng": "ng build user-tooltip -c=production", + "build": "nx build:ng @hug/ngx-user-tooltip --verbose", + "release": "nx release -p=@hug/ngx-user-tooltip --yes --verbose", + "release:dry-run": "nx release -p=@hug/ngx-user-tooltip --verbose --dry-run" + }, + "peerDependencies": { + "@angular/common": ">= 14", + "@angular/core": ">= 14", + "@angular/material": ">= 14", + "@hug/ngx-core": "1.1.5", + "@hug/ngx-tooltip": "1.1.1", + "@hug/ngx-user-card": "1.1.0" + }, + "dependencies": { + "tslib": "^2.6.3" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/projects/user-tooltip/src/index.ts b/projects/user-tooltip/src/index.ts new file mode 100644 index 00000000..7cf56cbd --- /dev/null +++ b/projects/user-tooltip/src/index.ts @@ -0,0 +1,3 @@ +export * from './user-tooltip.module'; +export * from './user-tooltip.component'; +export * from './user-tooltip.service'; diff --git a/projects/user-tooltip/src/test.ts b/projects/user-tooltip/src/test.ts new file mode 100644 index 00000000..390c9374 --- /dev/null +++ b/projects/user-tooltip/src/test.ts @@ -0,0 +1,28 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js'; +import 'zone.js/testing'; + +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: { + context: (path: string, deep?: boolean, filter?: RegExp) => { + (id: string): T; + keys: () => string[]; + }; +}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); + +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().forEach(context); diff --git a/projects/user-tooltip/src/user-tooltip.component.html b/projects/user-tooltip/src/user-tooltip.component.html new file mode 100644 index 00000000..8d10538b --- /dev/null +++ b/projects/user-tooltip/src/user-tooltip.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects/user-tooltip/src/user-tooltip.component.ts b/projects/user-tooltip/src/user-tooltip.component.ts new file mode 100644 index 00000000..884bd516 --- /dev/null +++ b/projects/user-tooltip/src/user-tooltip.component.ts @@ -0,0 +1,16 @@ +import { ChangeDetectionStrategy, Component, ElementRef, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { TooltipComponentInterface } from '@hug/ngx-tooltip'; +import { UserCard } from '@hug/ngx-user-card'; + +@Component({ + selector: 'app-user-tooltip', + templateUrl: './user-tooltip.component.html', + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class UserTooltipComponent implements TooltipComponentInterface { + public constructor( + public elementRef: ElementRef, + @Inject(MAT_DIALOG_DATA) protected user: UserCard + ) { } +} diff --git a/projects/user-tooltip/src/user-tooltip.module.ts b/projects/user-tooltip/src/user-tooltip.module.ts new file mode 100644 index 00000000..06f82100 --- /dev/null +++ b/projects/user-tooltip/src/user-tooltip.module.ts @@ -0,0 +1,20 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { AbstractLazyModule } from '@hug/ngx-core'; +import { UserCardComponent } from '@hug/ngx-user-card'; + +import { UserTooltipComponent } from './user-tooltip.component'; + +@NgModule({ + declarations: [UserTooltipComponent], + exports: [UserTooltipComponent], + imports: [ + CommonModule, + UserCardComponent + ] +}) +export class UserTooltipModule extends AbstractLazyModule { + public constructor() { + super(UserTooltipComponent); + } +} diff --git a/projects/user-tooltip/src/user-tooltip.service.ts b/projects/user-tooltip/src/user-tooltip.service.ts new file mode 100644 index 00000000..26e407da --- /dev/null +++ b/projects/user-tooltip/src/user-tooltip.service.ts @@ -0,0 +1,25 @@ +import { Injectable, Type } from '@angular/core'; +import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; +import { AbstractLazyModule, LazyLoaderService } from '@hug/ngx-core'; +import { TooltipComponentInterface, TooltipService } from '@hug/ngx-tooltip'; +import { UserCard } from '@hug/ngx-user-card'; + +@Injectable({ + providedIn: 'root' +}) +export class UserTooltipService extends TooltipService { + public constructor( + lazyLoaderService: LazyLoaderService, + dialog: MatDialog + ) { + super(lazyLoaderService, dialog, { + panelClass: 'no-padding-dialog', + width: 'auto', + minWidth: '16px' + } as MatDialogConfig); + } + + protected getModule(): Promise>> { + return import('./user-tooltip.module').then(m => m.UserTooltipModule); + } +} diff --git a/projects/user-tooltip/tsconfig.lib.json b/projects/user-tooltip/tsconfig.lib.json new file mode 100644 index 00000000..599bb9f4 --- /dev/null +++ b/projects/user-tooltip/tsconfig.lib.json @@ -0,0 +1,15 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "declaration": true, + "declarationMap": true, + "inlineSources": true, + "types": [] + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/projects/user-tooltip/tsconfig.lib.prod.json b/projects/user-tooltip/tsconfig.lib.prod.json new file mode 100644 index 00000000..560c2391 --- /dev/null +++ b/projects/user-tooltip/tsconfig.lib.prod.json @@ -0,0 +1,10 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} diff --git a/projects/user-tooltip/tsconfig.spec.json b/projects/user-tooltip/tsconfig.spec.json new file mode 100644 index 00000000..3823c756 --- /dev/null +++ b/projects/user-tooltip/tsconfig.spec.json @@ -0,0 +1,17 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 4e581800..75a18271 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -60,6 +60,9 @@ ], "@hug/ngx-user-card": [ "dist/user-card" + ], + "@hug/ngx-user-tooltip": [ + "dist/user-tooltip" ] } }, diff --git a/tsconfig.json b/tsconfig.json index 5e1495c7..8565ac66 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -40,6 +40,9 @@ ], "@hug/ngx-user-card": [ "projects/user-card/src" + ], + "@hug/ngx-user-tooltip": [ + "projects/user-tooltip/src" ] } }