@pallasoft/ps-core-components 2.20.0 → 2.22.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-client-only.d.ts +6 -0
- package/dist/components/ps-client-only.js +7 -0
- package/dist/constants/ps-hydration-store.d.ts +5 -0
- package/dist/constants/ps-hydration-store.js +8 -0
- package/dist/esm/components/ps-client-only.js +3 -0
- package/dist/esm/constants/ps-hydration-store.js +5 -0
- package/dist/esm/hooks/use-ps-change-queue.js +31 -0
- package/dist/esm/hooks/use-ps-hydrated.js +3 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/interfaces/ps-change-queue-input.js +1 -0
- package/dist/esm/interfaces/ps-change-queue-result.js +1 -0
- package/dist/hooks/use-ps-change-queue.d.ts +3 -0
- package/dist/hooks/use-ps-change-queue.js +35 -0
- package/dist/hooks/use-ps-hydrated.d.ts +1 -0
- package/dist/hooks/use-ps-hydrated.js +7 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/interfaces/ps-change-queue-input.d.ts +5 -0
- package/dist/interfaces/ps-change-queue-input.js +2 -0
- package/dist/interfaces/ps-change-queue-result.d.ts +3 -0
- package/dist/interfaces/ps-change-queue-result.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsClientOnly = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const use_ps_hydrated_1 = require("../hooks/use-ps-hydrated");
|
|
6
|
+
const PsClientOnly = ({ children, fallback = null }) => (0, use_ps_hydrated_1.usePsHydrated)() ? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children() }) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fallback });
|
|
7
|
+
exports.PsClientOnly = PsClientOnly;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePsHydrated } from '../hooks/use-ps-hydrated';
|
|
3
|
+
export const PsClientOnly = ({ children, fallback = null }) => usePsHydrated() ? _jsx(_Fragment, { children: children() }) : _jsx(_Fragment, { children: fallback });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
export const usePsChangeQueue = ({ onDrained, onFailed, send, }) => {
|
|
3
|
+
const pending = useRef([]);
|
|
4
|
+
const isRunning = useRef(false);
|
|
5
|
+
const latest = useRef({ onDrained, onFailed, send });
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
latest.current = { onDrained, onFailed, send };
|
|
8
|
+
}, [onDrained, onFailed, send]);
|
|
9
|
+
const run = useCallback(async () => {
|
|
10
|
+
if (isRunning.current)
|
|
11
|
+
return;
|
|
12
|
+
isRunning.current = true;
|
|
13
|
+
await Promise.resolve();
|
|
14
|
+
while (pending.current.length > 0) {
|
|
15
|
+
const batch = pending.current;
|
|
16
|
+
pending.current = [];
|
|
17
|
+
await latest.current.send(batch).catch(() => {
|
|
18
|
+
const dropped = pending.current;
|
|
19
|
+
pending.current = [];
|
|
20
|
+
latest.current.onFailed(batch, dropped);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
isRunning.current = false;
|
|
24
|
+
latest.current.onDrained();
|
|
25
|
+
}, []);
|
|
26
|
+
const enqueue = useCallback((change) => {
|
|
27
|
+
pending.current = [...pending.current, change];
|
|
28
|
+
void run();
|
|
29
|
+
}, [run]);
|
|
30
|
+
return { enqueue };
|
|
31
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from './components/ps-pallasoft-mark';
|
|
|
10
10
|
export * from './components/ps-pallasoft-sign-in-button';
|
|
11
11
|
export * from './constants/ps-pallasoft-mark-config';
|
|
12
12
|
export * from './components/ps-card';
|
|
13
|
+
export * from './components/ps-client-only';
|
|
13
14
|
export * from './components/ps-draggable-grid';
|
|
14
15
|
export * from './components/ps-empty-state';
|
|
15
16
|
export * from './components/ps-fab';
|
|
@@ -48,12 +49,16 @@ export * from './contexts/ps-layer-context';
|
|
|
48
49
|
export * from './hooks/use-ps-layer-z-index';
|
|
49
50
|
export * from './hooks/use-ps-route-loader-data';
|
|
50
51
|
export * from './hooks/use-ps-element-size';
|
|
52
|
+
export * from './hooks/use-ps-hydrated';
|
|
51
53
|
export * from './hooks/use-ps-viewport';
|
|
52
54
|
export * from './interfaces/ps-component-props';
|
|
53
55
|
export * from './models/ps-element-size';
|
|
54
56
|
export * from './models/ps-voice-orb';
|
|
55
57
|
export * from './models/ps-navigation-progress';
|
|
56
58
|
export * from './hooks/use-ps-debounced-value';
|
|
59
|
+
export * from './hooks/use-ps-change-queue';
|
|
60
|
+
export * from './interfaces/ps-change-queue-input';
|
|
61
|
+
export * from './interfaces/ps-change-queue-result';
|
|
57
62
|
export * from './hooks/use-ps-optimistic-rows';
|
|
58
63
|
export * from './interfaces/ps-optimistic-rows-input';
|
|
59
64
|
export * from './interfaces/ps-optimistic-rows-result';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PsChangeQueueInput } from '../interfaces/ps-change-queue-input';
|
|
2
|
+
import type { PsChangeQueueResult } from '../interfaces/ps-change-queue-result';
|
|
3
|
+
export declare const usePsChangeQueue: <Change>({ onDrained, onFailed, send, }: PsChangeQueueInput<Change>) => PsChangeQueueResult<Change>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsChangeQueue = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const usePsChangeQueue = ({ onDrained, onFailed, send, }) => {
|
|
6
|
+
const pending = (0, react_1.useRef)([]);
|
|
7
|
+
const isRunning = (0, react_1.useRef)(false);
|
|
8
|
+
const latest = (0, react_1.useRef)({ onDrained, onFailed, send });
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
latest.current = { onDrained, onFailed, send };
|
|
11
|
+
}, [onDrained, onFailed, send]);
|
|
12
|
+
const run = (0, react_1.useCallback)(async () => {
|
|
13
|
+
if (isRunning.current)
|
|
14
|
+
return;
|
|
15
|
+
isRunning.current = true;
|
|
16
|
+
await Promise.resolve();
|
|
17
|
+
while (pending.current.length > 0) {
|
|
18
|
+
const batch = pending.current;
|
|
19
|
+
pending.current = [];
|
|
20
|
+
await latest.current.send(batch).catch(() => {
|
|
21
|
+
const dropped = pending.current;
|
|
22
|
+
pending.current = [];
|
|
23
|
+
latest.current.onFailed(batch, dropped);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
isRunning.current = false;
|
|
27
|
+
latest.current.onDrained();
|
|
28
|
+
}, []);
|
|
29
|
+
const enqueue = (0, react_1.useCallback)((change) => {
|
|
30
|
+
pending.current = [...pending.current, change];
|
|
31
|
+
void run();
|
|
32
|
+
}, [run]);
|
|
33
|
+
return { enqueue };
|
|
34
|
+
};
|
|
35
|
+
exports.usePsChangeQueue = usePsChangeQueue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usePsHydrated: () => boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsHydrated = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ps_hydration_store_1 = require("../constants/ps-hydration-store");
|
|
6
|
+
const usePsHydrated = () => (0, react_1.useSyncExternalStore)(ps_hydration_store_1.PsHydrationStore.subscribe, ps_hydration_store_1.PsHydrationStore.clientSnapshot, ps_hydration_store_1.PsHydrationStore.serverSnapshot);
|
|
7
|
+
exports.usePsHydrated = usePsHydrated;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './components/ps-pallasoft-mark';
|
|
|
10
10
|
export * from './components/ps-pallasoft-sign-in-button';
|
|
11
11
|
export * from './constants/ps-pallasoft-mark-config';
|
|
12
12
|
export * from './components/ps-card';
|
|
13
|
+
export * from './components/ps-client-only';
|
|
13
14
|
export * from './components/ps-draggable-grid';
|
|
14
15
|
export * from './components/ps-empty-state';
|
|
15
16
|
export * from './components/ps-fab';
|
|
@@ -48,12 +49,16 @@ export * from './contexts/ps-layer-context';
|
|
|
48
49
|
export * from './hooks/use-ps-layer-z-index';
|
|
49
50
|
export * from './hooks/use-ps-route-loader-data';
|
|
50
51
|
export * from './hooks/use-ps-element-size';
|
|
52
|
+
export * from './hooks/use-ps-hydrated';
|
|
51
53
|
export * from './hooks/use-ps-viewport';
|
|
52
54
|
export * from './interfaces/ps-component-props';
|
|
53
55
|
export * from './models/ps-element-size';
|
|
54
56
|
export * from './models/ps-voice-orb';
|
|
55
57
|
export * from './models/ps-navigation-progress';
|
|
56
58
|
export * from './hooks/use-ps-debounced-value';
|
|
59
|
+
export * from './hooks/use-ps-change-queue';
|
|
60
|
+
export * from './interfaces/ps-change-queue-input';
|
|
61
|
+
export * from './interfaces/ps-change-queue-result';
|
|
57
62
|
export * from './hooks/use-ps-optimistic-rows';
|
|
58
63
|
export * from './interfaces/ps-optimistic-rows-input';
|
|
59
64
|
export * from './interfaces/ps-optimistic-rows-result';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./components/ps-pallasoft-mark"), exports);
|
|
|
26
26
|
__exportStar(require("./components/ps-pallasoft-sign-in-button"), exports);
|
|
27
27
|
__exportStar(require("./constants/ps-pallasoft-mark-config"), exports);
|
|
28
28
|
__exportStar(require("./components/ps-card"), exports);
|
|
29
|
+
__exportStar(require("./components/ps-client-only"), exports);
|
|
29
30
|
__exportStar(require("./components/ps-draggable-grid"), exports);
|
|
30
31
|
__exportStar(require("./components/ps-empty-state"), exports);
|
|
31
32
|
__exportStar(require("./components/ps-fab"), exports);
|
|
@@ -64,12 +65,16 @@ __exportStar(require("./contexts/ps-layer-context"), exports);
|
|
|
64
65
|
__exportStar(require("./hooks/use-ps-layer-z-index"), exports);
|
|
65
66
|
__exportStar(require("./hooks/use-ps-route-loader-data"), exports);
|
|
66
67
|
__exportStar(require("./hooks/use-ps-element-size"), exports);
|
|
68
|
+
__exportStar(require("./hooks/use-ps-hydrated"), exports);
|
|
67
69
|
__exportStar(require("./hooks/use-ps-viewport"), exports);
|
|
68
70
|
__exportStar(require("./interfaces/ps-component-props"), exports);
|
|
69
71
|
__exportStar(require("./models/ps-element-size"), exports);
|
|
70
72
|
__exportStar(require("./models/ps-voice-orb"), exports);
|
|
71
73
|
__exportStar(require("./models/ps-navigation-progress"), exports);
|
|
72
74
|
__exportStar(require("./hooks/use-ps-debounced-value"), exports);
|
|
75
|
+
__exportStar(require("./hooks/use-ps-change-queue"), exports);
|
|
76
|
+
__exportStar(require("./interfaces/ps-change-queue-input"), exports);
|
|
77
|
+
__exportStar(require("./interfaces/ps-change-queue-result"), exports);
|
|
73
78
|
__exportStar(require("./hooks/use-ps-optimistic-rows"), exports);
|
|
74
79
|
__exportStar(require("./interfaces/ps-optimistic-rows-input"), exports);
|
|
75
80
|
__exportStar(require("./interfaces/ps-optimistic-rows-result"), exports);
|