@pallasoft/ps-core-components 2.31.0 → 2.33.0
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/components/ps-drag-overlay.d.ts +2 -1
- package/dist/components/ps-drag-overlay.js +2 -2
- package/dist/esm/components/ps-drag-overlay.js +2 -2
- package/dist/esm/hooks/use-ps-debounced-revalidate.js +23 -0
- package/dist/esm/hooks/use-ps-live.js +34 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/interfaces/ps-live-handle.js +1 -0
- package/dist/esm/interfaces/ps-live-input.js +1 -0
- package/dist/esm/interfaces/ps-live-open-options.js +1 -0
- package/dist/hooks/use-ps-debounced-revalidate.d.ts +2 -0
- package/dist/hooks/use-ps-debounced-revalidate.js +27 -0
- package/dist/hooks/use-ps-live.d.ts +2 -0
- package/dist/hooks/use-ps-live.js +38 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/interfaces/ps-live-handle.d.ts +3 -0
- package/dist/interfaces/ps-live-handle.js +2 -0
- package/dist/interfaces/ps-live-input.d.ts +11 -0
- package/dist/interfaces/ps-live-input.js +2 -0
- package/dist/interfaces/ps-live-open-options.d.ts +7 -0
- package/dist/interfaces/ps-live-open-options.js +2 -0
- package/package.json +1 -1
|
@@ -3,5 +3,6 @@ export interface PsDragOverlayProps {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
className: string;
|
|
5
5
|
frames: Keyframe[];
|
|
6
|
+
isDropAnimated?: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare const PsDragOverlay: ({ children, className, frames }: PsDragOverlayProps) => import("react").ReactPortal | null;
|
|
8
|
+
export declare const PsDragOverlay: ({ children, className, frames, isDropAnimated, }: PsDragOverlayProps) => import("react").ReactPortal | null;
|
|
@@ -14,7 +14,7 @@ const dropAnimation = {
|
|
|
14
14
|
styles: { active: { opacity: ps_drag_config_1.PsDragConfig.placeholderOpacity } },
|
|
15
15
|
}),
|
|
16
16
|
};
|
|
17
|
-
const PsDragOverlay = ({ children, className, frames }) => {
|
|
17
|
+
const PsDragOverlay = ({ children, className, frames, isDropAnimated, }) => {
|
|
18
18
|
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
19
19
|
const isReduced = (0, use_ps_reduced_motion_1.usePsReducedMotion)();
|
|
20
20
|
(0, react_1.useEffect)(() => setIsMounted(true), []);
|
|
@@ -29,6 +29,6 @@ const PsDragOverlay = ({ children, className, frames }) => {
|
|
|
29
29
|
fill: 'forwards',
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
|
-
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: isReduced ? null : dropAnimation, children: children === null ? null : ((0, jsx_runtime_1.jsx)("div", { className: className, ref: lift, children: children })) }), document.body);
|
|
32
|
+
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, children: children === null ? null : ((0, jsx_runtime_1.jsx)("div", { className: className, ref: lift, children: children })) }), document.body);
|
|
33
33
|
};
|
|
34
34
|
exports.PsDragOverlay = PsDragOverlay;
|
|
@@ -11,7 +11,7 @@ const dropAnimation = {
|
|
|
11
11
|
styles: { active: { opacity: PsDragConfig.placeholderOpacity } },
|
|
12
12
|
}),
|
|
13
13
|
};
|
|
14
|
-
export const PsDragOverlay = ({ children, className, frames }) => {
|
|
14
|
+
export const PsDragOverlay = ({ children, className, frames, isDropAnimated, }) => {
|
|
15
15
|
const [isMounted, setIsMounted] = useState(false);
|
|
16
16
|
const isReduced = usePsReducedMotion();
|
|
17
17
|
useEffect(() => setIsMounted(true), []);
|
|
@@ -26,5 +26,5 @@ export const PsDragOverlay = ({ children, className, frames }) => {
|
|
|
26
26
|
fill: 'forwards',
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
-
return createPortal(_jsx(DragOverlay, { dropAnimation: isReduced ? null : dropAnimation, children: children === null ? null : (_jsx("div", { className: className, ref: lift, children: children })) }), document.body);
|
|
29
|
+
return createPortal(_jsx(DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, children: children === null ? null : (_jsx("div", { className: className, ref: lift, children: children })) }), document.body);
|
|
30
30
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
export const usePsDebouncedRevalidate = (revalidator, delayMilliseconds) => {
|
|
3
|
+
const latest = useRef(revalidator);
|
|
4
|
+
const timer = useRef(null);
|
|
5
|
+
latest.current = revalidator;
|
|
6
|
+
const fire = useCallback(() => {
|
|
7
|
+
timer.current = null;
|
|
8
|
+
if (latest.current.state !== 'idle') {
|
|
9
|
+
timer.current = setTimeout(fire, delayMilliseconds);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
void latest.current.revalidate();
|
|
13
|
+
}, [delayMilliseconds]);
|
|
14
|
+
useEffect(() => () => {
|
|
15
|
+
if (timer.current !== null)
|
|
16
|
+
clearTimeout(timer.current);
|
|
17
|
+
}, []);
|
|
18
|
+
return useCallback(() => {
|
|
19
|
+
if (timer.current !== null)
|
|
20
|
+
clearTimeout(timer.current);
|
|
21
|
+
timer.current = setTimeout(fire, delayMilliseconds);
|
|
22
|
+
}, [delayMilliseconds, fire]);
|
|
23
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
export const usePsLive = (input) => {
|
|
3
|
+
const latest = useRef(input);
|
|
4
|
+
const { enabled, open, path } = input;
|
|
5
|
+
const eventKey = input.events.join(',');
|
|
6
|
+
latest.current = input;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!enabled)
|
|
9
|
+
return;
|
|
10
|
+
let isActive = true;
|
|
11
|
+
let close = null;
|
|
12
|
+
void open({
|
|
13
|
+
events: latest.current.events,
|
|
14
|
+
fetchToken: () => latest.current.fetchToken(),
|
|
15
|
+
onEvent: (name, payload) => latest.current.onEvent(name, payload),
|
|
16
|
+
onResume: () => {
|
|
17
|
+
const { onResume } = latest.current;
|
|
18
|
+
if (onResume !== undefined)
|
|
19
|
+
onResume();
|
|
20
|
+
},
|
|
21
|
+
path,
|
|
22
|
+
}).then((handle) => {
|
|
23
|
+
if (isActive)
|
|
24
|
+
close = () => handle.close();
|
|
25
|
+
else
|
|
26
|
+
handle.close();
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
isActive = false;
|
|
30
|
+
if (close !== null)
|
|
31
|
+
close();
|
|
32
|
+
};
|
|
33
|
+
}, [enabled, eventKey, open, path]);
|
|
34
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -76,6 +76,8 @@ export * from './hooks/use-ps-debounced-value';
|
|
|
76
76
|
export * from './hooks/use-ps-change-queue';
|
|
77
77
|
export * from './interfaces/ps-change-queue-input';
|
|
78
78
|
export * from './interfaces/ps-change-queue-result';
|
|
79
|
+
export * from './hooks/use-ps-live';
|
|
80
|
+
export * from './hooks/use-ps-debounced-revalidate';
|
|
79
81
|
export * from './hooks/use-ps-optimistic-rows';
|
|
80
82
|
export * from './hooks/use-ps-optimistic-fetcher';
|
|
81
83
|
export * from './hooks/use-ps-optimistic-save';
|
|
@@ -88,6 +90,9 @@ export * from './services/ps-optimistic-save-service';
|
|
|
88
90
|
export * from './services/ps-client-param-revalidation-service';
|
|
89
91
|
export * from './interfaces/ps-fetcher-like';
|
|
90
92
|
export * from './interfaces/ps-fetcher-submit-options';
|
|
93
|
+
export * from './interfaces/ps-live-handle';
|
|
94
|
+
export * from './interfaces/ps-live-input';
|
|
95
|
+
export * from './interfaces/ps-live-open-options';
|
|
91
96
|
export * from './interfaces/ps-optimistic-fetcher-input';
|
|
92
97
|
export * from './interfaces/ps-optimistic-fetcher-result';
|
|
93
98
|
export * from './interfaces/ps-revalidator-like';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsDebouncedRevalidate = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const usePsDebouncedRevalidate = (revalidator, delayMilliseconds) => {
|
|
6
|
+
const latest = (0, react_1.useRef)(revalidator);
|
|
7
|
+
const timer = (0, react_1.useRef)(null);
|
|
8
|
+
latest.current = revalidator;
|
|
9
|
+
const fire = (0, react_1.useCallback)(() => {
|
|
10
|
+
timer.current = null;
|
|
11
|
+
if (latest.current.state !== 'idle') {
|
|
12
|
+
timer.current = setTimeout(fire, delayMilliseconds);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
void latest.current.revalidate();
|
|
16
|
+
}, [delayMilliseconds]);
|
|
17
|
+
(0, react_1.useEffect)(() => () => {
|
|
18
|
+
if (timer.current !== null)
|
|
19
|
+
clearTimeout(timer.current);
|
|
20
|
+
}, []);
|
|
21
|
+
return (0, react_1.useCallback)(() => {
|
|
22
|
+
if (timer.current !== null)
|
|
23
|
+
clearTimeout(timer.current);
|
|
24
|
+
timer.current = setTimeout(fire, delayMilliseconds);
|
|
25
|
+
}, [delayMilliseconds, fire]);
|
|
26
|
+
};
|
|
27
|
+
exports.usePsDebouncedRevalidate = usePsDebouncedRevalidate;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsLive = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const usePsLive = (input) => {
|
|
6
|
+
const latest = (0, react_1.useRef)(input);
|
|
7
|
+
const { enabled, open, path } = input;
|
|
8
|
+
const eventKey = input.events.join(',');
|
|
9
|
+
latest.current = input;
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (!enabled)
|
|
12
|
+
return;
|
|
13
|
+
let isActive = true;
|
|
14
|
+
let close = null;
|
|
15
|
+
void open({
|
|
16
|
+
events: latest.current.events,
|
|
17
|
+
fetchToken: () => latest.current.fetchToken(),
|
|
18
|
+
onEvent: (name, payload) => latest.current.onEvent(name, payload),
|
|
19
|
+
onResume: () => {
|
|
20
|
+
const { onResume } = latest.current;
|
|
21
|
+
if (onResume !== undefined)
|
|
22
|
+
onResume();
|
|
23
|
+
},
|
|
24
|
+
path,
|
|
25
|
+
}).then((handle) => {
|
|
26
|
+
if (isActive)
|
|
27
|
+
close = () => handle.close();
|
|
28
|
+
else
|
|
29
|
+
handle.close();
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
isActive = false;
|
|
33
|
+
if (close !== null)
|
|
34
|
+
close();
|
|
35
|
+
};
|
|
36
|
+
}, [enabled, eventKey, open, path]);
|
|
37
|
+
};
|
|
38
|
+
exports.usePsLive = usePsLive;
|
package/dist/index.d.ts
CHANGED
|
@@ -76,6 +76,8 @@ export * from './hooks/use-ps-debounced-value';
|
|
|
76
76
|
export * from './hooks/use-ps-change-queue';
|
|
77
77
|
export * from './interfaces/ps-change-queue-input';
|
|
78
78
|
export * from './interfaces/ps-change-queue-result';
|
|
79
|
+
export * from './hooks/use-ps-live';
|
|
80
|
+
export * from './hooks/use-ps-debounced-revalidate';
|
|
79
81
|
export * from './hooks/use-ps-optimistic-rows';
|
|
80
82
|
export * from './hooks/use-ps-optimistic-fetcher';
|
|
81
83
|
export * from './hooks/use-ps-optimistic-save';
|
|
@@ -88,6 +90,9 @@ export * from './services/ps-optimistic-save-service';
|
|
|
88
90
|
export * from './services/ps-client-param-revalidation-service';
|
|
89
91
|
export * from './interfaces/ps-fetcher-like';
|
|
90
92
|
export * from './interfaces/ps-fetcher-submit-options';
|
|
93
|
+
export * from './interfaces/ps-live-handle';
|
|
94
|
+
export * from './interfaces/ps-live-input';
|
|
95
|
+
export * from './interfaces/ps-live-open-options';
|
|
91
96
|
export * from './interfaces/ps-optimistic-fetcher-input';
|
|
92
97
|
export * from './interfaces/ps-optimistic-fetcher-result';
|
|
93
98
|
export * from './interfaces/ps-revalidator-like';
|
package/dist/index.js
CHANGED
|
@@ -92,6 +92,8 @@ __exportStar(require("./hooks/use-ps-debounced-value"), exports);
|
|
|
92
92
|
__exportStar(require("./hooks/use-ps-change-queue"), exports);
|
|
93
93
|
__exportStar(require("./interfaces/ps-change-queue-input"), exports);
|
|
94
94
|
__exportStar(require("./interfaces/ps-change-queue-result"), exports);
|
|
95
|
+
__exportStar(require("./hooks/use-ps-live"), exports);
|
|
96
|
+
__exportStar(require("./hooks/use-ps-debounced-revalidate"), exports);
|
|
95
97
|
__exportStar(require("./hooks/use-ps-optimistic-rows"), exports);
|
|
96
98
|
__exportStar(require("./hooks/use-ps-optimistic-fetcher"), exports);
|
|
97
99
|
__exportStar(require("./hooks/use-ps-optimistic-save"), exports);
|
|
@@ -104,6 +106,9 @@ __exportStar(require("./services/ps-optimistic-save-service"), exports);
|
|
|
104
106
|
__exportStar(require("./services/ps-client-param-revalidation-service"), exports);
|
|
105
107
|
__exportStar(require("./interfaces/ps-fetcher-like"), exports);
|
|
106
108
|
__exportStar(require("./interfaces/ps-fetcher-submit-options"), exports);
|
|
109
|
+
__exportStar(require("./interfaces/ps-live-handle"), exports);
|
|
110
|
+
__exportStar(require("./interfaces/ps-live-input"), exports);
|
|
111
|
+
__exportStar(require("./interfaces/ps-live-open-options"), exports);
|
|
107
112
|
__exportStar(require("./interfaces/ps-optimistic-fetcher-input"), exports);
|
|
108
113
|
__exportStar(require("./interfaces/ps-optimistic-fetcher-result"), exports);
|
|
109
114
|
__exportStar(require("./interfaces/ps-revalidator-like"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PsLiveHandle } from './ps-live-handle';
|
|
2
|
+
import type { PsLiveOpenOptions } from './ps-live-open-options';
|
|
3
|
+
export interface PsLiveInput {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
events: string[];
|
|
6
|
+
fetchToken: () => Promise<string | null>;
|
|
7
|
+
onEvent: (name: string, payload: unknown) => void;
|
|
8
|
+
onResume?: () => void;
|
|
9
|
+
open: (options: PsLiveOpenOptions) => Promise<PsLiveHandle>;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|