@helpdice/draggable 0.0.1 → 0.0.2
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/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
|
@@ -10,9 +10,9 @@ export type Closest = {
|
|
|
10
10
|
type Args = {
|
|
11
11
|
descriptor: DroppableDescriptor;
|
|
12
12
|
isEnabled: boolean;
|
|
13
|
-
isCombineEnabled
|
|
13
|
+
isCombineEnabled?: boolean;
|
|
14
14
|
isFixedOnPage: boolean;
|
|
15
|
-
direction
|
|
15
|
+
direction?: 'vertical' | 'horizontal';
|
|
16
16
|
client: BoxModel;
|
|
17
17
|
page: BoxModel;
|
|
18
18
|
closest?: Closest | null;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export type DroppableDimension = {
|
|
|
94
94
|
descriptor: DroppableDescriptor;
|
|
95
95
|
axis: Axis;
|
|
96
96
|
isEnabled: boolean;
|
|
97
|
-
isCombineEnabled
|
|
97
|
+
isCombineEnabled?: boolean;
|
|
98
98
|
client: BoxModel;
|
|
99
99
|
isFixedOnPage: boolean;
|
|
100
100
|
page: BoxModel;
|
|
@@ -276,10 +276,10 @@ export type OnDragStartResponder = (start: DragStart, provided: ResponderProvide
|
|
|
276
276
|
export type OnDragUpdateResponder = (update: DragUpdate, provided: ResponderProvided) => unknown;
|
|
277
277
|
export type OnDragEndResponder = (result: DropResult, provided: ResponderProvided) => unknown;
|
|
278
278
|
export type Responders = {
|
|
279
|
-
onBeforeCapture
|
|
280
|
-
onBeforeDragStart
|
|
281
|
-
onDragStart
|
|
282
|
-
onDragUpdate
|
|
279
|
+
onBeforeCapture?: OnBeforeCaptureResponder | null;
|
|
280
|
+
onBeforeDragStart?: OnBeforeDragStartResponder | null;
|
|
281
|
+
onDragStart?: OnDragStartResponder | null;
|
|
282
|
+
onDragUpdate?: OnDragUpdateResponder | null;
|
|
283
283
|
onDragEnd: OnDragEndResponder;
|
|
284
284
|
};
|
|
285
285
|
export type StopDragOptions = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DraggableId, DroppableId, TypeId } from '../../types';
|
|
3
3
|
export type DroppableContextValue = {
|
|
4
|
-
isUsingCloneFor
|
|
4
|
+
isUsingCloneFor?: DraggableId | null;
|
|
5
5
|
droppableId: DroppableId;
|
|
6
|
-
type
|
|
6
|
+
type?: TypeId;
|
|
7
7
|
};
|
|
8
8
|
declare const _default: React.Context<DroppableContextValue | null>;
|
|
9
9
|
export default _default;
|
|
@@ -29,13 +29,13 @@ export type MapProps = {
|
|
|
29
29
|
useClone: UseClone | null;
|
|
30
30
|
};
|
|
31
31
|
export type DefaultProps = {
|
|
32
|
-
mode
|
|
33
|
-
type
|
|
34
|
-
isDropDisabled
|
|
35
|
-
isCombineEnabled
|
|
36
|
-
direction
|
|
37
|
-
renderClone
|
|
38
|
-
ignoreContainerClipping
|
|
32
|
+
mode?: DroppableMode;
|
|
33
|
+
type?: TypeId;
|
|
34
|
+
isDropDisabled?: boolean;
|
|
35
|
+
isCombineEnabled?: boolean;
|
|
36
|
+
direction?: Direction;
|
|
37
|
+
renderClone?: DraggableChildrenFn | null;
|
|
38
|
+
ignoreContainerClipping?: boolean;
|
|
39
39
|
getContainerForClone: () => HTMLElement;
|
|
40
40
|
};
|
|
41
41
|
export type DispatchProps = {
|
|
@@ -6,9 +6,9 @@ type Args = {
|
|
|
6
6
|
descriptor: DroppableDescriptor;
|
|
7
7
|
env: Env;
|
|
8
8
|
windowScroll: Position;
|
|
9
|
-
direction
|
|
10
|
-
isDropDisabled
|
|
11
|
-
isCombineEnabled
|
|
9
|
+
direction?: Direction;
|
|
10
|
+
isDropDisabled?: boolean;
|
|
11
|
+
isCombineEnabled?: boolean;
|
|
12
12
|
shouldClipSubject: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare const _default: ({ ref, descriptor, env, windowScroll, direction, isDropDisabled, isCombineEnabled, shouldClipSubject, }: Args) => DroppableDimension;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { DroppableId, TypeId, Direction, DroppableMode } from "../../types";
|
|
2
2
|
type Props = {
|
|
3
3
|
droppableId: DroppableId;
|
|
4
|
-
type
|
|
5
|
-
mode
|
|
6
|
-
direction
|
|
7
|
-
isDropDisabled
|
|
8
|
-
isCombineEnabled
|
|
9
|
-
ignoreContainerClipping
|
|
10
|
-
getDroppableRef
|
|
4
|
+
type?: TypeId;
|
|
5
|
+
mode?: DroppableMode;
|
|
6
|
+
direction?: Direction;
|
|
7
|
+
isDropDisabled?: boolean;
|
|
8
|
+
isCombineEnabled?: boolean;
|
|
9
|
+
ignoreContainerClipping?: boolean;
|
|
10
|
+
getDroppableRef?: () => HTMLElement | null;
|
|
11
11
|
};
|
|
12
12
|
export default function useDroppablePublisher(args: Props): void;
|
|
13
13
|
export {};
|
package/package.json
CHANGED
|
@@ -26,9 +26,9 @@ export type Closest = {
|
|
|
26
26
|
type Args = {
|
|
27
27
|
descriptor: DroppableDescriptor,
|
|
28
28
|
isEnabled: boolean,
|
|
29
|
-
isCombineEnabled
|
|
29
|
+
isCombineEnabled?: boolean,
|
|
30
30
|
isFixedOnPage: boolean,
|
|
31
|
-
direction
|
|
31
|
+
direction?: 'vertical' | 'horizontal',
|
|
32
32
|
client: BoxModel,
|
|
33
33
|
// is null when in a fixed container
|
|
34
34
|
page: BoxModel,
|
|
@@ -95,7 +95,7 @@ export default (getResponders: () => Responders, announce: Announce) => {
|
|
|
95
95
|
);
|
|
96
96
|
withTimings('onBeforeCapture', () => {
|
|
97
97
|
// No use of screen reader for this responder
|
|
98
|
-
const fn: OnBeforeCaptureResponder | null = getResponders().onBeforeCapture;
|
|
98
|
+
const fn: OnBeforeCaptureResponder | null | undefined = getResponders().onBeforeCapture;
|
|
99
99
|
if (fn) {
|
|
100
100
|
const before: BeforeCapture = {
|
|
101
101
|
draggableId,
|
|
@@ -113,7 +113,7 @@ export default (getResponders: () => Responders, announce: Announce) => {
|
|
|
113
113
|
);
|
|
114
114
|
withTimings('onBeforeDragStart', () => {
|
|
115
115
|
// No use of screen reader for this responder
|
|
116
|
-
const fn: OnBeforeDragStartResponder | null = getResponders().onBeforeDragStart;
|
|
116
|
+
const fn: OnBeforeDragStartResponder | null | undefined = getResponders().onBeforeDragStart;
|
|
117
117
|
if (fn) {
|
|
118
118
|
fn(getDragStart(critical, mode));
|
|
119
119
|
}
|
|
@@ -137,7 +137,7 @@ export default (getResponders: () => Responders, announce: Announce) => {
|
|
|
137
137
|
asyncMarshal.add(() => {
|
|
138
138
|
withTimings('onDragStart', () =>
|
|
139
139
|
execute(
|
|
140
|
-
getResponders().onDragStart,
|
|
140
|
+
getResponders().onDragStart ?? null,
|
|
141
141
|
data,
|
|
142
142
|
announce,
|
|
143
143
|
messagePreset.onDragStart,
|
|
@@ -195,7 +195,7 @@ export default (getResponders: () => Responders, announce: Announce) => {
|
|
|
195
195
|
asyncMarshal.add(() => {
|
|
196
196
|
withTimings('onDragUpdate', () =>
|
|
197
197
|
execute(
|
|
198
|
-
getResponders().onDragUpdate,
|
|
198
|
+
getResponders().onDragUpdate ?? null,
|
|
199
199
|
data,
|
|
200
200
|
announce,
|
|
201
201
|
messagePreset.onDragUpdate,
|
package/src/types.ts
CHANGED
|
@@ -143,7 +143,7 @@ export type DroppableDimension = {
|
|
|
143
143
|
descriptor: DroppableDescriptor,
|
|
144
144
|
axis: Axis,
|
|
145
145
|
isEnabled: boolean,
|
|
146
|
-
isCombineEnabled
|
|
146
|
+
isCombineEnabled?: boolean,
|
|
147
147
|
// relative to the current viewport
|
|
148
148
|
client: BoxModel,
|
|
149
149
|
// relative to the whole page
|
|
@@ -430,10 +430,10 @@ export type OnDragEndResponder = (
|
|
|
430
430
|
) => unknown;
|
|
431
431
|
|
|
432
432
|
export type Responders = {
|
|
433
|
-
onBeforeCapture
|
|
434
|
-
onBeforeDragStart
|
|
435
|
-
onDragStart
|
|
436
|
-
onDragUpdate
|
|
433
|
+
onBeforeCapture?: OnBeforeCaptureResponder | null,
|
|
434
|
+
onBeforeDragStart?: OnBeforeDragStartResponder | null,
|
|
435
|
+
onDragStart?: OnDragStartResponder | null,
|
|
436
|
+
onDragUpdate?: OnDragUpdateResponder | null,
|
|
437
437
|
// always required
|
|
438
438
|
onDragEnd: OnDragEndResponder,
|
|
439
439
|
};
|
|
@@ -4,9 +4,9 @@ import type { DraggableId, DroppableId, TypeId } from '../../types';
|
|
|
4
4
|
|
|
5
5
|
// Exact
|
|
6
6
|
export type DroppableContextValue = {
|
|
7
|
-
isUsingCloneFor
|
|
7
|
+
isUsingCloneFor?: DraggableId | null,
|
|
8
8
|
droppableId: DroppableId,
|
|
9
|
-
type
|
|
9
|
+
type?: TypeId,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export default React.createContext<DroppableContextValue | null>(null);
|
|
@@ -160,7 +160,7 @@ export const makeMapStateToProps = (): Selector => {
|
|
|
160
160
|
ownProps: OwnProps,
|
|
161
161
|
): MapProps => {
|
|
162
162
|
const id: DroppableId = ownProps.droppableId;
|
|
163
|
-
const type: TypeId = ownProps.type;
|
|
163
|
+
const type: TypeId | undefined = ownProps.type;
|
|
164
164
|
const isEnabled: boolean = !ownProps.isDropDisabled;
|
|
165
165
|
const renderClone: DraggableChildrenFn | null =
|
|
166
166
|
ownProps.renderClone;
|
|
@@ -168,7 +168,7 @@ export const makeMapStateToProps = (): Selector => {
|
|
|
168
168
|
if (isDragging(state)) {
|
|
169
169
|
const critical: Critical = state.critical;
|
|
170
170
|
|
|
171
|
-
if (!isMatchingType(type, critical)) {
|
|
171
|
+
if (type && !isMatchingType(type, critical)) {
|
|
172
172
|
return idleWithoutAnimation;
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -193,7 +193,7 @@ export const makeMapStateToProps = (): Selector => {
|
|
|
193
193
|
if (state.phase === 'DROP_ANIMATING') {
|
|
194
194
|
const completed: CompletedDrag = state.completed;
|
|
195
195
|
|
|
196
|
-
if (!isMatchingType(type, completed.critical)) {
|
|
196
|
+
if (type && !isMatchingType(type, completed.critical)) {
|
|
197
197
|
return idleWithoutAnimation;
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -219,7 +219,7 @@ export const makeMapStateToProps = (): Selector => {
|
|
|
219
219
|
) {
|
|
220
220
|
const completed: CompletedDrag = state.completed;
|
|
221
221
|
|
|
222
|
-
if (!isMatchingType(type, completed.critical)) {
|
|
222
|
+
if (type && !isMatchingType(type, completed.critical)) {
|
|
223
223
|
return idleWithoutAnimation;
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -65,13 +65,13 @@ export type MapProps = {
|
|
|
65
65
|
|
|
66
66
|
// Exact
|
|
67
67
|
export type DefaultProps = {
|
|
68
|
-
mode
|
|
69
|
-
type
|
|
70
|
-
isDropDisabled
|
|
71
|
-
isCombineEnabled
|
|
72
|
-
direction
|
|
73
|
-
renderClone
|
|
74
|
-
ignoreContainerClipping
|
|
68
|
+
mode?: DroppableMode,
|
|
69
|
+
type?: TypeId,
|
|
70
|
+
isDropDisabled?: boolean,
|
|
71
|
+
isCombineEnabled?: boolean,
|
|
72
|
+
direction?: Direction,
|
|
73
|
+
renderClone?: DraggableChildrenFn | null,
|
|
74
|
+
ignoreContainerClipping?: boolean,
|
|
75
75
|
getContainerForClone: () => HTMLElement,
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -85,9 +85,9 @@ type Args = {
|
|
|
85
85
|
descriptor: DroppableDescriptor,
|
|
86
86
|
env: Env,
|
|
87
87
|
windowScroll: Position,
|
|
88
|
-
direction
|
|
89
|
-
isDropDisabled
|
|
90
|
-
isCombineEnabled
|
|
88
|
+
direction?: Direction,
|
|
89
|
+
isDropDisabled?: boolean,
|
|
90
|
+
isCombineEnabled?: boolean,
|
|
91
91
|
shouldClipSubject: boolean,
|
|
92
92
|
};
|
|
93
93
|
|
|
@@ -36,13 +36,13 @@ import useUniqueId from "../use-unique-id";
|
|
|
36
36
|
// Exact
|
|
37
37
|
type Props = {
|
|
38
38
|
droppableId: DroppableId,
|
|
39
|
-
type
|
|
40
|
-
mode
|
|
41
|
-
direction
|
|
42
|
-
isDropDisabled
|
|
43
|
-
isCombineEnabled
|
|
44
|
-
ignoreContainerClipping
|
|
45
|
-
getDroppableRef
|
|
39
|
+
type?: TypeId,
|
|
40
|
+
mode?: DroppableMode,
|
|
41
|
+
direction?: Direction,
|
|
42
|
+
isDropDisabled?: boolean,
|
|
43
|
+
isCombineEnabled?: boolean,
|
|
44
|
+
ignoreContainerClipping?: boolean,
|
|
45
|
+
getDroppableRef?: () => HTMLElement | null,
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// Exact
|
|
@@ -66,8 +66,8 @@ export default function useDroppablePublisher(args: Props) {
|
|
|
66
66
|
const descriptor = useMemo<DroppableDescriptor>(
|
|
67
67
|
() => ({
|
|
68
68
|
id: args.droppableId,
|
|
69
|
-
type: args.type,
|
|
70
|
-
mode: args.mode,
|
|
69
|
+
type: args.type ?? "",
|
|
70
|
+
mode: args.mode ?? "standard", // By default
|
|
71
71
|
}),
|
|
72
72
|
[args.droppableId, args.mode, args.type],
|
|
73
73
|
);
|
|
@@ -129,7 +129,7 @@ export default function useDroppablePublisher(args: Props) {
|
|
|
129
129
|
"Cannot collect a droppable while a drag is occurring",
|
|
130
130
|
);
|
|
131
131
|
const previous: Props = previousRef.current;
|
|
132
|
-
const ref: HTMLElement | null = previous.getDroppableRef();
|
|
132
|
+
const ref: HTMLElement | null = previous.getDroppableRef ? previous.getDroppableRef() : null;
|
|
133
133
|
invariant(ref, "Cannot collect without a droppable ref");
|
|
134
134
|
const env: Env = getEnv(ref);
|
|
135
135
|
|
|
@@ -282,7 +282,7 @@ export default function useDroppablePublisher(args: Props) {
|
|
|
282
282
|
}
|
|
283
283
|
marshal.updateDroppableIsCombineEnabled(
|
|
284
284
|
publishedDescriptorRef.current.id,
|
|
285
|
-
args.isCombineEnabled,
|
|
285
|
+
args.isCombineEnabled ?? false, // by default
|
|
286
286
|
);
|
|
287
287
|
}, [args.isCombineEnabled, marshal]);
|
|
288
288
|
}
|