Skip to content

Commit d14b101

Browse files
committed
fix: Publish under @angular-skyhook/* scope
1 parent 4709c4b commit d14b101

File tree

167 files changed

+1843
-855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1843
-855
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
<a name="1.0.10"></a>
7+
## [1.0.10](https://github.com/cormacrelf/angular-skyhook/compare/v1.0.9...v1.0.10) (2018-09-01)
8+
9+
10+
### Bug Fixes
11+
12+
* simplify yarn add suggestion ([a6e0023](https://github.com/cormacrelf/angular-skyhook/commit/a6e0023))
13+
* **package:** shouldn't ever have supported Angular 5, without rxjs 6. Bump both peerdeps to 6, + tslib. ([734d66e](https://github.com/cormacrelf/angular-skyhook/commit/734d66e))
14+
* **package:** switch to scoped packages, i.e. [@angular-skyhook](https://github.com/skyhook)/core ([874723a](https://github.com/cormacrelf/angular-skyhook/commit/874723a))
15+
* **package:** update react-dnd-touch-backend to version 0.5.1 ([244e71c](https://github.com/cormacrelf/angular-skyhook/commit/244e71c)), closes [#11](https://github.com/cormacrelf/angular-skyhook/issues/11)
16+
17+
18+
19+
20+
121
<a name="1.0.9"></a>
222
## [1.0.9](https://github.com/cormacrelf/angular-skyhook/compare/v1.0.8...v1.0.9) (2018-07-04)
323

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[![Build Status](https://travis-ci.org/cormacrelf/angular-skyhook.svg?branch=master)](https://travis-ci.org/cormacrelf/angular-skyhook)
2-
[![npm](https://img.shields.io/npm/v/angular-skyhook.svg)](https://www.npmjs.com/package/angular-skyhook)
2+
[![npm](https://img.shields.io/npm/v/@angular-skyhook/core.svg)](https://www.npmjs.com/package/@angular-skyhook/core)
33
[![Documentation coverage](https://cormacrelf.github.io/angular-skyhook/images/coverage-badge.svg)](https://cormacrelf.github.io/angular-skyhook/coverage.html)
44

5-
# angular-skyhook
5+
# `@angular-skyhook`
66

77
`react-dnd`-style drag and drop for Angular, built on
88
[`dnd-core`](https://github.com/react-dnd/react-dnd).

build-docs.sh

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
pkg="angular-skyhook"
4-
53
usage () {
64
echo "usage: $0 [--serve] [--serve-only] [--no-examples] [--port <default is 8080>]"
75
}
@@ -21,6 +19,7 @@ serve() {
2119
SERVE=0
2220
SERVE_ONLY=0
2321
PORT=8080
22+
NO_EXAMPLES=0
2423

2524
if [ -n "$TRAVIS" ]; then
2625
SERVE=0
@@ -46,6 +45,9 @@ else
4645
--serve-only)
4746
SERVE_ONLY=1
4847
;;
48+
--no-examples)
49+
NO_EXAMPLES=1
50+
;;
4951
--port)
5052
PORT=$2
5153
shift
@@ -66,12 +68,13 @@ fi
6668

6769
DIR=$(dirname "$0")
6870
output="$DIR/out-docs"
69-
skyhook="$DIR/packages/angular-skyhook"
70-
multi_backend="$DIR/packages/angular-skyhook-multi-backend"
71+
core="$DIR/packages/core"
72+
sortable="$DIR/packages/sortable"
73+
multi_backend="$DIR/packages/multi-backend"
7174
examples="$DIR/packages/examples"
7275

7376
EXAMPLES_TASK="local-docs"
74-
if [ $TRAVIS == "true" ]; then
77+
if [ "$TRAVIS" == "true" ]; then
7578
EXAMPLES_TASK="gh-pages"
7679
fi
7780

@@ -90,24 +93,30 @@ build() {
9093
set -euxo pipefail
9194

9295
rm -rf out-docs
93-
rm -rf "$skyhook/documentation"
96+
rm -rf "$core/documentation"
9497

95-
(cd "$skyhook" && yarn run docs)
98+
(cd "$core" && yarn run docs)
9699

97100
# move main docs into output
98-
(mv "$skyhook/documentation" "$output")
101+
(mv "$core/documentation" "$output")
102+
103+
# build sortable docs
104+
(cd "$sortable" && yarn run docs)
105+
106+
# move multi-backend into output
107+
(mv "$sortable/documentation" "$output/sortable")
99108

100109
# build multi-backend docs
101-
(cd $multi_backend && yarn run docs)
110+
(cd "$multi_backend" && yarn run docs)
102111

103112
# move multi-backend into output
104-
(mv "$multi_backend/documentation" "$output/angular-skyhook-multi-backend")
113+
(mv "$multi_backend/documentation" "$output/multi-backend")
105114

106115
# build examples
107-
(cd "$examples" && yarn run $EXAMPLES_TASK)
116+
[ $NO_EXAMPLES -ne 1 ] && (cd "$examples" && yarn run $EXAMPLES_TASK)
108117

109118
# move examples into output
110-
(mv "$examples/dist/examples" "$output/examples")
119+
[ $NO_EXAMPLES -ne 1 ] && (mv "$examples/dist/examples" "$output/examples")
111120

112121
: "built successfully"
113122
}

docs/Connecting-to-DOM.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,40 @@ a drag. Use `DragSourceDirective` to do this. It's as simple as:
1515
```
1616
```typescript
1717
source = this.dnd.dragSource("DRAGME", {
18-
beginDrag: () => ({}),
19-
// ...
20-
})
21-
// ...
18+
beginDrag: () => ({ name: 'Jones McFly' }),
19+
// other DragSourceSpec methods
20+
});
21+
// constructor, unsubscribe, etc
2222
```
2323

24+
Then, investigate using
25+
[DragSourceSpec](../../interfaces/DragSourceSpec.html)
26+
to customise the behaviour.
27+
2428
### Making a DOM element into a drop target
2529

2630
This means your element will react to items being hovered or dropped within its
2731
bounding rectangle.
2832

2933
```html
30-
<div [dragSource]="source">
31-
drag me
34+
<div [dropTarget]="target">
35+
drop on me
3236
</div>
3337
```
3438
```typescript
35-
source = this.dnd.dragSource("DRAGME", {
36-
beginDrag: () => ({}),
37-
// ...
39+
target = this.dnd.dropTarget("DRAGME", {
40+
drop: monitor => {
41+
console.log('dropped an item:', monitor.getItem()); // => { name: 'Jones McFly' }
42+
}
3843
})
39-
// ...
44+
// constructor, unsubscribe, etc
4045
```
4146

47+
Then, investigate using
48+
[DropTargetSpec](../../interfaces/DropTargetSpec.html)
49+
to customise the behaviour.
50+
51+
4252
## Drag previews
4353

4454
__This is a feature unique to the HTML5 backend.__ If you are using another

docs/Creating-Connections.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ You can create an RxJS `Subscription` object in your component, and call
9595
on each of the `SkyhookDndService` methods which will do this for you.
9696

9797
```typescript
98-
import { Subscription } from 'rxjs/Subscription';
98+
import { Subscription } from 'rxjs';
9999

100100
// ...
101101

docs/Guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
When using `angular-skyhook`, you follow this general pattern:
1+
When using `@angular-skyhook`, you follow this general pattern:
22

33
1. Create a connection and specify its behaviour: [Creating Connections](guide/1.-creating-connections.html)
44
2. Use directives or methods to connect it to real DOM elements:

docs/Monitoring-State.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,53 @@
22

33
## How to change your template depending on the drag state
44

5-
1. Take any connection object, like `DragSource`
5+
1. Take any connection object, like `DropTarget`
66
2. Call `.listen()` with a function that returns what information you want to
77
monitor
88
3. Save the resulting Observable to an instance variable in your component
99
4. Use the observable via the `| async` pipe to render alternate content in
1010
your template.
1111

12+
For example:
13+
14+
```html
15+
<div [dropTarget]="target"
16+
class="cat-target"
17+
[class.cat-target--hovering]="hovering$ | async">
18+
drop cats here
19+
</div>
20+
```
21+
22+
```scss
23+
.cat-target { background: #eee; }
24+
.cat-target--hovering { background: lightgoldenrodyellow; }
25+
```
26+
27+
```typescript
28+
target = this.dnd.dropTarget("CAT", {
29+
drop: monitor => {
30+
console.log('dropped a cat');
31+
}
32+
});
33+
34+
// this is a very useful combination on a drop target,
35+
// which expresses 'hovering over' + ('same type' + 'DropTargetSpec.canDrop returned true')
36+
// you almost always want to use the combination rather than isOver on its own
37+
hovering$ = this.target.listen(m => m.isOver() && m.canDrop());
38+
```
39+
40+
## What can you listen to?
41+
1242
Each type of connection gets a different set of information available on the
13-
monitor. They are laid out in the three interfaces in this module:
43+
monitor. They are laid out in these interfaces:
1444

1545
- [DragSourceMonitor](../../interfaces/DragSourceMonitor.html)
1646
- [DropTargetMonitor](../../interfaces/DropTargetMonitor.html)
1747
- [DragLayerMonitor](../../interfaces/DragLayerMonitor.html)
1848
- All three derive from [MonitorBase](../../interfaces/MonitorBase.html)
1949

50+
## Optimisation
51+
2052
Note that all three monitors have very rapidly-changing information available on
2153
them, such as the current viewport-mouse offset. The `.listen()` functions will
2254
optimise component updates for you. You **don't** want to:
@@ -25,6 +57,19 @@ optimise component updates for you. You **don't** want to:
2557
2. Subscribe to the entire monitor object. It will only fire once, and then
2658
never again, because the monitor object itself is the same each time.
2759

60+
The implementation of `listen()` includes an implementation of RxJS'
61+
`distinctUntilChanged` that also optimises for JS Objects with the same keys
62+
but different values. The following two examples fire exactly as often:
63+
64+
```typescript
65+
isDraggingPlain$ = this.source.listen(m => m.isDragging());
66+
isDraggingObj$ = this.source.listen(m => ({ isDragging: m.isDragging() }));
67+
```
68+
69+
This is helpful if you have a lot of properties to listen to and wish to
70+
reduce the number of `| async` pipes in your code, or if you want to copy
71+
some `react-dnd` code.
72+
2873
## Making decisions in the Spec based on current drag state
2974

3075
The other place you get access to a monitor is in the callbacks in each Spec.

docs/Quickstart.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
## Installation
22

33
```sh
4-
yarn add angular-skyhook react-dnd-html5-backend
4+
yarn add @angular-skyhook/core react-dnd-html5-backend
55
```
66

7-
You might consider `angular-skyhook-multi-backend` instead of the HTML5
7+
You might consider `@angular-skyhook/multi-backend` instead of the HTML5
88
backend, because it allows adding touch support as well.
99

1010
Then import `SkyhookDndModule` and provide the backend:
1111

1212

1313
```typescript
14-
import { SkyhookDndModule } from 'angular-skyhook';
14+
import { SkyhookDndModule } from "@angular-skyhook/core";
1515
import { default as HTML5Backend } from 'react-dnd-html5-backend'
1616

1717
@NgModule({
@@ -79,12 +79,12 @@ can let the browser render drag previews, when using a backend based on click
7979
or touch events, on mobile you have to render them yourself.
8080

8181
A good way to solve both problems at once is using
82-
[`angular-skyhook-multi-backend`][skyhook-multi]. It is based on the original
82+
[`@angular-skyhook/multi-backend`][skyhook-multi]. It is based on the original
8383
[dnd-multi-backend][dnd-multi-backend], which was designed to seamlessly switch
8484
between an HTML5 and a [touch backend][touch-backend] when it noticed different
85-
kinds of interaction. The Skyhook version includes a preview component.
85+
kinds of interaction. The `@angular-skyhook` version includes a preview component.
8686

87-
[skyhook-multi]: ../angular-skyhook-multi-backend/
87+
[skyhook-multi]: ../@angular-skyhook/multi-backend/
8888
Note also that you will need to use an exported function
8989
to provide the backend, to retain AOT compatibility, if it requires assembly.
9090
`MultiBackend`, for example, can be used like so:

docs/Translating-React-Code.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ documentation](http://react-dnd.github.io/react-dnd/docs-overview.html). In the
77
interest of making them useful or at least understandable, this library presents
88
a fairly similar API to the original. There are, of course, some differences
99
mandated by the style and limitations of React and Angular. We will illustrate
10-
this with the `react-dnd` `DragSource` compared to `angular-skyhook`
10+
this with the `react-dnd` `DragSource` compared to `@angular-skyhook`'s
1111
`SkyhookDndService.dragSource()`. Here are the [original API
1212
docs](http://react-dnd.github.io/react-dnd/docs-drag-source.html) on
1313
`DragSource`; the following is a small but complete example for a quick
@@ -173,7 +173,7 @@ asynchronous drag operations start. Angular doesn't have a way for arbitrary
173173
objects to listen to `ngOnChanges()`, so we have to do it manually.
174174

175175
You can supply a default type, or `null`, and update it in later as the
176-
`@Input()` property is populated. If you supply `null`, `angular-skyhook` will
176+
`@Input()` property is populated. If you supply `null`, `@angular-skyhook` will
177177
defer connecting the DOM and the subscription to the `monitor` until this is
178178
done. See `DragSource.setType` for more information.
179179

docs/Tutorial.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ value to any new subscribers. This is exactly what we want.
270270

271271
```typescript
272272
import { Injectable } from '@angular/core';
273-
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
273+
import { BehaviorSubject } from 'rxjs';
274274
import { Coord } from './coord';
275275

276276
@Injectable()
@@ -346,7 +346,7 @@ position. You can store the `currentPosition` by subscribing internally to
346346

347347
```typescript
348348
import { Injectable } from '@angular/core';
349-
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
349+
import { BehaviorSubject } from 'rxjs';
350350
import { Coord } from './coord';
351351

352352
@Injectable()
@@ -446,7 +446,7 @@ Here's all four in one go:
446446

447447
```typescript
448448
import { Component } from '@angular/core';
449-
import { SkyhookDndService } from 'angular-skyhook';
449+
import { SkyhookDndService } from "@angular-skyhook/core";
450450
import { ItemTypes } from './constants';
451451

452452
@Component({
@@ -506,7 +506,7 @@ isDragging$ = this.knightSource.listen(monitor => monitor.isDragging());
506506

507507
Now, the knight on the board will be a bit transparent when you've picked it up.
508508
You could set it to `opacity: 0`, but in chess, players like to know where the
509-
piece came from. `angular-skyhook` makes no assumptions about how to render
509+
piece came from. `@angular-skyhook` makes no assumptions about how to render
510510
any elements, so you can always customise their appearance at any stage of the
511511
drag and drop process.
512512

@@ -569,7 +569,7 @@ to that wrapper `div`. It's very similar to the drag source.
569569

570570
```typescript
571571
import { Component, Input } from "@angular/core";
572-
import { SkyhookDndService } from 'angular-skyhook';
572+
import { SkyhookDndService } from "@angular-skyhook/core";
573573
import { ItemTypes } from "./constants";
574574

575575
@Component({
@@ -717,7 +717,7 @@ Here's what it looks like:
717717
![Visual guides and a horse preview image](../media/guides-nohorse.png)
718718

719719
Lastly, we're going to customize the drag preview (that little knight that
720-
follows the mouse around). `angular-skyhook` has some very powerful ways to
720+
follows the mouse around). `@angular-skyhook` has some very powerful ways to
721721
customize this, but we're going to use a simple image. It's quite simple:
722722

723723
1. Create an [`Image`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image)

0 commit comments

Comments
 (0)