@open-rlb/ng-bootstrap 3.3.20 → 3.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,24 +1,74 @@
1
- # NgBootstrap
1
+ # @open-rlb/ng-bootstrap
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.1.0.
3
+ Angular 21 component library built on Bootstrap 5.3 (signals, OnPush), with timezone-aware
4
+ date handling via [`@open-rlb/date-tz`](https://www.npmjs.com/package/@open-rlb/date-tz).
4
5
 
5
- ## Code scaffolding
6
+ ## Installation
6
7
 
7
- Run `ng generate component component-name --project ng-bootstrap` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ng-bootstrap`.
8
- > Note: Don't forget to add `--project ng-bootstrap` or else it will be added to the default project in your `angular.json` file.
8
+ ### Recommended `ng add`
9
9
 
10
- ## Build
10
+ ```bash
11
+ ng add @open-rlb/ng-bootstrap
12
+ ```
11
13
 
12
- Run `ng build ng-bootstrap` to build the project. The build artifacts will be stored in the `dist/` directory.
14
+ The schematic will:
13
15
 
14
- ## Publishing
16
+ - install the required dependencies (`bootstrap`, `bootstrap-icons`, `@open-rlb/date-tz`,
17
+ `@ngx-translate/core`, `@angular/cdk`, and `@types/bootstrap`) at compatible versions;
18
+ - register the Bootstrap and Bootstrap Icons stylesheets in `angular.json`;
19
+ - add `provideRlbBootstrap()` to your application providers;
20
+ - scaffold a `RlbStarterComponent` (`src/app/rlb-starter/`) you can render to verify the setup
21
+ (pass `--skip-starter` to opt out).
22
+
23
+ ### Manual
24
+
25
+ ```bash
26
+ npm install @open-rlb/ng-bootstrap
27
+ ```
28
+
29
+ When installed this way, npm pulls the declared peer dependencies automatically (npm 7+).
30
+ Then register the providers and styles yourself:
31
+
32
+ ```typescript
33
+ // app.config.ts
34
+ import { provideRlbBootstrap } from '@open-rlb/ng-bootstrap';
15
35
 
16
- After building your library with `ng build ng-bootstrap`, go to the dist folder `cd dist/ng-bootstrap` and run `npm publish`.
36
+ export const appConfig: ApplicationConfig = {
37
+ providers: [provideRlbBootstrap()],
38
+ };
39
+ ```
17
40
 
18
- ## Running unit tests
41
+ ```jsonc
42
+ // angular.json → projects.<app>.architect.build.options.styles
43
+ "styles": [
44
+ "node_modules/bootstrap/dist/css/bootstrap.min.css",
45
+ "node_modules/bootstrap-icons/font/bootstrap-icons.css",
46
+ "src/styles.scss"
47
+ ]
48
+ ```
19
49
 
20
- Run `ng test ng-bootstrap` to execute the unit tests via [Karma](https://karma-runner.github.io).
50
+ ## Usage
21
51
 
22
- ## Further help
52
+ ```html
53
+ <rlb-card>
54
+ <rlb-card-header>Hello</rlb-card-header>
55
+ <rlb-card-body>
56
+ <button rlb-button color="primary">Click me</button>
57
+ </rlb-card-body>
58
+ </rlb-card>
59
+ ```
60
+
61
+ ## Development
62
+
63
+ - `npm run lib:build` — builds the library **and** its `ng-add` schematics into `dist/rlb/ng-bootstrap`.
64
+ - `npm run lib:test:ng-add` — runs an isolated, in-memory check of the `ng-add` schematic
65
+ (requires a prior `lib:build`).
66
+ - `npm run lib:pack` — builds and packs a publishable tarball.
67
+
68
+ ## Publishing
23
69
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
70
+ ```bash
71
+ npm run lib:build
72
+ cd dist/rlb/ng-bootstrap
73
+ npm publish
74
+ ```
package/package.json CHANGED
@@ -1,14 +1,30 @@
1
1
  {
2
2
  "name": "@open-rlb/ng-bootstrap",
3
- "version": "3.3.20",
3
+ "version": "3.3.22",
4
4
  "peerDependencies": {
5
+ "@angular/cdk": "^21.0.0",
6
+ "@angular/common": "^21.0.0",
7
+ "@angular/core": "^21.0.0",
8
+ "@angular/forms": "^21.0.0",
9
+ "@angular/router": "^21.0.0",
10
+ "@ngx-translate/core": "^16.0.0",
11
+ "@open-rlb/date-tz": ">=2.1.1",
5
12
  "bootstrap": ">=5.3.0",
6
- "@types/bootstrap": ">5.2.0",
7
- "@open-rlb/date-tz": ">=2.1.1"
13
+ "@types/bootstrap": ">=5.2.0",
14
+ "rxjs": "^7.8.0"
15
+ },
16
+ "peerDependenciesMeta": {
17
+ "@types/bootstrap": {
18
+ "optional": true
19
+ }
8
20
  },
9
21
  "dependencies": {
10
22
  "tslib": ">=2.3.0"
11
23
  },
24
+ "schematics": "./schematics/collection.json",
25
+ "ng-add": {
26
+ "save": "dependencies"
27
+ },
12
28
  "sideEffects": false,
13
29
  "module": "fesm2022/open-rlb-ng-bootstrap.mjs",
14
30
  "typings": "types/open-rlb-ng-bootstrap.d.ts",
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Add @open-rlb/ng-bootstrap to an Angular project: install peer dependencies, register Bootstrap styles, wire up provideRlbBootstrap(), and scaffold a starter component.",
6
+ "factory": "./ng-add/index#ngAdd",
7
+ "schema": "./ng-add/schema.json"
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ <rlb-card>
2
+ <rlb-card-header>@open-rlb/ng-bootstrap is ready 🎉</rlb-card-header>
3
+ <rlb-card-body>
4
+ <p class="mb-3">You clicked the button {{ clicks() }} times.</p>
5
+ <button rlb-button color="primary" (click)="increment()">Click me</button>
6
+ </rlb-card-body>
7
+ </rlb-card>
@@ -0,0 +1,25 @@
1
+ import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
2
+ import {
3
+ ButtonComponent,
4
+ CardBodyComponent,
5
+ CardComponent,
6
+ CardHeaderComponent,
7
+ } from '@open-rlb/ng-bootstrap';
8
+
9
+ /**
10
+ * Starter component generated by `ng add @open-rlb/ng-bootstrap`.
11
+ * Render `<app-rlb-starter />` (or route to it) to confirm the library works.
12
+ */
13
+ @Component({
14
+ selector: 'app-rlb-starter',
15
+ changeDetection: ChangeDetectionStrategy.OnPush,
16
+ imports: [CardComponent, CardHeaderComponent, CardBodyComponent, ButtonComponent],
17
+ templateUrl: './rlb-starter.component.html',
18
+ })
19
+ export class RlbStarterComponent {
20
+ clicks = signal(0);
21
+
22
+ increment(): void {
23
+ this.clicks.update(n => n + 1);
24
+ }
25
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = ngAdd;
4
+ const core_1 = require("@angular-devkit/core");
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const utility_1 = require("@schematics/angular/utility");
7
+ /**
8
+ * Dependencies the library needs at the consumer side. `@angular/{core,common,forms,router}`
9
+ * and `rxjs` are intentionally omitted: every Angular app already provides them.
10
+ */
11
+ const DEPENDENCIES = [
12
+ { name: '@open-rlb/date-tz', version: '^2.1.1', type: utility_1.DependencyType.Default },
13
+ { name: '@ngx-translate/core', version: '^16.0.0', type: utility_1.DependencyType.Default },
14
+ { name: '@angular/cdk', version: '^21.0.0', type: utility_1.DependencyType.Default },
15
+ { name: 'bootstrap', version: '^5.3.0', type: utility_1.DependencyType.Default },
16
+ { name: 'bootstrap-icons', version: '^1.11.0', type: utility_1.DependencyType.Default },
17
+ { name: '@types/bootstrap', version: '^5.2.0', type: utility_1.DependencyType.Dev },
18
+ ];
19
+ /** Global styles required for the Bootstrap look & feel. */
20
+ const STYLE_PATHS = [
21
+ 'node_modules/bootstrap/dist/css/bootstrap.min.css',
22
+ 'node_modules/bootstrap-icons/font/bootstrap-icons.css',
23
+ ];
24
+ function ngAdd(options) {
25
+ return async (tree, _context) => {
26
+ const project = await resolveProject(tree, options.project);
27
+ return (0, schematics_1.chain)([
28
+ // 1. Install dependencies (a single npm install is scheduled automatically).
29
+ ...DEPENDENCIES.map(dep => (0, utility_1.addDependency)(dep.name, dep.version, { type: dep.type })),
30
+ // 2. Register Bootstrap + Bootstrap Icons global styles in angular.json.
31
+ addBootstrapStyles(project),
32
+ // 3. Wire up the library providers (modals/toasts registry, etc.).
33
+ (0, utility_1.addRootProvider)(project, ({ code, external }) => code `${external('provideRlbBootstrap', '@open-rlb/ng-bootstrap')}()`),
34
+ // 4. Optionally scaffold a starter component.
35
+ options.skipStarter ? noop : scaffoldStarter(tree, project),
36
+ // 5. Print next steps.
37
+ logNextSteps(project, options.skipStarter),
38
+ ]);
39
+ };
40
+ }
41
+ /** Resolves the target project: the provided name, else the first application, else the first project. */
42
+ async function resolveProject(tree, name) {
43
+ const workspace = await (0, utility_1.readWorkspace)(tree);
44
+ if (name) {
45
+ if (!workspace.projects.has(name)) {
46
+ throw new schematics_1.SchematicsException(`Project "${name}" was not found in the workspace.`);
47
+ }
48
+ return name;
49
+ }
50
+ for (const [projectName, project] of workspace.projects) {
51
+ if (project.extensions['projectType'] === 'application') {
52
+ return projectName;
53
+ }
54
+ }
55
+ const first = workspace.projects.keys().next().value;
56
+ if (!first) {
57
+ throw new schematics_1.SchematicsException('No project found in the workspace to add @open-rlb/ng-bootstrap to.');
58
+ }
59
+ return first;
60
+ }
61
+ function addBootstrapStyles(project) {
62
+ return (0, utility_1.updateWorkspace)(workspace => {
63
+ const target = workspace.projects.get(project)?.targets.get('build');
64
+ if (!target) {
65
+ return;
66
+ }
67
+ target.options ??= {};
68
+ const styles = target.options['styles'] ?? [];
69
+ for (const style of STYLE_PATHS) {
70
+ const present = styles.some(s => (typeof s === 'string' ? s : s.input) === style);
71
+ if (!present) {
72
+ styles.unshift(style);
73
+ }
74
+ }
75
+ target.options['styles'] = styles;
76
+ });
77
+ }
78
+ function scaffoldStarter(tree, project) {
79
+ return async () => {
80
+ const workspace = await (0, utility_1.readWorkspace)(tree);
81
+ const def = workspace.projects.get(project);
82
+ const sourceRoot = def?.sourceRoot ?? (def ? `${def.root}/src` : 'src');
83
+ const templates = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
84
+ (0, schematics_1.applyTemplates)({ ...core_1.strings }),
85
+ (0, schematics_1.move)(`${sourceRoot}/app/rlb-starter`),
86
+ ]);
87
+ // Skip silently if the files already exist (idempotent re-runs).
88
+ return (0, schematics_1.mergeWith)(templates, schematics_1.MergeStrategy.Default);
89
+ };
90
+ }
91
+ function logNextSteps(project, skipStarter) {
92
+ return (_tree, context) => {
93
+ const log = context.logger;
94
+ log.info('');
95
+ log.info('✅ @open-rlb/ng-bootstrap added successfully.');
96
+ log.info(` • Dependencies installed and added to package.json`);
97
+ log.info(` • Bootstrap + Bootstrap Icons styles registered in angular.json`);
98
+ log.info(` • provideRlbBootstrap() wired into the "${project}" app providers`);
99
+ if (!skipStarter) {
100
+ log.info(' • Starter component generated at src/app/rlb-starter/');
101
+ log.info(' Render it to verify the setup, e.g. add <app-rlb-starter /> to a template.');
102
+ }
103
+ log.info('');
104
+ };
105
+ }
106
+ /** A no-op rule. */
107
+ const noop = tree => tree;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "OpenRlbNgBootstrapNgAdd",
4
+ "title": "@open-rlb/ng-bootstrap ng-add schematic",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "The name of the project to add the library to.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "skipStarter": {
15
+ "type": "boolean",
16
+ "default": false,
17
+ "description": "Do not scaffold the RlbStarterComponent example."
18
+ }
19
+ },
20
+ "required": []
21
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }