@angular-bootstrap/ngbootstrap 0.0.1

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 ADDED
@@ -0,0 +1,302 @@
1
+ # @angular-bootstrap/ngbootstrap
2
+
3
+ Angular UI library providing datagrid, drag‑and‑drop, pagination, and stepper components with Bootstrap‑friendly styling.
4
+
5
+ ## Features
6
+
7
+ - Datagrid – sortable, filterable, paginated, editable table with export (PDF/Excel) support and accessible templates.
8
+ - Drag & drop – lightweight list and item directives with keyboard‑friendly a11y helpers.
9
+ - Pagination – standalone Bootstrap‑styled pagination component.
10
+ - Stepper – horizontal/vertical stepper with custom labels, error states, theming hooks, and keyboard support.
11
+ - Splitter – resizable horizontal/vertical panes with collapsing, keyboard resizing, and ARIA semantics.
12
+ - Tree – keyboard-accessible tree with optional checkboxes, JSON-style expanders, and expand/collapse helpers.
13
+ - Typeahead – virtualized, debounced search with single/multi select, exact-match selection, and scroll hooks.
14
+ - Angular + Bootstrap first – built for modern Angular (v17–20) and works with plain Bootstrap CSS; Material/Tailwind can be layered via custom styles.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @angular-bootstrap/ngbootstrap
20
+ ```
21
+
22
+ Make sure your app:
23
+
24
+ - Uses Angular 17–20.
25
+ - Includes Bootstrap CSS (for example in `angular.json` or global styles):
26
+
27
+ ```css
28
+ @import 'bootstrap/dist/css/bootstrap.min.css';
29
+ ```
30
+
31
+ ## Usage overview
32
+
33
+ All components are standalone, so you import them directly into your feature components.
34
+
35
+ ### Datagrid
36
+
37
+ ```ts
38
+ import { Component } from '@angular/core';
39
+ import { Datagrid } from '@angular-bootstrap/ngbootstrap/datagrid';
40
+
41
+ interface User {
42
+ id: number;
43
+ name: string;
44
+ email: string;
45
+ }
46
+
47
+ @Component({
48
+ standalone: true,
49
+ selector: 'app-users',
50
+ imports: [Datagrid],
51
+ template: `
52
+ <ngb-datagrid
53
+ [columns]="columns"
54
+ [data]="rows"
55
+ [enableSorting]="true"
56
+ [enableFiltering]="true"
57
+ [enablePagination]="true"
58
+ [pageSize]="10"
59
+ (rowSave)="onRowSave($event)"
60
+ ></ngb-datagrid>
61
+ `,
62
+ })
63
+ export class UsersComponent {
64
+ columns = [
65
+ { field: 'id', header: 'ID', sortable: true },
66
+ { field: 'name', header: 'Name', sortable: true, filterable: true },
67
+ { field: 'email', header: 'Email', sortable: true, filterable: true, type: 'email' },
68
+ ];
69
+
70
+ rows: User[] = [
71
+ { id: 1, name: 'Alice', email: 'alice@example.com' },
72
+ { id: 2, name: 'Bob', email: 'bob@example.com' },
73
+ ];
74
+
75
+ onRowSave(evt: { original: User; updated: User }) {
76
+ // persist the update
77
+ }
78
+ }
79
+ ```
80
+
81
+ Key datagrid capabilities:
82
+
83
+ - Sorting (`enableSorting`, `sortChange`).
84
+ - Column/global filtering (`enableFiltering`, `enableGlobalFilter`, `filtersChange`).
85
+ - Pagination (`enablePagination`, `pageSize`, `pageChange`).
86
+ - Inline add/edit/delete (`enableAdd`, `enableEdit`, `enableDelete`, `rowAdd`, `rowSave`, `rowDelete`).
87
+ - Export to PDF/Excel via `exportOptions`.
88
+
89
+ Export requires optional peer dependencies. Install only if you use export:
90
+
91
+ ```sh
92
+ npm install jspdf jspdf-autotable xlsx
93
+ ```
94
+
95
+ ### Pagination
96
+
97
+ ```ts
98
+ import { Component } from '@angular/core';
99
+ import { NgbPaginationComponent } from '@angular-bootstrap/ngbootstrap/pagination';
100
+
101
+ @Component({
102
+ standalone: true,
103
+ selector: 'app-pager',
104
+ imports: [NgbPaginationComponent],
105
+ template: `
106
+ <ngb-pagination
107
+ [(page)]="page"
108
+ [pageSize]="pageSize"
109
+ [collectionSize]="total"
110
+ (pageChange)="loadPage($event)"
111
+ ></ngb-pagination>
112
+ `,
113
+ })
114
+ export class PagerComponent {
115
+ page = 1;
116
+ pageSize = 10;
117
+ total = 250;
118
+
119
+ loadPage(p: number) {
120
+ this.page = p;
121
+ // fetch data for the page
122
+ }
123
+ }
124
+ ```
125
+
126
+ ### Stepper
127
+
128
+ ```ts
129
+ import { Component } from '@angular/core';
130
+ import { NgbStepperComponent } from '@angular-bootstrap/ngbootstrap/stepper';
131
+ import { NgbStepperStep } from '@angular-bootstrap/ngbootstrap/stepper';
132
+
133
+ ### Splitter
134
+
135
+ ```ts
136
+ import { Component } from '@angular/core';
137
+ import { NgbSplitterComponent, NgbSplitterPaneComponent } from '@angular-bootstrap/ngbootstrap/splitter';
138
+
139
+ @Component({
140
+ standalone: true,
141
+ selector: 'app-splitter',
142
+ imports: [NgbSplitterComponent, NgbSplitterPaneComponent],
143
+ template: `
144
+ <ngb-splitter orientation="horizontal">
145
+ <ngb-splitter-pane size="30%" min="200px" [collapsible]="true" (collapsedChange)="onCollapse($event)">
146
+ <div class="p-3">Navigation</div>
147
+ </ngb-splitter-pane>
148
+ <ngb-splitter-pane>
149
+ <div class="p-3">Main content</div>
150
+ </ngb-splitter-pane>
151
+ </ngb-splitter>
152
+ `,
153
+ })
154
+ export class SplitterExampleComponent {
155
+ onCollapse(collapsed: boolean) {
156
+ // persist pane state if needed
157
+ }
158
+ }
159
+ ```
160
+
161
+ @Component({
162
+ standalone: true,
163
+ selector: 'app-wizard',
164
+ imports: [NgbStepperComponent],
165
+ template: `
166
+ <ngb-stepper
167
+ [steps]="steps"
168
+ [(selectedIndex)]="index"
169
+ orientation="horizontal"
170
+ [allowRevisit]="false"
171
+ theme="bootstrap"
172
+ (selectionChange)="onSelectionChange($event)"
173
+ >
174
+ <ng-template #stepContent let-index="index">
175
+ <ng-container [ngSwitch]="index">
176
+ <div *ngSwitchCase="0">Account step</div>
177
+ <div *ngSwitchCase="1">Profile step</div>
178
+ <div *ngSwitchCase="2">Confirm step</div>
179
+ </ng-container>
180
+ </ng-template>
181
+ </ngb-stepper>
182
+ `,
183
+ })
184
+ export class WizardComponent {
185
+ index = 0;
186
+
187
+ steps: NgbStepperStep[] = [
188
+ { id: 'account', label: 'Account' },
189
+ { id: 'profile', label: 'Profile' },
190
+ { id: 'confirm', label: 'Confirm', optional: true },
191
+ ];
192
+
193
+ onSelectionChange(e: { previousIndex: number; currentIndex: number }) {
194
+ // analytics, autosave, etc.
195
+ }
196
+ }
197
+ ```
198
+
199
+ Stepper highlights:
200
+
201
+ - Horizontal/vertical variants via `orientation`.
202
+ - Custom labels with the `ngbStepLabel` directive.
203
+ - Label and content positioning (`labelPosition`, `contentPosition`).
204
+ - Error states and messages (`errorMessage` on steps).
205
+ - Controlled navigation (`allowRevisit`, `next()`, `prev()`, `reset()` and events).
206
+ - Theming hooks via `theme` and CSS classes (`bootstrap`, `material`, `tailwind`).
207
+
208
+ ### Drag & drop
209
+
210
+ ```ts
211
+ import { Component } from '@angular/core';
212
+ import { DndListDirective, DndItemDirective } from '@angular-bootstrap/ngbootstrap/drag-drop';
213
+
214
+ ### Tree
215
+
216
+ ```ts
217
+ import { Component } from '@angular/core';
218
+ import { NgbTreeComponent, NgbTreeNode } from '@angular-bootstrap/ngbootstrap/tree';
219
+
220
+ @Component({
221
+ standalone: true,
222
+ selector: 'app-tree',
223
+ imports: [NgbTreeComponent],
224
+ template: `
225
+ <ngb-tree
226
+ [nodes]="nodes"
227
+ [showCheckbox]="true"
228
+ type="json"
229
+ (expand)="onExpand($event)"
230
+ (collapse)="onCollapse($event)"
231
+ (selectionChange)="onSelection($event)"
232
+ ></ngb-tree>
233
+ `,
234
+ })
235
+ export class TreeExampleComponent {
236
+ nodes: NgbTreeNode[] = [
237
+ {
238
+ id: 'parent',
239
+ label: 'Parent',
240
+ expanded: true,
241
+ children: [
242
+ { id: 'child-1', label: 'Child 1' },
243
+ { id: 'child-2', label: 'Child 2' },
244
+ ],
245
+ },
246
+ ];
247
+
248
+ onExpand(node: NgbTreeNode) {}
249
+ onCollapse(node: NgbTreeNode) {}
250
+ onSelection(selected: NgbTreeNode[]) {}
251
+ }
252
+ ```
253
+
254
+ @Component({
255
+ standalone: true,
256
+ selector: 'app-drag-list',
257
+ imports: [DndListDirective, DndItemDirective],
258
+ template: `
259
+ <ul dndList [dndListData]="items">
260
+ <li *ngFor="let item of items" dndItem [dndItemData]="item">
261
+ {{ item }}
262
+ </li>
263
+ </ul>
264
+ `,
265
+ })
266
+ export class DragListComponent {
267
+ items = ['One', 'Two', 'Three'];
268
+ }
269
+ ```
270
+
271
+ Refer to the source under `src/drag-drop` and `src/datagrid`/`src/stepper` for full API details until a dedicated docs site is added.
272
+
273
+ ## Development
274
+
275
+ Local setup:
276
+
277
+ ```bash
278
+ npm install
279
+ npm run lint
280
+ npm test
281
+ npm run build
282
+ ```
283
+
284
+ - Build artefacts go to `dist/`.
285
+ - Tests are powered by Jest + `jest-preset-angular`.
286
+
287
+ ## Releasing
288
+
289
+ Releases are automated via GitHub Actions:
290
+
291
+ - Non‑`main` branches:
292
+ - `.github/workflows/ci.yml` runs install, tests, build only.
293
+ - `main` branch:
294
+ - `.github/workflows/release.yml` runs install, tests, build and publishes to npm using `NPM_TOKEN` from repository secrets.
295
+
296
+ Recommended release flow:
297
+
298
+ - On your local machine:
299
+ - Decide the new version (e.g. `1.1.0`).
300
+ - Run `npm version minor` or `npm version patch` to bump `package.json` and create the tag.
301
+ - Push the commit and tag: `git push origin main --tags`.
302
+ - GitHub Actions will build and publish that tagged version to npm.