@pallasoft/ps-core-components 2.46.1 → 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-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-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-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-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-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
|
@@ -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;
|
|
@@ -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;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PsRemoteReadState } from '../models/ps-remote-read-state';
|
|
2
|
+
import type { PsRemoteSettledData } from '../models/ps-remote-settled-data';
|
|
3
|
+
export declare class PsRemoteReadService {
|
|
4
|
+
private static readonly client;
|
|
5
|
+
static initialState<Data>(): PsRemoteReadState<Data>;
|
|
6
|
+
static isPending(settled: PsRemoteSettledData | null, url: string | null, reloadKey: unknown): boolean;
|
|
7
|
+
static read<Data>(url: string, parse: (value: unknown) => Data, signal: AbortSignal): Promise<Data>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsRemoteReadService = void 0;
|
|
4
|
+
const ps_utilities_1 = require("@pallasoft/ps-utilities");
|
|
5
|
+
class PsRemoteReadService {
|
|
6
|
+
static initialState() {
|
|
7
|
+
return { data: null, error: null, settled: null };
|
|
8
|
+
}
|
|
9
|
+
static isPending(settled, url, reloadKey) {
|
|
10
|
+
if (url === null)
|
|
11
|
+
return false;
|
|
12
|
+
return settled === null || settled.url !== url || !Object.is(settled.reloadKey, reloadKey);
|
|
13
|
+
}
|
|
14
|
+
static async read(url, parse, signal) {
|
|
15
|
+
const response = await PsRemoteReadService.client.get(url, {
|
|
16
|
+
responseType: 'json',
|
|
17
|
+
signal,
|
|
18
|
+
});
|
|
19
|
+
return parse(response.data);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PsRemoteReadService = PsRemoteReadService;
|
|
23
|
+
PsRemoteReadService.client = ps_utilities_1.Client.HttpService.createApiClient();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsSignedValueService = void 0;
|
|
4
|
+
const ps_utilities_1 = require("@pallasoft/ps-utilities");
|
|
5
|
+
class PsSignedValueService {
|
|
6
|
+
static direction(value) {
|
|
7
|
+
const sign = ps_utilities_1.Common.DecimalStringService.sign(value);
|
|
8
|
+
if (sign > 0)
|
|
9
|
+
return ps_utilities_1.AmountDirection.In;
|
|
10
|
+
return sign < 0 ? ps_utilities_1.AmountDirection.Out : ps_utilities_1.AmountDirection.Neutral;
|
|
11
|
+
}
|
|
12
|
+
static text(value, format) {
|
|
13
|
+
const body = format === undefined ? value : format(value);
|
|
14
|
+
return ps_utilities_1.Common.DecimalStringService.sign(value) > 0 ? `+${body}` : body;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.PsSignedValueService = PsSignedValueService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pallasoft/ps-core-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.47.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@dnd-kit/utilities": "^3.2.2",
|
|
49
49
|
"@pallasoft/ps-icons": "^1.5.4",
|
|
50
50
|
"@pallasoft/ps-motion-components": "^1.2.2",
|
|
51
|
-
"@pallasoft/ps-utilities": "^2.
|
|
51
|
+
"@pallasoft/ps-utilities": "^2.25.0",
|
|
52
52
|
"@portabletext/react": "^3.2.4",
|
|
53
53
|
"@portabletext/types": "^2.0.13",
|
|
54
54
|
"@radix-ui/react-accordion": "^1.2.12",
|