@libs-ui/components-drag-drop 0.2.190 → 0.2.191

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,3 +1,445 @@
1
- # drag-drop
1
+ # Drag and Drop Component Documentation
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ ## Overview
4
+
5
+ The Drag and Drop component provides a powerful and flexible way to implement drag and drop functionality in your Angular applications. It supports various scenarios including container-to-container dragging, virtual scrolling, and custom drag boundaries.
6
+
7
+ ## Quick Start
8
+
9
+ ### Installation
10
+
11
+ ```bash
12
+ npm install @libs-ui/drag-drop
13
+ ```
14
+
15
+ ### Basic Implementation
16
+
17
+ ```typescript
18
+ import { LibsUiComponentsDragContainerDirective, LibsUiDragItemDirective } from '@libs-ui/drag-drop';
19
+
20
+ @Component({
21
+ selector: 'app-drag-drop-demo',
22
+ template: `
23
+ <div LibsUiComponentsDragContainerDirective [items]="items">
24
+ <div *ngFor="let item of items" LibsUiDragItemDirective [item]="item">
25
+ {{ item.name }}
26
+ </div>
27
+ </div>
28
+ `,
29
+ standalone: true,
30
+ imports: [LibsUiComponentsDragContainerDirective, LibsUiDragItemDirective]
31
+ })
32
+ export class DragDropDemoComponent {
33
+ items = [
34
+ { id: 1, name: 'Item 1' },
35
+ { id: 2, name: 'Item 2' },
36
+ { id: 3, name: 'Item 3' }
37
+ ];
38
+ }
39
+ ```
40
+
41
+ ## Features
42
+
43
+ ### 1. Container-to-Container Drag
44
+
45
+ ```typescript
46
+ @Component({
47
+ template: `
48
+ <div class="container">
49
+ <h3>Source</h3>
50
+ <div LibsUiComponentsDragContainerDirective
51
+ [items]="sourceItems"
52
+ [groupName]="'source'"
53
+ [dropToGroupName]="['target']">
54
+ <div *ngFor="let item of sourceItems"
55
+ LibsUiDragItemDirective
56
+ [item]="item">
57
+ {{ item.name }}
58
+ </div>
59
+ </div>
60
+ </div>
61
+
62
+ <div class="container">
63
+ <h3>Target</h3>
64
+ <div LibsUiComponentsDragContainerDirective
65
+ [items]="targetItems"
66
+ [groupName]="'target'"
67
+ [dropToGroupName]="['source']">
68
+ <div *ngFor="let item of targetItems"
69
+ LibsUiDragItemDirective
70
+ [item]="item">
71
+ {{ item.name }}
72
+ </div>
73
+ </div>
74
+ </div>
75
+ `,
76
+ styles: [`
77
+ .container {
78
+ border: 1px solid #ccc;
79
+ padding: 10px;
80
+ margin: 10px;
81
+ min-height: 200px;
82
+ }
83
+ `]
84
+ })
85
+ ```
86
+
87
+ ### 2. Virtual Scrolling Support
88
+
89
+ ```typescript
90
+ @Component({
91
+ template: `
92
+ <virtual-scroller [items]="items">
93
+ <div LibsUiComponentsDragContainerDirective [items]="items">
94
+ <div *ngFor="let item of items"
95
+ LibsUiDragItemDirective
96
+ [item]="item"
97
+ [itemInContainerVirtualScroll]="true"
98
+ [fieldId]="'id'">
99
+ {{ item.name }}
100
+ </div>
101
+ </div>
102
+ </virtual-scroller>
103
+ `
104
+ })
105
+ ```
106
+
107
+ ### 3. Custom Drag Boundaries
108
+
109
+ ```typescript
110
+ @Component({
111
+ template: `
112
+ <div class="boundary-container">
113
+ <div LibsUiComponentsDragContainerDirective
114
+ [items]="items"
115
+ [dragBoundary]="true">
116
+ <div *ngFor="let item of items"
117
+ LibsUiDragItemDirective
118
+ [item]="item"
119
+ [dragBoundary]="true">
120
+ {{ item.name }}
121
+ </div>
122
+ </div>
123
+ </div>
124
+ `,
125
+ styles: [`
126
+ .boundary-container {
127
+ position: relative;
128
+ width: 500px;
129
+ height: 500px;
130
+ border: 2px solid #333;
131
+ }
132
+ `]
133
+ })
134
+ ```
135
+
136
+ ## Configuration Options
137
+
138
+ ### Container Directive
139
+
140
+ | Property | Type | Default | Description |
141
+ |----------|------|---------|-------------|
142
+ | `mode` | 'move' \| 'copy' \| 'deepCopy' | 'move' | Drag operation mode |
143
+ | `directionDrag` | 'horizontal' \| 'vertical' | undefined | Drag direction |
144
+ | `groupName` | string | 'groupDragAndDropDefault' | Group identifier |
145
+ | `dropToGroupName` | string[] | null | Allowed drop targets |
146
+ | `disableDragContainer` | boolean | false | Disable drag functionality |
147
+ | `placeholder` | boolean | true | Show placeholder during drag |
148
+
149
+ ### Item Directive
150
+
151
+ | Property | Type | Default | Description |
152
+ |----------|------|---------|-------------|
153
+ | `fieldId` | string | '' | Item identifier field |
154
+ | `item` | any | undefined | Item data |
155
+ | `itemInContainerVirtualScroll` | boolean | false | Enable virtual scroll support |
156
+ | `dragBoundary` | boolean | false | Restrict drag to container boundaries |
157
+ | `zIndex` | number | 1300 | Drag element z-index |
158
+
159
+ ## Events
160
+
161
+ ### Container Events
162
+
163
+ ```typescript
164
+ @Component({
165
+ template: `
166
+ <div LibsUiComponentsDragContainerDirective
167
+ (outDragStartContainer)="onDragStart($event)"
168
+ (outDragOverContainer)="onDragOver($event)"
169
+ (outDragLeaveContainer)="onDragLeave($event)"
170
+ (outDragEndContainer)="onDragEnd($event)"
171
+ (outDroppedContainer)="onDrop($event)">
172
+ <!-- Items -->
173
+ </div>
174
+ `
175
+ })
176
+ ```
177
+
178
+ ### Item Events
179
+
180
+ ```typescript
181
+ @Component({
182
+ template: `
183
+ <div LibsUiDragItemDirective
184
+ (outDragStart)="onItemDragStart($event)"
185
+ (outDragOver)="onItemDragOver($event)"
186
+ (outDragLeave)="onItemDragLeave($event)"
187
+ (outDragEnd)="onItemDragEnd($event)"
188
+ (outDropped)="onItemDrop($event)">
189
+ <!-- Item content -->
190
+ </div>
191
+ `
192
+ })
193
+ ```
194
+
195
+ ## Interfaces
196
+
197
+ ### Event Interfaces
198
+
199
+ ```typescript
200
+ interface IDragging {
201
+ mousePosition: IMousePosition;
202
+ elementDrag: HTMLElement;
203
+ elementKeepContainer?: boolean;
204
+ itemDragInfo?: IItemDragInfo;
205
+ }
206
+
207
+ interface IDragStart {
208
+ mousePosition: IMousePosition;
209
+ elementDrag: HTMLElement;
210
+ itemDragInfo?: IItemDragInfo;
211
+ }
212
+
213
+ interface IDragOver {
214
+ mousePosition: IMousePosition;
215
+ elementDrag: HTMLElement;
216
+ elementDragOver: HTMLElement;
217
+ itemDragInfo?: IItemDragInfo;
218
+ }
219
+
220
+ interface IDragLeave {
221
+ elementDrag: HTMLElement;
222
+ elementDragLeave: HTMLElement;
223
+ itemDragInfo?: IItemDragInfo;
224
+ }
225
+
226
+ interface IDragEnd {
227
+ mousePosition: IMousePosition;
228
+ elementDrag: HTMLElement;
229
+ itemDragInfo?: IItemDragInfo;
230
+ }
231
+
232
+ interface IDrop {
233
+ elementDrag: HTMLElement;
234
+ elementDrop: HTMLElement;
235
+ itemDragInfo?: IItemDragInfo;
236
+ }
237
+
238
+ interface IItemDragInfo {
239
+ item: object;
240
+ itemsMove?: WritableSignal<Array<unknown>>;
241
+ indexDrag?: number;
242
+ indexDrop?: number;
243
+ itemsDrag: WritableSignal<Array<unknown>>;
244
+ itemsDrop?: WritableSignal<Array<unknown>>;
245
+ containerDrag?: HTMLElement;
246
+ containerDrop?: HTMLElement;
247
+ }
248
+
249
+ interface IDragItemInContainerVirtualScroll {
250
+ itemDragInfo?: IItemDragInfo;
251
+ elementDrag: HTMLElement;
252
+ distanceStartElementAndMouseTop: number;
253
+ distanceStartElementAndMouseLeft: number;
254
+ elementContainer?: HTMLElement;
255
+ dragBoundary?: boolean;
256
+ dragBoundaryAcceptMouseLeaveContainer?: boolean;
257
+ ignoreStopEvent?: boolean;
258
+ }
259
+
260
+ interface IMousePosition {
261
+ clientX: number;
262
+ clientY: number;
263
+ }
264
+
265
+ interface IDragDropFunctionControlEvent {
266
+ setAttributeElementAndItemDrag: () => Promise<void>;
267
+ }
268
+ ```
269
+
270
+ ## Styling
271
+
272
+ ### Default Classes
273
+
274
+ ```css
275
+ /* Container */
276
+ .libs-ui-drag-drop-container {
277
+ position: relative;
278
+ min-height: 100px;
279
+ }
280
+
281
+ /* Item */
282
+ .libs-ui-drag-drop-item {
283
+ cursor: move;
284
+ transition: transform 0.2s;
285
+ }
286
+
287
+ /* Dragging */
288
+ .libs-ui-drag-drop-item-dragging {
289
+ opacity: 0.8;
290
+ box-shadow: 0 2px 5px rgba(0,0,0,0.2);
291
+ }
292
+
293
+ /* Placeholder */
294
+ .libs-ui-drag-drop-item-placeholder {
295
+ background: #f0f0f0;
296
+ border: 2px dashed #ccc;
297
+ }
298
+ ```
299
+
300
+ ### Custom Styling
301
+
302
+ ```typescript
303
+ @Component({
304
+ template: `
305
+ <div LibsUiComponentsDragContainerDirective
306
+ [stylesOverride]="customStyles">
307
+ <!-- Items -->
308
+ </div>
309
+ `
310
+ })
311
+ export class CustomStyledComponent {
312
+ customStyles = [
313
+ {
314
+ className: 'custom-container',
315
+ styles: `
316
+ .custom-container {
317
+ background: #f5f5f5;
318
+ border-radius: 8px;
319
+ padding: 15px;
320
+ }
321
+ `
322
+ }
323
+ ];
324
+ }
325
+ ```
326
+
327
+ ## Best Practices
328
+
329
+ 1. **Performance Optimization**
330
+ - Use virtual scrolling for lists with more than 100 items
331
+ - Implement proper event throttling
332
+ - Clean up event listeners in ngOnDestroy
333
+
334
+ 2. **User Experience**
335
+ - Provide clear visual feedback during drag operations
336
+ - Implement smooth animations
337
+ - Handle edge cases (container boundaries, scrolling)
338
+
339
+ 3. **Accessibility**
340
+ - Ensure keyboard navigation support
341
+ - Provide proper ARIA labels
342
+ - Support screen readers
343
+
344
+ ## Troubleshooting
345
+
346
+ ### Common Issues
347
+
348
+ 1. **Drag Not Working**
349
+ - Verify container and item configurations
350
+ - Check event bindings
351
+ - Ensure proper group settings
352
+
353
+ 2. **Performance Issues**
354
+ - Implement virtual scrolling
355
+ - Use event throttling
356
+ - Optimize event handlers
357
+
358
+ 3. **Container Boundaries**
359
+ - Verify dragBoundary settings
360
+ - Check container dimensions
361
+ - Ensure proper event handling
362
+
363
+ ## Examples
364
+
365
+ ### Basic List
366
+
367
+ ```typescript
368
+ @Component({
369
+ template: `
370
+ <div class="list-container">
371
+ <div LibsUiComponentsDragContainerDirective [items]="items">
372
+ <div *ngFor="let item of items"
373
+ class="list-item"
374
+ LibsUiDragItemDirective
375
+ [item]="item">
376
+ <span class="item-icon">📋</span>
377
+ <span class="item-text">{{ item.name }}</span>
378
+ </div>
379
+ </div>
380
+ </div>
381
+ `,
382
+ styles: [`
383
+ .list-container {
384
+ max-width: 400px;
385
+ margin: 20px auto;
386
+ }
387
+ .list-item {
388
+ padding: 10px;
389
+ margin: 5px 0;
390
+ background: white;
391
+ border: 1px solid #ddd;
392
+ border-radius: 4px;
393
+ display: flex;
394
+ align-items: center;
395
+ }
396
+ .item-icon {
397
+ margin-right: 10px;
398
+ }
399
+ `]
400
+ })
401
+ ```
402
+
403
+ ### Kanban Board
404
+
405
+ ```typescript
406
+ @Component({
407
+ template: `
408
+ <div class="kanban-board">
409
+ <div *ngFor="let column of columns"
410
+ class="kanban-column"
411
+ LibsUiComponentsDragContainerDirective
412
+ [items]="column.items"
413
+ [groupName]="column.id">
414
+ <h3>{{ column.title }}</h3>
415
+ <div *ngFor="let item of column.items"
416
+ class="kanban-item"
417
+ LibsUiDragItemDirective
418
+ [item]="item">
419
+ {{ item.title }}
420
+ </div>
421
+ </div>
422
+ </div>
423
+ `,
424
+ styles: [`
425
+ .kanban-board {
426
+ display: flex;
427
+ gap: 20px;
428
+ padding: 20px;
429
+ }
430
+ .kanban-column {
431
+ flex: 1;
432
+ background: #f5f5f5;
433
+ padding: 15px;
434
+ border-radius: 8px;
435
+ }
436
+ .kanban-item {
437
+ background: white;
438
+ padding: 10px;
439
+ margin: 5px 0;
440
+ border-radius: 4px;
441
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
442
+ }
443
+ `]
444
+ })
445
+ ```
@@ -0,0 +1,56 @@
1
+ import * as i0 from "@angular/core";
2
+ interface Task {
3
+ id: number;
4
+ title: string;
5
+ description: string;
6
+ status: 'todo' | 'in-progress' | 'done';
7
+ }
8
+ interface Column {
9
+ id: string;
10
+ title: string;
11
+ items: Task[];
12
+ }
13
+ export declare class LibsUiDragDropDemoComponent {
14
+ basicItems: string[];
15
+ columnsIds: string[];
16
+ columns: Column[];
17
+ nestedItems: {
18
+ id: number;
19
+ title: string;
20
+ subItems: string[];
21
+ }[];
22
+ inputsDoc: {
23
+ name: string;
24
+ type: string;
25
+ default: string;
26
+ description: string;
27
+ }[];
28
+ outputsDoc: {
29
+ name: string;
30
+ type: string;
31
+ description: string;
32
+ }[];
33
+ interfacesDoc: {
34
+ name: string;
35
+ code: string;
36
+ description: string;
37
+ }[];
38
+ features: {
39
+ id: number;
40
+ icon: string;
41
+ title: string;
42
+ description: string;
43
+ }[];
44
+ codeExamples: {
45
+ id: number;
46
+ title: string;
47
+ code: string;
48
+ }[];
49
+ /**
50
+ * Copy text to clipboard
51
+ */
52
+ copyToClipboard(text: string): void;
53
+ static ɵfac: i0.ɵɵFactoryDeclaration<LibsUiDragDropDemoComponent, never>;
54
+ static ɵcmp: i0.ɵɵComponentDeclaration<LibsUiDragDropDemoComponent, "lib-drag-drop-demo", never, {}, {}, never, never, true, never>;
55
+ }
56
+ export {};
@@ -12,7 +12,6 @@ export declare class LibsUiDragItemDirective extends LibsUiDragItemInContainerVi
12
12
  readonly ignoreStopEvent: import("@angular/core").InputSignal<boolean | undefined>;
13
13
  readonly onlyMouseDownStopEvent: import("@angular/core").InputSignal<boolean | undefined>;
14
14
  readonly dragRootElement: import("@angular/core").InputSignal<boolean | undefined>;
15
- readonly groupName: import("@angular/core").InputSignalWithTransform<string, string | undefined>;
16
15
  readonly dragBoundary: import("@angular/core").InputSignal<boolean | undefined>;
17
16
  readonly dragBoundaryAcceptMouseLeaveContainer: import("@angular/core").InputSignal<boolean | undefined>;
18
17
  readonly elementContainer: import("@angular/core").InputSignal<HTMLElement | undefined>;
@@ -27,5 +26,5 @@ export declare class LibsUiDragItemDirective extends LibsUiDragItemInContainerVi
27
26
  constructor();
28
27
  ngAfterViewInit(): void;
29
28
  static ɵfac: i0.ɵɵFactoryDeclaration<LibsUiDragItemDirective, never>;
30
- static ɵdir: i0.ɵɵDirectiveDeclaration<LibsUiDragItemDirective, "[LibsUiDragItemDirective]", never, { "fieldId": { "alias": "fieldId"; "required": false; "isSignal": true; }; "item": { "alias": "item"; "required": false; "isSignal": true; }; "itemInContainerVirtualScroll": { "alias": "itemInContainerVirtualScroll"; "required": false; "isSignal": true; }; "throttleTimeHandlerDraggingEvent": { "alias": "throttleTimeHandlerDraggingEvent"; "required": false; "isSignal": true; }; "ignoreStopEvent": { "alias": "ignoreStopEvent"; "required": false; "isSignal": true; }; "onlyMouseDownStopEvent": { "alias": "onlyMouseDownStopEvent"; "required": false; "isSignal": true; }; "dragRootElement": { "alias": "dragRootElement"; "required": false; "isSignal": true; }; "groupName": { "alias": "groupName"; "required": false; "isSignal": true; }; "dragBoundary": { "alias": "dragBoundary"; "required": false; "isSignal": true; }; "dragBoundaryAcceptMouseLeaveContainer": { "alias": "dragBoundaryAcceptMouseLeaveContainer"; "required": false; "isSignal": true; }; "elementContainer": { "alias": "elementContainer"; "required": false; "isSignal": true; }; "zIndex": { "alias": "zIndex"; "required": false; "isSignal": true; }; "disable": { "alias": "disable"; "required": false; "isSignal": true; }; }, { "outDragStart": "outDragStart"; "outDragOver": "outDragOver"; "outDragLeave": "outDragLeave"; "outDragEnd": "outDragEnd"; "outDropped": "outDropped"; }, never, never, true, never>;
29
+ static ɵdir: i0.ɵɵDirectiveDeclaration<LibsUiDragItemDirective, "[LibsUiDragItemDirective]", never, { "fieldId": { "alias": "fieldId"; "required": false; "isSignal": true; }; "item": { "alias": "item"; "required": false; "isSignal": true; }; "itemInContainerVirtualScroll": { "alias": "itemInContainerVirtualScroll"; "required": false; "isSignal": true; }; "throttleTimeHandlerDraggingEvent": { "alias": "throttleTimeHandlerDraggingEvent"; "required": false; "isSignal": true; }; "ignoreStopEvent": { "alias": "ignoreStopEvent"; "required": false; "isSignal": true; }; "onlyMouseDownStopEvent": { "alias": "onlyMouseDownStopEvent"; "required": false; "isSignal": true; }; "dragRootElement": { "alias": "dragRootElement"; "required": false; "isSignal": true; }; "dragBoundary": { "alias": "dragBoundary"; "required": false; "isSignal": true; }; "dragBoundaryAcceptMouseLeaveContainer": { "alias": "dragBoundaryAcceptMouseLeaveContainer"; "required": false; "isSignal": true; }; "elementContainer": { "alias": "elementContainer"; "required": false; "isSignal": true; }; "zIndex": { "alias": "zIndex"; "required": false; "isSignal": true; }; "disable": { "alias": "disable"; "required": false; "isSignal": true; }; }, { "outDragStart": "outDragStart"; "outDragOver": "outDragOver"; "outDragLeave": "outDragLeave"; "outDragEnd": "outDragEnd"; "outDropped": "outDropped"; }, never, never, true, never>;
31
30
  }