Socket
Socket
Sign inDemoInstall

@ryware/ngx-drag-and-drop-lists

Package Overview
Dependencies
5
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.2 to 2.0.3

2

package.json
{
"name": "@ryware/ngx-drag-and-drop-lists",
"version": "2.0.2",
"version": "2.0.3",
"private": false,

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -1,24 +0,139 @@

# NgxDragAndDropLists
ngx-drag-and-drop-lists
===========================
Angular directives that allow you to build sortable lists with the native HTML5 drag & drop API. The directives can also be nested to bring drag & drop to your WYSIWYG editor, your tree, or whatever fancy structure you are building.
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.1.0.
### [Demo](https://stackblitz.com/edit/ngx-drag-and-drop-lists/)
## Code scaffolding
### [NPM Package](https://www.npmjs.com/package/@ryware/ngx-drag-and-drop-lists)
Run `ng generate component component-name --project ngx-drag-and-drop-lists` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-drag-and-drop-lists`.
> Note: Don't forget to add `--project ngx-drag-and-drop-lists` or else it will be added to the default project in your `angular.json` file.
`npm install @ryware/ngx-drag-and-drop-lists`
## Build
## Credits to the original creator
This library is inspired by the https://github.com/marceljuenemann/angular-drag-and-drop-lists library which was written in AngularJS.
Run `ng build ngx-drag-and-drop-lists` to build the project. The build artifacts will be stored in the `dist/` directory.
**Drag Element Inputs**
* `dndDraggable` Required attribute. Signifies that this element is part of the dndDraggable. Can receive options on how to behave of the following type:
```
interface DndDraggableConfig {
draggable: boolean;
effectAllowed: 'move' | 'copy' | 'link';
}
```
## Publishing
* `dndObject` Required attribute. Represents the object that is actually dragged, the data.
After building your library with `ng build ngx-drag-and-drop-lists`, go to the dist folder `cd dist/ngx-drag-and-drop-lists` and run `npm publish`.
* `dndType` Required attribute. Tells what is the type of the data
## Running unit tests
* `dndDragDisabled` Tells whether the drag ability is disabled or not
Run `ng test ngx-drag-and-drop-lists` to execute the unit tests via [Karma](https://karma-runner.github.io).
**Drag Element Outputs**
## Further help
* `dndDragStart` An event that fires when a drag starts
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.
* `dndDragEnd` An event that fires when a drag ends
* `dndCopied` An event that fires when a copy effect happens
* `dndMoved` An event that fires when a move effect happens
* `dndLinked` An event that fires when a link effect happens
* `dndCanceled` An event that fires when a drag cancels
* `dndSelected` An event that fires when an element is clicked and not dragged
**CSS classes**
* `dndDragging` This class will be added to the element while the element is being dragged. It will affect both the element you see while dragging and the source element that stays at it's position. Do not try to hide the source element with this class, because that will abort the drag operation.
* `dndDraggingSource` This class will be added to the element after the drag operation was started, meaning it only affects the original element that is still at it's source position, and not the "element" that the user is dragging with his mouse pointer
**Drag List Inputs**
* `dndList` Required attribute. Signifies that this list is part of the dndList. Can receive options on how to behave of the following type:
```
interface DndListSettings {
allowedTypes: string[];
effectAllowed: 'move' | 'copy' | 'link';
disabled: boolean;
externalSources: boolean;
horizontal: boolean;
}
```
* `dndModel` Required attribute. The array that holds the objects
* `dndPlaceholder` An element that should be displayed as a placeholder before a drag.
**Drag Element Outputs**
* `dndDragOver` An event that fires when an element is dragged over a list
* `dndDrop` An event that fires when an element is dropped upon a list
* `dndInserted` An event that happens after a drop if the object was actually inserted
**CSS classes**
* `dndDragover` This class will be added to the list while an element is being dragged over the list.
**dndNoDrag attribute**
Use the `dndNoDrag` attribute inside of `dndDraggable` elements to prevent them from starting drag operations. This is especially useful if you want to use input elements inside of `dndDraggable` elements or create specific handle elements.
**dndHandle attribute**
Use the `dndHandle` directive within a `dndNoDrag` element in order to allow dragging of that element after all. Therefore, by combining `dndNoDrag` and `dndHandle` you can allow `dndDraggable` elements to only be dragged via specific *handle* elements.
**Example 1**
```
<div *ngFor="let list of models.lists;let i = index">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">List {{i}}</h3>
</div>
<div class="panel-body">
<ul [dndList]
[dndModel]="list">
<li *ngFor="let item of list;let i = index"
[dndDraggable]
[dndType]="'item'"
[dndObject]="item"
(dndMoved)="removeMovedItem(i, list)"
[class.selected]="models.selected === item">
{{item.label}}
</li>
</ul>
</div>
</div>
```
**Example 2**
```
<div *ngFor="let list of models.lists;let i = index">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">List {{i}}</h3>
</div>
<div class="panel-body">
<ul [dndList]="{
disabled: false,
effectAllowed: 'move',
allowedTypes: ['item']}"
[dndModel]="list">
<li *ngFor="let item of list;let i = index"
[dndType]="'item'"
[dndDraggable]="{draggable:true, effectAllowed:'move'}"
[dndObject]="item"
(dndMoved)="removeMovedItem(i, list)"
(dndSelected)="log('selected')"
[class.selected]="models.selected === item">
{{item.label}}
</li>
</ul>
</div>
</div>
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc