@helpdice/draggable 0.0.1 → 0.0.3
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 +15 -15
- package/dist/draggable.cjs.js +23 -13
- package/dist/draggable.cjs.js.map +1 -1
- package/dist/draggable.esm.js +23 -13
- package/dist/draggable.esm.js.map +1 -1
- package/dist/types/state/droppable/get-droppable.d.ts +2 -2
- package/dist/types/types.d.ts +5 -5
- package/dist/types/view/context/droppable-context.d.ts +2 -2
- package/dist/types/view/droppable/droppable-types.d.ts +7 -7
- package/dist/types/view/use-droppable-publisher/get-dimension.d.ts +3 -3
- package/dist/types/view/use-droppable-publisher/use-droppable-publisher.d.ts +7 -7
- package/package.json +1 -1
- package/src/state/droppable/get-droppable.ts +2 -2
- package/src/state/middleware/responders/publisher.ts +4 -4
- package/src/types.ts +5 -5
- package/src/view/context/droppable-context.ts +2 -2
- package/src/view/draggable/draggable.tsx +1 -1
- package/src/view/droppable/connected-droppable.tsx +4 -4
- package/src/view/droppable/droppable-types.ts +7 -7
- package/src/view/use-droppable-publisher/get-dimension.ts +3 -3
- package/src/view/use-droppable-publisher/use-droppable-publisher.ts +11 -11
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ We recommend that you don’t raise issues or pull requests, as they will not be
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
|
-
<img src="https://user-images.githubusercontent.com/2182637/53611918-54c1ff80-3c24-11e9-9917-66ac3cef513d.png" alt="
|
|
13
|
+
<img src="https://user-images.githubusercontent.com/2182637/53611918-54c1ff80-3c24-11e9-9917-66ac3cef513d.png" alt="draggable logo" />
|
|
14
14
|
</p>
|
|
15
|
-
<h1 align="center">
|
|
15
|
+
<h1 align="center">draggable <small><sup>(rbd)</sup></small></h1>
|
|
16
16
|
|
|
17
17
|
<div align="center">
|
|
18
18
|
|
|
@@ -32,9 +32,9 @@ We recommend that you don’t raise issues or pull requests, as they will not be
|
|
|
32
32
|
|
|
33
33
|
## Get started 👩🏫
|
|
34
34
|
|
|
35
|
-
We have created [a free course on `egghead.io` 🥚](https://egghead.io/courses/beautiful-and-accessible-drag-and-drop-with
|
|
35
|
+
We have created [a free course on `egghead.io` 🥚](https://egghead.io/courses/beautiful-and-accessible-drag-and-drop-with-@helpdice/draggable) to help you get started with `@helpdice/draggable` as quickly as possible.
|
|
36
36
|
|
|
37
|
-
[](https://egghead.io/courses/beautiful-and-accessible-drag-and-drop-with
|
|
37
|
+
[](https://egghead.io/courses/beautiful-and-accessible-drag-and-drop-with-@helpdice/draggable)
|
|
38
38
|
|
|
39
39
|
## Currently supported feature set ✅
|
|
40
40
|
|
|
@@ -64,14 +64,14 @@ We have created [a free course on `egghead.io` 🥚](https://egghead.io/courses/
|
|
|
64
64
|
|
|
65
65
|
## Motivation 🤔
|
|
66
66
|
|
|
67
|
-
`
|
|
67
|
+
`@helpdice/draggable` exists to create beautiful drag and drop for lists that anyone can use - even people who cannot see. For a good overview of the history and motivations of the project you can take a look at these external resources:
|
|
68
68
|
|
|
69
69
|
- 📖 [Rethinking drag and drop](https://medium.com/@alexandereardon/rethinking-drag-and-drop-d9f5770b4e6b)
|
|
70
70
|
- 🎧 [React podcast: fast, accessible and beautiful drag and drop](https://reactpodcast.simplecast.fm/17)
|
|
71
71
|
|
|
72
72
|
## Not for everyone ✌️
|
|
73
73
|
|
|
74
|
-
There are a lot of libraries out there that allow for drag and drop interactions within React. Most notable of these is the amazing [`react-dnd`](https://github.com/react-dnd/react-dnd). It does an incredible job at providing a great set of drag and drop primitives which work especially well with the [wildly inconsistent](https://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html) html5 drag and drop feature. `
|
|
74
|
+
There are a lot of libraries out there that allow for drag and drop interactions within React. Most notable of these is the amazing [`react-dnd`](https://github.com/react-dnd/react-dnd). It does an incredible job at providing a great set of drag and drop primitives which work especially well with the [wildly inconsistent](https://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html) html5 drag and drop feature. `@helpdice/draggable` is a higher level abstraction specifically built for lists (vertical, horizontal, movement between lists, nested lists and so on). Within that subset of functionality `@helpdice/draggable` offers a powerful, natural and beautiful drag and drop experience. However, it does not provide the breadth of functionality offered by `react-dnd`. So `@helpdice/draggable` might not be for you depending on what your use case is.
|
|
75
75
|
|
|
76
76
|
## Documentation 📖
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ There are a lot of libraries out there that allow for drag and drop interactions
|
|
|
79
79
|
|
|
80
80
|
- [Installation](/docs/about/installation.md)
|
|
81
81
|
- [Examples and samples](/docs/about/examples.md)
|
|
82
|
-
- [Get started](https://egghead.io/courses/beautiful-and-accessible-drag-and-drop-with-
|
|
82
|
+
- [Get started](https://egghead.io/courses/beautiful-and-accessible-drag-and-drop-with-draggable)
|
|
83
83
|
- [Design principles](/docs/about/design-principles.md)
|
|
84
84
|
- [Animations](/docs/about/animations.md)
|
|
85
85
|
- [Accessibility](/docs/about/accessibility.md)
|
|
@@ -121,7 +121,7 @@ There are a lot of libraries out there that allow for drag and drop interactions
|
|
|
121
121
|
- [Avoiding image flickering](/docs/guides/avoiding-image-flickering.md)
|
|
122
122
|
- [Non-visible preset styles](/docs/guides/preset-styles.md)
|
|
123
123
|
- [How we detect scroll containers](/docs/guides/how-we-detect-scroll-containers.md)
|
|
124
|
-
- [How we use dom events](/docs/guides/how-we-use-dom-events.md) - _Useful if you need to build on top of `
|
|
124
|
+
- [How we use dom events](/docs/guides/how-we-use-dom-events.md) - _Useful if you need to build on top of `@helpdice/draggable`_
|
|
125
125
|
- [Adding `<Draggable />`s during a drag (11.x behaviour)](/docs/guides/changes-while-dragging.md) - _⚠️ Advanced_
|
|
126
126
|
- [Setting up Content Security Policy](/docs/guides/content-security-policy.md)
|
|
127
127
|
|
|
@@ -136,18 +136,18 @@ There are a lot of libraries out there that allow for drag and drop interactions
|
|
|
136
136
|
|
|
137
137
|
- [Engineering health](/docs/support/engineering-health.md)
|
|
138
138
|
- [Community and addons](/docs/support/community-and-addons.md)
|
|
139
|
-
- [Release notes and changelog](https://github.com/atlassian/
|
|
139
|
+
- [Release notes and changelog](https://github.com/atlassian/@helpdice/draggable/releases)
|
|
140
140
|
- [Upgrading](/docs/support/upgrading.md)
|
|
141
|
-
- [Road map](https://github.com/atlassian/
|
|
141
|
+
- [Road map](https://github.com/atlassian/@helpdice/draggable/issues)
|
|
142
142
|
- [Media](/docs/support/media.md)
|
|
143
143
|
|
|
144
144
|
## Read this in other languages 🌎
|
|
145
145
|
|
|
146
|
-
- [ **한글/Korean**](https://github.com/LeeHyungGeun/
|
|
147
|
-
- [ **На русском/Russian**](https://github.com/vtereshyn/
|
|
148
|
-
- [ **Português/Portuguese**](https://github.com/dudestein/
|
|
149
|
-
- [ **Ελληνικά/Greek**](https://github.com/milvard/
|
|
150
|
-
- [ **日本語/Japanese**](https://github.com/eltociear/
|
|
146
|
+
- [ **한글/Korean**](https://github.com/LeeHyungGeun/@helpdice/draggable-kr)
|
|
147
|
+
- [ **На русском/Russian**](https://github.com/vtereshyn/@helpdice/draggable-ru)
|
|
148
|
+
- [ **Português/Portuguese**](https://github.com/dudestein/@helpdice/draggable-pt)
|
|
149
|
+
- [ **Ελληνικά/Greek**](https://github.com/milvard/@helpdice/draggable-gr)
|
|
150
|
+
- [ **日本語/Japanese**](https://github.com/eltociear/@helpdice/draggable-ja)
|
|
151
151
|
|
|
152
152
|
## Creator ✍️
|
|
153
153
|
|
package/dist/draggable.cjs.js
CHANGED
|
@@ -4857,7 +4857,10 @@ var getPublisher = (getResponders, announce) => {
|
|
|
4857
4857
|
};
|
|
4858
4858
|
// we will flush this frame if we receive any responder updates
|
|
4859
4859
|
asyncMarshal.add(() => {
|
|
4860
|
-
withTimings('onDragStart', () =>
|
|
4860
|
+
withTimings('onDragStart', () => {
|
|
4861
|
+
var _a;
|
|
4862
|
+
return execute((_a = getResponders().onDragStart) !== null && _a !== void 0 ? _a : null, data, announce, preset.onDragStart);
|
|
4863
|
+
});
|
|
4861
4864
|
});
|
|
4862
4865
|
};
|
|
4863
4866
|
// Passing in the critical location again as it can change during a drag
|
|
@@ -4885,7 +4888,10 @@ var getPublisher = (getResponders, announce) => {
|
|
|
4885
4888
|
}
|
|
4886
4889
|
const data = Object.assign(Object.assign({}, getDragStart(critical, dragging.mode)), { combine, destination: location });
|
|
4887
4890
|
asyncMarshal.add(() => {
|
|
4888
|
-
withTimings('onDragUpdate', () =>
|
|
4891
|
+
withTimings('onDragUpdate', () => {
|
|
4892
|
+
var _a;
|
|
4893
|
+
return execute((_a = getResponders().onDragUpdate) !== null && _a !== void 0 ? _a : null, data, announce, preset.onDragUpdate);
|
|
4894
|
+
});
|
|
4889
4895
|
});
|
|
4890
4896
|
};
|
|
4891
4897
|
const flush = () => {
|
|
@@ -8704,11 +8710,14 @@ function useDroppablePublisher(args) {
|
|
|
8704
8710
|
const uniqueId = useUniqueId("droppable");
|
|
8705
8711
|
const { registry, marshal } = appContext;
|
|
8706
8712
|
const previousRef = usePrevious(args);
|
|
8707
|
-
const descriptor = useMemo(() =>
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8713
|
+
const descriptor = useMemo(() => {
|
|
8714
|
+
var _a, _b;
|
|
8715
|
+
return ({
|
|
8716
|
+
id: args.droppableId,
|
|
8717
|
+
type: (_a = args.type) !== null && _a !== void 0 ? _a : "",
|
|
8718
|
+
mode: (_b = args.mode) !== null && _b !== void 0 ? _b : "standard", // By default
|
|
8719
|
+
});
|
|
8720
|
+
}, [args.droppableId, args.mode, args.type]);
|
|
8712
8721
|
const publishedDescriptorRef = React.useRef(descriptor);
|
|
8713
8722
|
const memoizedUpdateScroll = useMemo(() => memoizeOne((x, y) => {
|
|
8714
8723
|
invariant$1(whileDraggingRef.current, "Can only update scroll when dragging");
|
|
@@ -8742,7 +8751,7 @@ function useDroppablePublisher(args) {
|
|
|
8742
8751
|
const getDimensionAndWatchScroll = useCallback((windowScroll, options) => {
|
|
8743
8752
|
invariant$1(!whileDraggingRef.current, "Cannot collect a droppable while a drag is occurring");
|
|
8744
8753
|
const previous = previousRef.current;
|
|
8745
|
-
const ref = previous.getDroppableRef();
|
|
8754
|
+
const ref = previous.getDroppableRef ? previous.getDroppableRef() : null;
|
|
8746
8755
|
invariant$1(ref, "Cannot collect without a droppable ref");
|
|
8747
8756
|
const env = getEnv(ref);
|
|
8748
8757
|
const dragging = {
|
|
@@ -8844,10 +8853,11 @@ function useDroppablePublisher(args) {
|
|
|
8844
8853
|
// update is combine enabled with the marshal
|
|
8845
8854
|
// only need to update when there is a drag
|
|
8846
8855
|
useIsomorphicLayoutEffect(() => {
|
|
8856
|
+
var _a;
|
|
8847
8857
|
if (!whileDraggingRef.current) {
|
|
8848
8858
|
return;
|
|
8849
8859
|
}
|
|
8850
|
-
marshal.updateDroppableIsCombineEnabled(publishedDescriptorRef.current.id, args.isCombineEnabled);
|
|
8860
|
+
marshal.updateDroppableIsCombineEnabled(publishedDescriptorRef.current.id, (_a = args.isCombineEnabled) !== null && _a !== void 0 ? _a : false);
|
|
8851
8861
|
}, [args.isCombineEnabled, marshal]);
|
|
8852
8862
|
}
|
|
8853
8863
|
|
|
@@ -9299,7 +9309,7 @@ function Draggable(props) {
|
|
|
9299
9309
|
const descriptor = useMemo(() => ({
|
|
9300
9310
|
id: props.draggableId,
|
|
9301
9311
|
index: props.index,
|
|
9302
|
-
type,
|
|
9312
|
+
type: type !== null && type !== void 0 ? type : "", // Empty by default Marked for review
|
|
9303
9313
|
droppableId,
|
|
9304
9314
|
}), [props.draggableId, props.index, type, droppableId]);
|
|
9305
9315
|
// props
|
|
@@ -9833,7 +9843,7 @@ const makeMapStateToProps = () => {
|
|
|
9833
9843
|
const renderClone = ownProps.renderClone;
|
|
9834
9844
|
if (isDragging(state)) {
|
|
9835
9845
|
const critical = state.critical;
|
|
9836
|
-
if (!isMatchingType(type, critical)) {
|
|
9846
|
+
if (type && !isMatchingType(type, critical)) {
|
|
9837
9847
|
return idleWithoutAnimation;
|
|
9838
9848
|
}
|
|
9839
9849
|
const dragging = getDraggable(critical, state.dimensions);
|
|
@@ -9842,7 +9852,7 @@ const makeMapStateToProps = () => {
|
|
|
9842
9852
|
}
|
|
9843
9853
|
if (state.phase === 'DROP_ANIMATING') {
|
|
9844
9854
|
const completed = state.completed;
|
|
9845
|
-
if (!isMatchingType(type, completed.critical)) {
|
|
9855
|
+
if (type && !isMatchingType(type, completed.critical)) {
|
|
9846
9856
|
return idleWithoutAnimation;
|
|
9847
9857
|
}
|
|
9848
9858
|
const dragging = getDraggable(completed.critical, state.dimensions);
|
|
@@ -9852,7 +9862,7 @@ const makeMapStateToProps = () => {
|
|
|
9852
9862
|
state.completed &&
|
|
9853
9863
|
!state.shouldFlush) {
|
|
9854
9864
|
const completed = state.completed;
|
|
9855
|
-
if (!isMatchingType(type, completed.critical)) {
|
|
9865
|
+
if (type && !isMatchingType(type, completed.critical)) {
|
|
9856
9866
|
return idleWithoutAnimation;
|
|
9857
9867
|
}
|
|
9858
9868
|
const wasOver = whatIsDraggedOver(completed.impact) === id;
|