@pallasoft/ps-core-components 2.46.0 → 2.47.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-data-boundary.d.ts +2 -1
- package/dist/components/ps-data-boundary.js +2 -2
- package/dist/components/ps-empty-value.d.ts +5 -0
- package/dist/components/ps-empty-value.js +8 -0
- package/dist/components/ps-image.d.ts +14 -0
- package/dist/components/ps-image.js +29 -0
- package/dist/components/ps-signed-value.d.ts +6 -0
- package/dist/components/ps-signed-value.js +9 -0
- package/dist/constants/ps-empty-value-config.d.ts +4 -0
- package/dist/constants/ps-empty-value-config.js +7 -0
- package/dist/constants/ps-image-config.d.ts +7 -0
- package/dist/constants/ps-image-config.js +10 -0
- package/dist/constants/ps-image-fit.d.ts +7 -0
- package/dist/constants/ps-image-fit.js +11 -0
- package/dist/constants/ps-image-status.d.ts +5 -0
- package/dist/constants/ps-image-status.js +9 -0
- package/dist/constants/ps-signed-value-classes.d.ts +2 -0
- package/dist/constants/ps-signed-value-classes.js +9 -0
- package/dist/esm/components/ps-data-boundary.js +2 -2
- package/dist/esm/components/ps-empty-value.js +4 -0
- package/dist/esm/components/ps-image.js +25 -0
- package/dist/esm/components/ps-signed-value.js +5 -0
- package/dist/esm/constants/ps-empty-value-config.js +4 -0
- package/dist/esm/constants/ps-image-config.js +7 -0
- package/dist/esm/constants/ps-image-fit.js +8 -0
- package/dist/esm/constants/ps-image-status.js +6 -0
- package/dist/esm/constants/ps-signed-value-classes.js +6 -0
- package/dist/esm/hooks/use-ps-cursor-pages.js +82 -0
- package/dist/esm/hooks/use-ps-draft-state.js +18 -0
- package/dist/esm/hooks/use-ps-optimistic-rows.js +2 -1
- package/dist/esm/hooks/use-ps-remote-read.js +31 -0
- package/dist/esm/hooks/use-ps-text-param.js +16 -0
- package/dist/esm/index.js +30 -0
- package/dist/esm/interfaces/ps-cursor-pages-input.js +1 -0
- package/dist/esm/interfaces/ps-cursor-pages-result.js +1 -0
- package/dist/esm/interfaces/ps-draft-state-options.js +1 -0
- package/dist/esm/interfaces/ps-draft-state-result.js +1 -0
- package/dist/esm/interfaces/ps-remote-read-input.js +1 -0
- package/dist/esm/interfaces/ps-remote-read-result.js +1 -0
- package/dist/esm/models/ps-cursor-pages-state.js +1 -0
- package/dist/esm/models/ps-draft-state-data.js +1 -0
- package/dist/esm/models/ps-image-state-data.js +1 -0
- package/dist/esm/models/ps-remote-read-state.js +1 -0
- package/dist/esm/models/ps-remote-settled-data.js +1 -0
- package/dist/esm/models/ps-text-param-data.js +1 -0
- package/dist/esm/models/ps-text-param-options.js +1 -0
- package/dist/esm/services/ps-cursor-pages-service.js +14 -0
- package/dist/esm/services/ps-draft-state-service.js +11 -0
- package/dist/esm/services/ps-image-service.js +11 -0
- package/dist/esm/services/ps-optimistic-release-service.js +11 -5
- package/dist/esm/services/ps-remote-read-service.js +19 -0
- package/dist/esm/services/ps-signed-value-service.js +13 -0
- package/dist/hooks/use-ps-cursor-pages.d.ts +3 -0
- package/dist/hooks/use-ps-cursor-pages.js +86 -0
- package/dist/hooks/use-ps-draft-state.d.ts +3 -0
- package/dist/hooks/use-ps-draft-state.js +22 -0
- package/dist/hooks/use-ps-optimistic-rows.js +2 -1
- package/dist/hooks/use-ps-remote-read.d.ts +3 -0
- package/dist/hooks/use-ps-remote-read.js +35 -0
- package/dist/hooks/use-ps-text-param.d.ts +4 -0
- package/dist/hooks/use-ps-text-param.js +20 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +30 -0
- package/dist/interfaces/ps-cursor-pages-input.d.ts +8 -0
- package/dist/interfaces/ps-cursor-pages-input.js +2 -0
- package/dist/interfaces/ps-cursor-pages-result.d.ts +7 -0
- package/dist/interfaces/ps-cursor-pages-result.js +2 -0
- package/dist/interfaces/ps-draft-state-options.d.ts +3 -0
- package/dist/interfaces/ps-draft-state-options.js +2 -0
- package/dist/interfaces/ps-draft-state-result.d.ts +7 -0
- package/dist/interfaces/ps-draft-state-result.js +2 -0
- package/dist/interfaces/ps-optimistic-changes.d.ts +1 -0
- package/dist/interfaces/ps-remote-read-input.d.ts +5 -0
- package/dist/interfaces/ps-remote-read-input.js +2 -0
- package/dist/interfaces/ps-remote-read-result.d.ts +5 -0
- package/dist/interfaces/ps-remote-read-result.js +2 -0
- package/dist/models/ps-cursor-pages-state.d.ts +8 -0
- package/dist/models/ps-cursor-pages-state.js +2 -0
- package/dist/models/ps-draft-state-data.d.ts +4 -0
- package/dist/models/ps-draft-state-data.js +2 -0
- package/dist/models/ps-image-state-data.d.ts +5 -0
- package/dist/models/ps-image-state-data.js +2 -0
- package/dist/models/ps-remote-read-state.d.ts +6 -0
- package/dist/models/ps-remote-read-state.js +2 -0
- package/dist/models/ps-remote-settled-data.d.ts +4 -0
- package/dist/models/ps-remote-settled-data.js +2 -0
- package/dist/models/ps-text-param-data.d.ts +5 -0
- package/dist/models/ps-text-param-data.js +2 -0
- package/dist/models/ps-text-param-options.d.ts +5 -0
- package/dist/models/ps-text-param-options.js +2 -0
- package/dist/services/ps-cursor-pages-service.d.ts +6 -0
- package/dist/services/ps-cursor-pages-service.js +18 -0
- package/dist/services/ps-draft-state-service.d.ts +6 -0
- package/dist/services/ps-draft-state-service.js +15 -0
- package/dist/services/ps-image-service.d.ts +6 -0
- package/dist/services/ps-image-service.js +15 -0
- package/dist/services/ps-optimistic-release-service.d.ts +1 -1
- package/dist/services/ps-optimistic-release-service.js +11 -5
- package/dist/services/ps-remote-read-service.d.ts +8 -0
- package/dist/services/ps-remote-read-service.js +23 -0
- package/dist/services/ps-signed-value-service.d.ts +5 -0
- package/dist/services/ps-signed-value-service.js +17 -0
- package/package.json +2 -2
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { PsDeepEqualService } from './ps-deep-equal-service.js';
|
|
2
2
|
export class PsOptimisticReleaseService {
|
|
3
3
|
static empty(rows) {
|
|
4
|
-
return { base: rows, changes: [], drainBase: null, wasActive: false };
|
|
4
|
+
return { base: rows, changes: [], drainBase: null, wasActive: false, wasHolding: false };
|
|
5
5
|
}
|
|
6
|
-
static next(remembered, rows, isActive, apply) {
|
|
6
|
+
static next(remembered, rows, isActive, isHolding, apply) {
|
|
7
7
|
if (isActive) {
|
|
8
|
-
|
|
8
|
+
const wasHolding = remembered.wasHolding || isHolding;
|
|
9
|
+
if (remembered.wasActive &&
|
|
10
|
+
remembered.drainBase === null &&
|
|
11
|
+
remembered.wasHolding === wasHolding)
|
|
9
12
|
return remembered;
|
|
10
|
-
return { ...remembered, drainBase: null, wasActive: true };
|
|
13
|
+
return { ...remembered, drainBase: null, wasActive: true, wasHolding };
|
|
11
14
|
}
|
|
12
15
|
if (remembered.changes.length === 0) {
|
|
13
16
|
if (remembered.base === rows && !remembered.wasActive)
|
|
@@ -15,10 +18,13 @@ export class PsOptimisticReleaseService {
|
|
|
15
18
|
return PsOptimisticReleaseService.empty(rows);
|
|
16
19
|
}
|
|
17
20
|
if (remembered.wasActive) {
|
|
21
|
+
if (remembered.wasHolding && rows !== remembered.base) {
|
|
22
|
+
return PsOptimisticReleaseService.empty(rows);
|
|
23
|
+
}
|
|
18
24
|
if (!PsDeepEqualService.isEqual(rows, remembered.base)) {
|
|
19
25
|
return PsOptimisticReleaseService.empty(rows);
|
|
20
26
|
}
|
|
21
|
-
return { ...remembered, drainBase: rows, wasActive: false };
|
|
27
|
+
return { ...remembered, drainBase: rows, wasActive: false, wasHolding: false };
|
|
22
28
|
}
|
|
23
29
|
const reference = remembered.drainBase === null ? remembered.base : remembered.drainBase;
|
|
24
30
|
if (!PsDeepEqualService.isEqual(rows, reference)) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Client } from '@pallasoft/ps-utilities';
|
|
2
|
+
export class PsRemoteReadService {
|
|
3
|
+
static initialState() {
|
|
4
|
+
return { data: null, error: null, settled: null };
|
|
5
|
+
}
|
|
6
|
+
static isPending(settled, url, reloadKey) {
|
|
7
|
+
if (url === null)
|
|
8
|
+
return false;
|
|
9
|
+
return settled === null || settled.url !== url || !Object.is(settled.reloadKey, reloadKey);
|
|
10
|
+
}
|
|
11
|
+
static async read(url, parse, signal) {
|
|
12
|
+
const response = await PsRemoteReadService.client.get(url, {
|
|
13
|
+
responseType: 'json',
|
|
14
|
+
signal,
|
|
15
|
+
});
|
|
16
|
+
return parse(response.data);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
PsRemoteReadService.client = Client.HttpService.createApiClient();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AmountDirection, Common } from '@pallasoft/ps-utilities';
|
|
2
|
+
export class PsSignedValueService {
|
|
3
|
+
static direction(value) {
|
|
4
|
+
const sign = Common.DecimalStringService.sign(value);
|
|
5
|
+
if (sign > 0)
|
|
6
|
+
return AmountDirection.In;
|
|
7
|
+
return sign < 0 ? AmountDirection.Out : AmountDirection.Neutral;
|
|
8
|
+
}
|
|
9
|
+
static text(value, format) {
|
|
10
|
+
const body = format === undefined ? value : format(value);
|
|
11
|
+
return Common.DecimalStringService.sign(value) > 0 ? `+${body}` : body;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsCursorPages = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ps_cursor_pages_service_1 = require("../services/ps-cursor-pages-service");
|
|
6
|
+
const ps_remote_read_service_1 = require("../services/ps-remote-read-service");
|
|
7
|
+
const usePsCursorPages = (input) => {
|
|
8
|
+
const { reloadKey } = input;
|
|
9
|
+
const firstUrl = input.url(null);
|
|
10
|
+
const [state, setState] = (0, react_1.useState)(() => ps_cursor_pages_service_1.PsCursorPagesService.initialState());
|
|
11
|
+
const inputRef = (0, react_1.useRef)(input);
|
|
12
|
+
const stateRef = (0, react_1.useRef)(state);
|
|
13
|
+
const inflight = (0, react_1.useRef)(null);
|
|
14
|
+
inputRef.current = input;
|
|
15
|
+
stateRef.current = state;
|
|
16
|
+
(0, react_1.useEffect)(() => {
|
|
17
|
+
setState((current) => (current.isLoadingMore ? { ...current, isLoadingMore: false } : current));
|
|
18
|
+
if (firstUrl === null)
|
|
19
|
+
return;
|
|
20
|
+
const controller = new AbortController();
|
|
21
|
+
inflight.current = controller;
|
|
22
|
+
ps_remote_read_service_1.PsRemoteReadService.read(firstUrl, inputRef.current.parse, controller.signal).then((page) => {
|
|
23
|
+
if (controller.signal.aborted)
|
|
24
|
+
return;
|
|
25
|
+
inflight.current = null;
|
|
26
|
+
setState({
|
|
27
|
+
error: null,
|
|
28
|
+
hasMore: ps_cursor_pages_service_1.PsCursorPagesService.hasMore(page.length, inputRef.current.pageSize),
|
|
29
|
+
isLoadingMore: false,
|
|
30
|
+
rows: page,
|
|
31
|
+
settled: { reloadKey, url: firstUrl },
|
|
32
|
+
});
|
|
33
|
+
}, (failure) => {
|
|
34
|
+
if (controller.signal.aborted)
|
|
35
|
+
return;
|
|
36
|
+
inflight.current = null;
|
|
37
|
+
setState({
|
|
38
|
+
error: failure,
|
|
39
|
+
hasMore: false,
|
|
40
|
+
isLoadingMore: false,
|
|
41
|
+
rows: [],
|
|
42
|
+
settled: { reloadKey, url: firstUrl },
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return () => {
|
|
46
|
+
controller.abort();
|
|
47
|
+
inflight.current = null;
|
|
48
|
+
};
|
|
49
|
+
}, [firstUrl, reloadKey]);
|
|
50
|
+
const loadMore = (0, react_1.useCallback)(() => {
|
|
51
|
+
const current = stateRef.current;
|
|
52
|
+
const latest = inputRef.current;
|
|
53
|
+
if (!current.hasMore || inflight.current !== null)
|
|
54
|
+
return;
|
|
55
|
+
const nextUrl = latest.url(latest.cursorOf(current.rows));
|
|
56
|
+
if (nextUrl === null)
|
|
57
|
+
return;
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
inflight.current = controller;
|
|
60
|
+
setState((existing) => ({ ...existing, error: null, isLoadingMore: true }));
|
|
61
|
+
ps_remote_read_service_1.PsRemoteReadService.read(nextUrl, latest.parse, controller.signal).then((page) => {
|
|
62
|
+
if (controller.signal.aborted)
|
|
63
|
+
return;
|
|
64
|
+
inflight.current = null;
|
|
65
|
+
setState((existing) => ({
|
|
66
|
+
...existing,
|
|
67
|
+
hasMore: ps_cursor_pages_service_1.PsCursorPagesService.hasMore(page.length, inputRef.current.pageSize),
|
|
68
|
+
isLoadingMore: false,
|
|
69
|
+
rows: ps_cursor_pages_service_1.PsCursorPagesService.append(existing.rows, page, inputRef.current.keyOf),
|
|
70
|
+
}));
|
|
71
|
+
}, (failure) => {
|
|
72
|
+
if (controller.signal.aborted)
|
|
73
|
+
return;
|
|
74
|
+
inflight.current = null;
|
|
75
|
+
setState((existing) => ({ ...existing, error: failure, isLoadingMore: false }));
|
|
76
|
+
});
|
|
77
|
+
}, []);
|
|
78
|
+
return {
|
|
79
|
+
error: state.error,
|
|
80
|
+
hasMore: state.hasMore,
|
|
81
|
+
isLoading: ps_remote_read_service_1.PsRemoteReadService.isPending(state.settled, firstUrl, reloadKey) || state.isLoadingMore,
|
|
82
|
+
loadMore,
|
|
83
|
+
rows: state.rows,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.usePsCursorPages = usePsCursorPages;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PsDraftStateOptions } from '../interfaces/ps-draft-state-options';
|
|
2
|
+
import type { PsDraftStateResult } from '../interfaces/ps-draft-state-result';
|
|
3
|
+
export declare const usePsDraftState: <Value>(initial: Value, options?: PsDraftStateOptions<Value>) => PsDraftStateResult<Value>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsDraftState = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ps_draft_state_service_1 = require("../services/ps-draft-state-service");
|
|
6
|
+
const usePsDraftState = (initial, options) => {
|
|
7
|
+
const [state, setState] = (0, react_1.useState)(() => ps_draft_state_service_1.PsDraftStateService.fresh(initial));
|
|
8
|
+
const isCurrent = ps_draft_state_service_1.PsDraftStateService.isEqual(initial, state.baseline, options);
|
|
9
|
+
if (!isCurrent)
|
|
10
|
+
setState(ps_draft_state_service_1.PsDraftStateService.fresh(initial));
|
|
11
|
+
const setValue = (0, react_1.useCallback)((next) => setState((current) => ({ ...current, value: next })), []);
|
|
12
|
+
const update = (0, react_1.useCallback)((updater) => setState((current) => ({ ...current, value: updater(current.value) })), []);
|
|
13
|
+
const reset = (0, react_1.useCallback)(() => setState((current) => ({ ...current, value: structuredClone(current.baseline) })), []);
|
|
14
|
+
return {
|
|
15
|
+
isDirty: !ps_draft_state_service_1.PsDraftStateService.isEqual(state.value, state.baseline, options),
|
|
16
|
+
reset,
|
|
17
|
+
setValue,
|
|
18
|
+
update,
|
|
19
|
+
value: state.value,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.usePsDraftState = usePsDraftState;
|
|
@@ -7,7 +7,7 @@ const ps_optimistic_release_service_1 = require("../services/ps-optimistic-relea
|
|
|
7
7
|
const usePsOptimisticRows = ({ apply, isHolding = false, isSaving, rows, }) => {
|
|
8
8
|
const [remembered, setRemembered] = (0, react_1.useState)(() => ps_optimistic_release_service_1.PsOptimisticReleaseService.empty(rows));
|
|
9
9
|
const isActive = isSaving || isHolding;
|
|
10
|
-
const current = ps_optimistic_release_service_1.PsOptimisticReleaseService.next(remembered, rows, isActive, apply);
|
|
10
|
+
const current = ps_optimistic_release_service_1.PsOptimisticReleaseService.next(remembered, rows, isActive, isHolding, apply);
|
|
11
11
|
if (current !== remembered)
|
|
12
12
|
setRemembered(current);
|
|
13
13
|
const { changes } = current;
|
|
@@ -24,6 +24,7 @@ const usePsOptimisticRows = ({ apply, isHolding = false, isSaving, rows, }) => {
|
|
|
24
24
|
changes: [...previous.changes, change],
|
|
25
25
|
drainBase: null,
|
|
26
26
|
wasActive: previous.wasActive,
|
|
27
|
+
wasHolding: previous.wasHolding,
|
|
27
28
|
})), [rows]);
|
|
28
29
|
const forgetLast = (0, react_1.useCallback)(() => setRemembered((previous) => ({ ...previous, changes: previous.changes.slice(0, -1) })), []);
|
|
29
30
|
const rollback = (0, react_1.useCallback)(() => setRemembered(ps_optimistic_release_service_1.PsOptimisticReleaseService.empty(rows)), [rows]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PsRemoteReadInput } from '../interfaces/ps-remote-read-input';
|
|
2
|
+
import type { PsRemoteReadResult } from '../interfaces/ps-remote-read-result';
|
|
3
|
+
export declare const usePsRemoteRead: <Data>({ parse, reloadKey, url, }: PsRemoteReadInput<Data>) => PsRemoteReadResult<Data>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsRemoteRead = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ps_remote_read_service_1 = require("../services/ps-remote-read-service");
|
|
6
|
+
const usePsRemoteRead = ({ parse, reloadKey, url, }) => {
|
|
7
|
+
const [state, setState] = (0, react_1.useState)(() => ps_remote_read_service_1.PsRemoteReadService.initialState());
|
|
8
|
+
const parseRef = (0, react_1.useRef)(parse);
|
|
9
|
+
parseRef.current = parse;
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (url === null)
|
|
12
|
+
return;
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
ps_remote_read_service_1.PsRemoteReadService.read(url, parseRef.current, controller.signal).then((data) => {
|
|
15
|
+
if (controller.signal.aborted)
|
|
16
|
+
return;
|
|
17
|
+
setState({ data, error: null, settled: { reloadKey, url } });
|
|
18
|
+
}, (failure) => {
|
|
19
|
+
if (controller.signal.aborted)
|
|
20
|
+
return;
|
|
21
|
+
setState((current) => ({
|
|
22
|
+
data: current.data,
|
|
23
|
+
error: failure,
|
|
24
|
+
settled: { reloadKey, url },
|
|
25
|
+
}));
|
|
26
|
+
});
|
|
27
|
+
return () => controller.abort();
|
|
28
|
+
}, [reloadKey, url]);
|
|
29
|
+
return {
|
|
30
|
+
data: state.data,
|
|
31
|
+
error: state.error,
|
|
32
|
+
isLoading: ps_remote_read_service_1.PsRemoteReadService.isPending(state.settled, url, reloadKey),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.usePsRemoteRead = usePsRemoteRead;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PsSearchParamsState } from '../models/ps-search-params-state';
|
|
2
|
+
import type { PsTextParamData } from '../models/ps-text-param-data';
|
|
3
|
+
import type { PsTextParamOptions } from '../models/ps-text-param-options';
|
|
4
|
+
export declare const usePsTextParam: ([searchParams, setSearchParams]: PsSearchParamsState, { debounceMs, name, resetParams }: PsTextParamOptions) => PsTextParamData;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsTextParam = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ps_query_param_config_1 = require("../constants/ps-query-param-config");
|
|
6
|
+
const ps_query_param_service_1 = require("../services/ps-query-param-service");
|
|
7
|
+
const use_ps_debounced_value_1 = require("./use-ps-debounced-value");
|
|
8
|
+
const usePsTextParam = ([searchParams, setSearchParams], { debounceMs, name, resetParams }) => {
|
|
9
|
+
const raw = searchParams.get(name);
|
|
10
|
+
const committed = raw === null ? '' : raw;
|
|
11
|
+
const [value, setValue] = (0, react_1.useState)(committed);
|
|
12
|
+
const settled = (0, use_ps_debounced_value_1.usePsDebouncedValue)(value, debounceMs);
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
if (settled === committed)
|
|
15
|
+
return;
|
|
16
|
+
setSearchParams((current) => ps_query_param_service_1.PsQueryParamService.withChoice(current, name, settled, '', resetParams), ps_query_param_config_1.PsQueryParamConfig.setOptions);
|
|
17
|
+
}, [settled]);
|
|
18
|
+
return { committed, onChange: setValue, value };
|
|
19
|
+
};
|
|
20
|
+
exports.usePsTextParam = usePsTextParam;
|
package/dist/index.d.ts
CHANGED
|
@@ -228,3 +228,33 @@ export * from './hooks/use-ps-choice-param';
|
|
|
228
228
|
export * from './hooks/use-ps-flag-param';
|
|
229
229
|
export * from './constants/ps-rerender-config';
|
|
230
230
|
export * from './hooks/use-ps-rerender-at';
|
|
231
|
+
export * from './models/ps-remote-settled-data';
|
|
232
|
+
export * from './models/ps-remote-read-state';
|
|
233
|
+
export * from './interfaces/ps-remote-read-input';
|
|
234
|
+
export * from './interfaces/ps-remote-read-result';
|
|
235
|
+
export * from './services/ps-remote-read-service';
|
|
236
|
+
export * from './hooks/use-ps-remote-read';
|
|
237
|
+
export * from './interfaces/ps-cursor-pages-input';
|
|
238
|
+
export * from './interfaces/ps-cursor-pages-result';
|
|
239
|
+
export * from './models/ps-cursor-pages-state';
|
|
240
|
+
export * from './services/ps-cursor-pages-service';
|
|
241
|
+
export * from './hooks/use-ps-cursor-pages';
|
|
242
|
+
export * from './models/ps-text-param-options';
|
|
243
|
+
export * from './models/ps-text-param-data';
|
|
244
|
+
export * from './hooks/use-ps-text-param';
|
|
245
|
+
export * from './interfaces/ps-draft-state-options';
|
|
246
|
+
export * from './interfaces/ps-draft-state-result';
|
|
247
|
+
export * from './models/ps-draft-state-data';
|
|
248
|
+
export * from './services/ps-draft-state-service';
|
|
249
|
+
export * from './hooks/use-ps-draft-state';
|
|
250
|
+
export * from './constants/ps-empty-value-config';
|
|
251
|
+
export * from './components/ps-empty-value';
|
|
252
|
+
export * from './constants/ps-signed-value-classes';
|
|
253
|
+
export * from './services/ps-signed-value-service';
|
|
254
|
+
export * from './components/ps-signed-value';
|
|
255
|
+
export * from './constants/ps-image-status';
|
|
256
|
+
export * from './constants/ps-image-fit';
|
|
257
|
+
export * from './constants/ps-image-config';
|
|
258
|
+
export * from './models/ps-image-state-data';
|
|
259
|
+
export * from './services/ps-image-service';
|
|
260
|
+
export * from './components/ps-image';
|
package/dist/index.js
CHANGED
|
@@ -244,3 +244,33 @@ __exportStar(require("./hooks/use-ps-choice-param"), exports);
|
|
|
244
244
|
__exportStar(require("./hooks/use-ps-flag-param"), exports);
|
|
245
245
|
__exportStar(require("./constants/ps-rerender-config"), exports);
|
|
246
246
|
__exportStar(require("./hooks/use-ps-rerender-at"), exports);
|
|
247
|
+
__exportStar(require("./models/ps-remote-settled-data"), exports);
|
|
248
|
+
__exportStar(require("./models/ps-remote-read-state"), exports);
|
|
249
|
+
__exportStar(require("./interfaces/ps-remote-read-input"), exports);
|
|
250
|
+
__exportStar(require("./interfaces/ps-remote-read-result"), exports);
|
|
251
|
+
__exportStar(require("./services/ps-remote-read-service"), exports);
|
|
252
|
+
__exportStar(require("./hooks/use-ps-remote-read"), exports);
|
|
253
|
+
__exportStar(require("./interfaces/ps-cursor-pages-input"), exports);
|
|
254
|
+
__exportStar(require("./interfaces/ps-cursor-pages-result"), exports);
|
|
255
|
+
__exportStar(require("./models/ps-cursor-pages-state"), exports);
|
|
256
|
+
__exportStar(require("./services/ps-cursor-pages-service"), exports);
|
|
257
|
+
__exportStar(require("./hooks/use-ps-cursor-pages"), exports);
|
|
258
|
+
__exportStar(require("./models/ps-text-param-options"), exports);
|
|
259
|
+
__exportStar(require("./models/ps-text-param-data"), exports);
|
|
260
|
+
__exportStar(require("./hooks/use-ps-text-param"), exports);
|
|
261
|
+
__exportStar(require("./interfaces/ps-draft-state-options"), exports);
|
|
262
|
+
__exportStar(require("./interfaces/ps-draft-state-result"), exports);
|
|
263
|
+
__exportStar(require("./models/ps-draft-state-data"), exports);
|
|
264
|
+
__exportStar(require("./services/ps-draft-state-service"), exports);
|
|
265
|
+
__exportStar(require("./hooks/use-ps-draft-state"), exports);
|
|
266
|
+
__exportStar(require("./constants/ps-empty-value-config"), exports);
|
|
267
|
+
__exportStar(require("./components/ps-empty-value"), exports);
|
|
268
|
+
__exportStar(require("./constants/ps-signed-value-classes"), exports);
|
|
269
|
+
__exportStar(require("./services/ps-signed-value-service"), exports);
|
|
270
|
+
__exportStar(require("./components/ps-signed-value"), exports);
|
|
271
|
+
__exportStar(require("./constants/ps-image-status"), exports);
|
|
272
|
+
__exportStar(require("./constants/ps-image-fit"), exports);
|
|
273
|
+
__exportStar(require("./constants/ps-image-config"), exports);
|
|
274
|
+
__exportStar(require("./models/ps-image-state-data"), exports);
|
|
275
|
+
__exportStar(require("./services/ps-image-service"), exports);
|
|
276
|
+
__exportStar(require("./components/ps-image"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PsCursorPagesState } from '../models/ps-cursor-pages-state';
|
|
2
|
+
export declare class PsCursorPagesService {
|
|
3
|
+
static append<Row>(existing: Row[], page: Row[], keyOf?: (row: Row) => string): Row[];
|
|
4
|
+
static hasMore(pageLength: number, pageSize: number): boolean;
|
|
5
|
+
static initialState<Row>(): PsCursorPagesState<Row>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsCursorPagesService = void 0;
|
|
4
|
+
class PsCursorPagesService {
|
|
5
|
+
static append(existing, page, keyOf) {
|
|
6
|
+
if (keyOf === undefined)
|
|
7
|
+
return [...existing, ...page];
|
|
8
|
+
const known = new Set(existing.map(keyOf));
|
|
9
|
+
return [...existing, ...page.filter((row) => !known.has(keyOf(row)))];
|
|
10
|
+
}
|
|
11
|
+
static hasMore(pageLength, pageSize) {
|
|
12
|
+
return pageLength >= pageSize;
|
|
13
|
+
}
|
|
14
|
+
static initialState() {
|
|
15
|
+
return { error: null, hasMore: false, isLoadingMore: false, rows: [], settled: null };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.PsCursorPagesService = PsCursorPagesService;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PsDraftStateOptions } from '../interfaces/ps-draft-state-options';
|
|
2
|
+
import type { PsDraftStateData } from '../models/ps-draft-state-data';
|
|
3
|
+
export declare class PsDraftStateService {
|
|
4
|
+
static fresh<Value>(initial: Value): PsDraftStateData<Value>;
|
|
5
|
+
static isEqual<Value>(left: Value, right: Value, options: PsDraftStateOptions<Value> | undefined): boolean;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsDraftStateService = void 0;
|
|
4
|
+
const ps_deep_equal_service_1 = require("./ps-deep-equal-service");
|
|
5
|
+
class PsDraftStateService {
|
|
6
|
+
static fresh(initial) {
|
|
7
|
+
return { baseline: initial, value: structuredClone(initial) };
|
|
8
|
+
}
|
|
9
|
+
static isEqual(left, right, options) {
|
|
10
|
+
if (options !== undefined && options.isEqual !== undefined)
|
|
11
|
+
return options.isEqual(left, right);
|
|
12
|
+
return ps_deep_equal_service_1.PsDeepEqualService.isEqual(left, right);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.PsDraftStateService = PsDraftStateService;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PsImageStatus } from '../constants/ps-image-status';
|
|
2
|
+
import type { PsImageStateData } from '../models/ps-image-state-data';
|
|
3
|
+
export declare class PsImageService {
|
|
4
|
+
static resolve(state: PsImageStateData, src: string): PsImageStatus;
|
|
5
|
+
static statusOf(element: HTMLImageElement): PsImageStatus;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsImageService = void 0;
|
|
4
|
+
const ps_image_status_1 = require("../constants/ps-image-status");
|
|
5
|
+
class PsImageService {
|
|
6
|
+
static resolve(state, src) {
|
|
7
|
+
return state.src === src ? state.status : ps_image_status_1.PsImageStatus.Loading;
|
|
8
|
+
}
|
|
9
|
+
static statusOf(element) {
|
|
10
|
+
if (!element.complete)
|
|
11
|
+
return ps_image_status_1.PsImageStatus.Loading;
|
|
12
|
+
return element.naturalWidth > 0 ? ps_image_status_1.PsImageStatus.Loaded : ps_image_status_1.PsImageStatus.Error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.PsImageService = PsImageService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PsOptimisticChanges } from '../interfaces/ps-optimistic-changes';
|
|
2
2
|
export declare class PsOptimisticReleaseService {
|
|
3
3
|
static empty<Row, Change>(rows: Row[]): PsOptimisticChanges<Row, Change>;
|
|
4
|
-
static next<Row, Change>(remembered: PsOptimisticChanges<Row, Change>, rows: Row[], isActive: boolean, apply: (rows: Row[], changes: Change[]) => Row[]): PsOptimisticChanges<Row, Change>;
|
|
4
|
+
static next<Row, Change>(remembered: PsOptimisticChanges<Row, Change>, rows: Row[], isActive: boolean, isHolding: boolean, apply: (rows: Row[], changes: Change[]) => Row[]): PsOptimisticChanges<Row, Change>;
|
|
5
5
|
}
|
|
@@ -4,13 +4,16 @@ exports.PsOptimisticReleaseService = void 0;
|
|
|
4
4
|
const ps_deep_equal_service_1 = require("./ps-deep-equal-service");
|
|
5
5
|
class PsOptimisticReleaseService {
|
|
6
6
|
static empty(rows) {
|
|
7
|
-
return { base: rows, changes: [], drainBase: null, wasActive: false };
|
|
7
|
+
return { base: rows, changes: [], drainBase: null, wasActive: false, wasHolding: false };
|
|
8
8
|
}
|
|
9
|
-
static next(remembered, rows, isActive, apply) {
|
|
9
|
+
static next(remembered, rows, isActive, isHolding, apply) {
|
|
10
10
|
if (isActive) {
|
|
11
|
-
|
|
11
|
+
const wasHolding = remembered.wasHolding || isHolding;
|
|
12
|
+
if (remembered.wasActive &&
|
|
13
|
+
remembered.drainBase === null &&
|
|
14
|
+
remembered.wasHolding === wasHolding)
|
|
12
15
|
return remembered;
|
|
13
|
-
return { ...remembered, drainBase: null, wasActive: true };
|
|
16
|
+
return { ...remembered, drainBase: null, wasActive: true, wasHolding };
|
|
14
17
|
}
|
|
15
18
|
if (remembered.changes.length === 0) {
|
|
16
19
|
if (remembered.base === rows && !remembered.wasActive)
|
|
@@ -18,10 +21,13 @@ class PsOptimisticReleaseService {
|
|
|
18
21
|
return PsOptimisticReleaseService.empty(rows);
|
|
19
22
|
}
|
|
20
23
|
if (remembered.wasActive) {
|
|
24
|
+
if (remembered.wasHolding && rows !== remembered.base) {
|
|
25
|
+
return PsOptimisticReleaseService.empty(rows);
|
|
26
|
+
}
|
|
21
27
|
if (!ps_deep_equal_service_1.PsDeepEqualService.isEqual(rows, remembered.base)) {
|
|
22
28
|
return PsOptimisticReleaseService.empty(rows);
|
|
23
29
|
}
|
|
24
|
-
return { ...remembered, drainBase: rows, wasActive: false };
|
|
30
|
+
return { ...remembered, drainBase: rows, wasActive: false, wasHolding: false };
|
|
25
31
|
}
|
|
26
32
|
const reference = remembered.drainBase === null ? remembered.base : remembered.drainBase;
|
|
27
33
|
if (!ps_deep_equal_service_1.PsDeepEqualService.isEqual(rows, reference)) {
|