ng-hub-ui-board 19.3.9 β 19.4.0
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 +154 -23
- package/fesm2022/ng-hub-ui-board.mjs +704 -27
- package/fesm2022/ng-hub-ui-board.mjs.map +1 -1
- package/index.d.ts +461 -16
- package/ng-hub-ui-board-19.4.0.tgz +0 -0
- package/package.json +3 -4
- package/src/lib/styles/base.scss +136 -15
package/README.md
CHANGED
|
@@ -21,33 +21,34 @@ A flexible and powerful board component for Angular applications, perfect for im
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
23
23
|
- π― **Standalone component** - Modern Angular approach with minimal setup
|
|
24
|
-
- π **
|
|
24
|
+
- π **Native drag and drop** - Custom implementation without external dependencies (no CDK required)
|
|
25
|
+
- π¨ **Fully customizable drag visuals** - Custom templates for drag previews and drop placeholders
|
|
26
|
+
- βοΈ **Configurable drag behavior** - Choose between ghost, hide, or collapse modes for dragged elements
|
|
25
27
|
- π± **Responsive design** - Works seamlessly across desktop, tablet, and mobile devices
|
|
26
|
-
-
|
|
28
|
+
- π **Highly customizable** - Custom templates for cards, headers, footers, and drag interactions
|
|
27
29
|
- π§ **Bootstrap compatible** - Integrates perfectly with Bootstrap 5 design system
|
|
28
30
|
- β‘ **Virtual scrolling** - Supports infinite scroll with end-detection for performance
|
|
29
|
-
-
|
|
31
|
+
- π¨ **Custom styling** - CSS custom properties for easy theming and customization
|
|
30
32
|
- π **Granular control** - Enable/disable functionality at board, column, or card level
|
|
31
33
|
- π·οΈ **TypeScript support** - Full type safety with generic interfaces
|
|
32
34
|
- βΏ **Accessibility ready** - Follows WAI-ARIA best practices for drag-and-drop
|
|
35
|
+
- πͺΆ **Lightweight** - Zero external UI dependencies
|
|
33
36
|
|
|
34
37
|
## Installation
|
|
35
38
|
|
|
36
39
|
```bash
|
|
37
40
|
# Install the component
|
|
38
41
|
npm install ng-hub-ui-board
|
|
39
|
-
|
|
40
|
-
# Install required peer dependency
|
|
41
|
-
npm install @angular/cdk
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Or using yarn:
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
47
|
yarn add ng-hub-ui-board
|
|
48
|
-
yarn add @angular/cdk
|
|
49
48
|
```
|
|
50
49
|
|
|
50
|
+
**Note:** Starting from version 19.4.0, `@angular/cdk` is no longer required. The component now includes its own native drag-and-drop implementation.
|
|
51
|
+
|
|
51
52
|
## Quick Start
|
|
52
53
|
|
|
53
54
|
Hereβs a quick example to get you started with `ng-hub-ui-board` using the standalone component approach.
|
|
@@ -169,7 +170,9 @@ export class AppModule {}
|
|
|
169
170
|
|
|
170
171
|
## Templates
|
|
171
172
|
|
|
172
|
-
The component uses
|
|
173
|
+
The component uses multiple templates for customization. If you're using the standalone approach, remember to import the corresponding directives for each template you plan to use.
|
|
174
|
+
|
|
175
|
+
### Standard Templates
|
|
173
176
|
|
|
174
177
|
### Card Template (CardTemplateDirective)
|
|
175
178
|
|
|
@@ -221,6 +224,71 @@ Used to add a footer to each column. Useful for summary information, quick actio
|
|
|
221
224
|
</ng-template>
|
|
222
225
|
```
|
|
223
226
|
|
|
227
|
+
### Drag-and-Drop Templates
|
|
228
|
+
|
|
229
|
+
#### Card Drag Preview Template (CardDragPreviewDirective)
|
|
230
|
+
|
|
231
|
+
Customize the visual element that follows the cursor when dragging cards. The template receives the dragged card and its source column as context.
|
|
232
|
+
|
|
233
|
+
```html
|
|
234
|
+
<ng-template cardDragPreview let-card="card" let-column="column">
|
|
235
|
+
<div class="custom-drag-preview">
|
|
236
|
+
<div class="preview-header">
|
|
237
|
+
<span class="badge">{{ column.title }}</span>
|
|
238
|
+
</div>
|
|
239
|
+
<h4>{{ card.title }}</h4>
|
|
240
|
+
<p class="preview-description">{{ card.description }}</p>
|
|
241
|
+
</div>
|
|
242
|
+
</ng-template>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Context variables:**
|
|
246
|
+
|
|
247
|
+
- `card`: The card being dragged
|
|
248
|
+
- `column`: The source column of the card
|
|
249
|
+
|
|
250
|
+
#### Card Placeholder Template (CardPlaceholderDirective)
|
|
251
|
+
|
|
252
|
+
Customize the drop zone appearance when dragging cards between or within columns.
|
|
253
|
+
|
|
254
|
+
```html
|
|
255
|
+
<ng-template cardPlaceholder>
|
|
256
|
+
<div class="custom-card-placeholder">
|
|
257
|
+
<span class="placeholder-icon">π₯</span>
|
|
258
|
+
<p>Drop card here</p>
|
|
259
|
+
</div>
|
|
260
|
+
</ng-template>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### Column Drag Preview Template (ColumnDragPreviewDirective)
|
|
264
|
+
|
|
265
|
+
Customize the visual element that follows the cursor when dragging columns. The template receives the dragged column as context.
|
|
266
|
+
|
|
267
|
+
```html
|
|
268
|
+
<ng-template columnDragPreview let-column="column">
|
|
269
|
+
<div class="custom-column-preview">
|
|
270
|
+
<h3>{{ column.title }}</h3>
|
|
271
|
+
<span class="card-count">{{ column.cards.length }} cards</span>
|
|
272
|
+
</div>
|
|
273
|
+
</ng-template>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Context variable:**
|
|
277
|
+
|
|
278
|
+
- `column`: The column being dragged
|
|
279
|
+
|
|
280
|
+
#### Column Placeholder Template (ColumnPlaceholderDirective)
|
|
281
|
+
|
|
282
|
+
Customize the drop zone appearance when reordering columns.
|
|
283
|
+
|
|
284
|
+
```html
|
|
285
|
+
<ng-template columnPlaceholder>
|
|
286
|
+
<div class="custom-column-placeholder">
|
|
287
|
+
<span class="placeholder-text">Drop column here</span>
|
|
288
|
+
</div>
|
|
289
|
+
</ng-template>
|
|
290
|
+
```
|
|
291
|
+
|
|
224
292
|
## Events
|
|
225
293
|
|
|
226
294
|
The `HubBoardComponent` emits several events to help you interact with user actions such as clicking cards, moving items, or reaching scroll limits.
|
|
@@ -253,12 +321,14 @@ Emitted when a card is moved either within the same column or between columns.
|
|
|
253
321
|
<hub-board [board]="board" (onCardMoved)="handleCardMoved($event)"> </hub-board>
|
|
254
322
|
```
|
|
255
323
|
|
|
256
|
-
**Type:** `EventEmitter<
|
|
324
|
+
**Type:** `EventEmitter<CardDragDropEvent>`
|
|
257
325
|
|
|
258
326
|
**Example:**
|
|
259
327
|
|
|
260
328
|
```ts
|
|
261
|
-
|
|
329
|
+
import { CardDragDropEvent } from 'ng-hub-ui-board';
|
|
330
|
+
|
|
331
|
+
handleCardMoved(event: CardDragDropEvent) {
|
|
262
332
|
const card = event.item.data;
|
|
263
333
|
const from = event.previousContainer.data;
|
|
264
334
|
const to = event.container.data;
|
|
@@ -277,12 +347,14 @@ Emitted when a column is reordered via drag and drop.
|
|
|
277
347
|
<hub-board [board]="board" (onColumnMoved)="handleColumnMoved($event)"> </hub-board>
|
|
278
348
|
```
|
|
279
349
|
|
|
280
|
-
**Type:** `EventEmitter<
|
|
350
|
+
**Type:** `EventEmitter<ColumnDragDropEvent>`
|
|
281
351
|
|
|
282
352
|
**Example:**
|
|
283
353
|
|
|
284
354
|
```ts
|
|
285
|
-
|
|
355
|
+
import { ColumnDragDropEvent } from 'ng-hub-ui-board';
|
|
356
|
+
|
|
357
|
+
handleColumnMoved(event: ColumnDragDropEvent) {
|
|
286
358
|
console.log(`Column moved from ${event.previousIndex} to ${event.currentIndex}`);
|
|
287
359
|
}
|
|
288
360
|
```
|
|
@@ -346,21 +418,22 @@ loadMoreCards(event: ReachedEndEvent) {
|
|
|
346
418
|
|
|
347
419
|
The following inputs are available on the `HubBoardComponent`:
|
|
348
420
|
|
|
349
|
-
| Input | Type
|
|
350
|
-
| ----------------------- |
|
|
351
|
-
| `board` | `Signal<Board>`
|
|
352
|
-
| `columnSortingDisabled` | `boolean`
|
|
421
|
+
| Input | Type | Description | Default |
|
|
422
|
+
| ----------------------- | ---------------- | -------------------------------------------------------------------------------------------------------- | ------------ |
|
|
423
|
+
| `board` | `Signal<Board>` | The board object containing columns and cards | `undefined` |
|
|
424
|
+
| `columnSortingDisabled` | `boolean` | Disables drag-and-drop sorting of columns | `false` |
|
|
425
|
+
| `dragBehavior` | `DragBehavior` | Controls how dragged elements behave visually: `'ghost'` (semi-transparent), `'hide'`, or `'collapse'` | `'collapse'` |
|
|
353
426
|
|
|
354
427
|
## Outputs
|
|
355
428
|
|
|
356
429
|
These outputs are emitted by the component during user interaction:
|
|
357
430
|
|
|
358
|
-
| Output | Type
|
|
359
|
-
| --------------- |
|
|
360
|
-
| `onCardClick` | `EventEmitter<BoardCard>`
|
|
361
|
-
| `onCardMoved` | `EventEmitter<
|
|
362
|
-
| `onColumnMoved` | `EventEmitter<
|
|
363
|
-
| `reachedEnd` | `EventEmitter<ReachedEndEvent>`
|
|
431
|
+
| Output | Type | Description |
|
|
432
|
+
| --------------- | ----------------------------------- | ------------------------------------------------------------------------- |
|
|
433
|
+
| `onCardClick` | `EventEmitter<BoardCard>` | Triggered when a card is clicked |
|
|
434
|
+
| `onCardMoved` | `EventEmitter<CardDragDropEvent>` | Emitted when a card is moved (within or across columns) |
|
|
435
|
+
| `onColumnMoved` | `EventEmitter<ColumnDragDropEvent>` | Emitted when a column is reordered via drag and drop |
|
|
436
|
+
| `reachedEnd` | `EventEmitter<ReachedEndEvent>` | Triggered when the user scrolls to the bottom of a column (for lazy load) |
|
|
364
437
|
|
|
365
438
|
## Interfaces
|
|
366
439
|
|
|
@@ -394,7 +467,6 @@ interface BoardColumn<T = any> {
|
|
|
394
467
|
classlist?: string[] | string;
|
|
395
468
|
disabled?: boolean;
|
|
396
469
|
cardSortingDisabled?: boolean;
|
|
397
|
-
predicate?: (item?: CdkDrag<T>) => boolean;
|
|
398
470
|
}
|
|
399
471
|
```
|
|
400
472
|
|
|
@@ -415,6 +487,54 @@ interface BoardCard<T = any> {
|
|
|
415
487
|
}
|
|
416
488
|
```
|
|
417
489
|
|
|
490
|
+
### CardDragDropEvent
|
|
491
|
+
|
|
492
|
+
Event interface emitted when a card is moved. Provides all information about the drag-and-drop operation.
|
|
493
|
+
|
|
494
|
+
```typescript
|
|
495
|
+
interface CardDragDropEvent<T = any> {
|
|
496
|
+
previousIndex: number;
|
|
497
|
+
currentIndex: number;
|
|
498
|
+
container: BoardDropContainer<BoardColumn>;
|
|
499
|
+
previousContainer: BoardDropContainer<BoardColumn>;
|
|
500
|
+
item: BoardDragItem<BoardCard>;
|
|
501
|
+
isPointerOverContainer: boolean;
|
|
502
|
+
distance?: { x: number; y: number };
|
|
503
|
+
dropPoint?: { x: number; y: number };
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### ColumnDragDropEvent
|
|
508
|
+
|
|
509
|
+
Event interface emitted when a column is moved. Provides all information about the column reordering operation.
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
interface ColumnDragDropEvent {
|
|
513
|
+
previousIndex: number;
|
|
514
|
+
currentIndex: number;
|
|
515
|
+
container: BoardDropContainer<BoardColumn[]>;
|
|
516
|
+
previousContainer: BoardDropContainer<BoardColumn[]>;
|
|
517
|
+
item: BoardDragItem<BoardColumn>;
|
|
518
|
+
isPointerOverContainer: boolean;
|
|
519
|
+
distance?: { x: number; y: number };
|
|
520
|
+
dropPoint?: { x: number; y: number };
|
|
521
|
+
}
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### DragBehavior
|
|
525
|
+
|
|
526
|
+
Type definition for controlling how dragged elements behave visually during drag operations.
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
type DragBehavior = 'ghost' | 'hide' | 'collapse';
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**Values:**
|
|
533
|
+
|
|
534
|
+
- `'ghost'`: Element becomes semi-transparent (50% opacity) but remains visible
|
|
535
|
+
- `'hide'`: Element is hidden but still occupies its space (invisible placeholder)
|
|
536
|
+
- `'collapse'`: Element is completely hidden and its space is collapsed (default)
|
|
537
|
+
|
|
418
538
|
## π§© Styling
|
|
419
539
|
|
|
420
540
|
The `ng-hub-ui-board` library is fully style-configurable through **CSS custom properties (CSS variables)**, defined with a consistent naming convention and designed to be easily overridden in consuming applications. It is built with flexibility in mind and integrates seamlessly with **Bootstrap** or any design system that supports custom properties.
|
|
@@ -477,6 +597,17 @@ You can customize the board's appearance by overriding these CSS variables. Exam
|
|
|
477
597
|
| `--hub-card-cap-padding-x` | `1rem` | Horizontal padding of card header/footer |
|
|
478
598
|
| `--hub-card-cap-padding-y` | `0.5rem` | Vertical padding of card header/footer |
|
|
479
599
|
|
|
600
|
+
#### Drag and Drop specific
|
|
601
|
+
|
|
602
|
+
| Variable | Default Value | Description |
|
|
603
|
+
| --------------------------------- | ---------------------------------------- | ------------------------------------------------ |
|
|
604
|
+
| `--hub-drag-transition` | `transform 250ms cubic-bezier(0,0,0.2,1)`| Transition animation for drag operations |
|
|
605
|
+
| `--hub-placeholder-border-color` | `#0d6efd` | Border color of drop zone placeholders |
|
|
606
|
+
| `--hub-placeholder-border-width` | `2px` | Border width of drop zone placeholders |
|
|
607
|
+
| `--hub-placeholder-border-style` | `dashed` | Border style of drop zone placeholders |
|
|
608
|
+
| `--hub-placeholder-bg` | `rgba(13, 110, 253, 0.05)` | Background color of drop zone placeholders |
|
|
609
|
+
| `--hub-placeholder-min-height` | `60px` | Minimum height for card drop zone placeholders |
|
|
610
|
+
|
|
480
611
|
### π How to include the styles in your application
|
|
481
612
|
|
|
482
613
|
To use the styles from `ng-hub-ui-board`, you need to import the base SCSS file from the compiled library into your main applicationβs `styles.scss` (or wherever you define your global styles).
|