@dnd-kit/react 0.0.6-beta-20240917191338 → 0.0.6-beta-20240917204927
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/hooks.cjs +9 -10
- package/hooks.d.ts +1 -1
- package/hooks.js +11 -12
- package/index.cjs +2 -2
- package/index.js +2 -2
- package/package.json +4 -4
package/hooks.cjs
CHANGED
|
@@ -15,15 +15,12 @@ var canUseDOM = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
15
15
|
var useIsomorphicLayoutEffect = canUseDOM ? react.useLayoutEffect : react.useEffect;
|
|
16
16
|
|
|
17
17
|
// src/hooks/useSignal.ts
|
|
18
|
-
function useSignal(
|
|
19
|
-
|
|
20
|
-
() => signalOrValue instanceof state.Signal ? signalOrValue : state.signal(signalOrValue)
|
|
21
|
-
);
|
|
22
|
-
let val = sig.peek();
|
|
18
|
+
function useSignal(signal, sync = false) {
|
|
19
|
+
let val = signal.peek();
|
|
23
20
|
const update = react.useState(val)[1];
|
|
24
21
|
useIsomorphicLayoutEffect(
|
|
25
22
|
() => state.effect(() => {
|
|
26
|
-
if (val !== (val =
|
|
23
|
+
if (val !== (val = signal.value)) {
|
|
27
24
|
if (sync) {
|
|
28
25
|
reactDom.flushSync(() => update(val));
|
|
29
26
|
} else {
|
|
@@ -31,15 +28,17 @@ function useSignal(signalOrValue, sync = false) {
|
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
}),
|
|
34
|
-
[sync]
|
|
31
|
+
[signal, sync]
|
|
35
32
|
);
|
|
36
|
-
return
|
|
33
|
+
return signal;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
// src/hooks/useComputed.ts
|
|
40
|
-
function useComputed(compute, sync = false) {
|
|
37
|
+
function useComputed(compute, dependencies = [], sync = false) {
|
|
38
|
+
const $compute = react.useRef(compute);
|
|
39
|
+
$compute.current = compute;
|
|
41
40
|
return useSignal(
|
|
42
|
-
|
|
41
|
+
react.useMemo(() => state.computed(() => $compute.current()), dependencies),
|
|
43
42
|
sync
|
|
44
43
|
);
|
|
45
44
|
}
|
package/hooks.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { EffectCallback, DependencyList, useLayoutEffect, useEffect } from 'reac
|
|
|
4
4
|
|
|
5
5
|
declare function useConstant<T = any>(initializer: () => T): T;
|
|
6
6
|
|
|
7
|
-
declare function useComputed<T = any>(compute: () => T, sync?: boolean): _preact_signals_core.
|
|
7
|
+
declare function useComputed<T = any>(compute: () => T, dependencies?: any[], sync?: boolean): _preact_signals_core.Signal<T>;
|
|
8
8
|
|
|
9
9
|
declare function useImmediateEffect(callback: EffectCallback, _?: DependencyList): void;
|
|
10
10
|
|
package/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useRef, useLayoutEffect, useEffect, useState } from 'react';
|
|
2
|
-
import { computed,
|
|
1
|
+
import { useRef, useLayoutEffect, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { computed, effect } from '@dnd-kit/state';
|
|
3
3
|
import { flushSync } from 'react-dom';
|
|
4
4
|
|
|
5
5
|
function useConstant(initializer) {
|
|
@@ -13,15 +13,12 @@ var canUseDOM = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
13
13
|
var useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
|
|
14
14
|
|
|
15
15
|
// src/hooks/useSignal.ts
|
|
16
|
-
function useSignal(
|
|
17
|
-
|
|
18
|
-
() => signalOrValue instanceof Signal ? signalOrValue : signal(signalOrValue)
|
|
19
|
-
);
|
|
20
|
-
let val = sig.peek();
|
|
16
|
+
function useSignal(signal, sync = false) {
|
|
17
|
+
let val = signal.peek();
|
|
21
18
|
const update = useState(val)[1];
|
|
22
19
|
useIsomorphicLayoutEffect(
|
|
23
20
|
() => effect(() => {
|
|
24
|
-
if (val !== (val =
|
|
21
|
+
if (val !== (val = signal.value)) {
|
|
25
22
|
if (sync) {
|
|
26
23
|
flushSync(() => update(val));
|
|
27
24
|
} else {
|
|
@@ -29,15 +26,17 @@ function useSignal(signalOrValue, sync = false) {
|
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
}),
|
|
32
|
-
[sync]
|
|
29
|
+
[signal, sync]
|
|
33
30
|
);
|
|
34
|
-
return
|
|
31
|
+
return signal;
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
// src/hooks/useComputed.ts
|
|
38
|
-
function useComputed(compute, sync = false) {
|
|
35
|
+
function useComputed(compute, dependencies = [], sync = false) {
|
|
36
|
+
const $compute = useRef(compute);
|
|
37
|
+
$compute.current = compute;
|
|
39
38
|
return useSignal(
|
|
40
|
-
|
|
39
|
+
useMemo(() => computed(() => $compute.current()), dependencies),
|
|
41
40
|
sync
|
|
42
41
|
);
|
|
43
42
|
}
|
package/index.cjs
CHANGED
|
@@ -276,8 +276,8 @@ function useDroppable(input) {
|
|
|
276
276
|
}
|
|
277
277
|
function useDragOperation() {
|
|
278
278
|
const manager = useDragDropManager();
|
|
279
|
-
const source = hooks.useComputed(() => manager == null ? void 0 : manager.dragOperation.source);
|
|
280
|
-
const target = hooks.useComputed(() => manager == null ? void 0 : manager.dragOperation.target);
|
|
279
|
+
const source = hooks.useComputed(() => manager == null ? void 0 : manager.dragOperation.source, [manager]);
|
|
280
|
+
const target = hooks.useComputed(() => manager == null ? void 0 : manager.dragOperation.target, [manager]);
|
|
281
281
|
return {
|
|
282
282
|
get source() {
|
|
283
283
|
return source.value;
|
package/index.js
CHANGED
|
@@ -274,8 +274,8 @@ function useDroppable(input) {
|
|
|
274
274
|
}
|
|
275
275
|
function useDragOperation() {
|
|
276
276
|
const manager = useDragDropManager();
|
|
277
|
-
const source = useComputed(() => manager == null ? void 0 : manager.dragOperation.source);
|
|
278
|
-
const target = useComputed(() => manager == null ? void 0 : manager.dragOperation.target);
|
|
277
|
+
const source = useComputed(() => manager == null ? void 0 : manager.dragOperation.source, [manager]);
|
|
278
|
+
const target = useComputed(() => manager == null ? void 0 : manager.dragOperation.target, [manager]);
|
|
279
279
|
return {
|
|
280
280
|
get source() {
|
|
281
281
|
return source.value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnd-kit/react",
|
|
3
|
-
"version": "0.0.6-beta-
|
|
3
|
+
"version": "0.0.6-beta-20240917204927",
|
|
4
4
|
"main": "./index.cjs",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@dnd-kit/abstract": "0.0.6-beta-
|
|
60
|
-
"@dnd-kit/dom": "0.0.6-beta-
|
|
61
|
-
"@dnd-kit/state": "0.0.6-beta-
|
|
59
|
+
"@dnd-kit/abstract": "0.0.6-beta-20240917204927",
|
|
60
|
+
"@dnd-kit/dom": "0.0.6-beta-20240917204927",
|
|
61
|
+
"@dnd-kit/state": "0.0.6-beta-20240917204927",
|
|
62
62
|
"tslib": "^2.6.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|