akanjs 2.3.5-rc.4 → 2.3.5-rc.6
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/constant/constantRegistry.ts +12 -1
- package/fetch/fetchType/buildFetch.type.ts +3 -0
- package/fetch/fetchType/endpointFetch.type.ts +7 -7
- package/package.json +1 -1
- package/signal/sliceInfo.ts +1 -13
- package/types/fetch/fetchType/buildFetch.type.d.ts +2 -0
- package/types/signal/sliceInfo.d.ts +1 -5
- package/types/ui/InfiniteScroll.d.ts +3 -1
- package/types/ui/More.d.ts +3 -1
- package/ui/InfiniteScroll.tsx +2 -2
- package/ui/Load/Units.tsx +6 -4
- package/ui/More.tsx +9 -2
|
@@ -416,7 +416,18 @@ export type ConstantFetchViewOf<Cnst> = Cnst extends {
|
|
|
416
416
|
_StateLight: infer StateLight;
|
|
417
417
|
_StateInsight: infer StateInsight;
|
|
418
418
|
}
|
|
419
|
-
? ConstantFetchView<
|
|
419
|
+
? ConstantFetchView<
|
|
420
|
+
RefName,
|
|
421
|
+
CapRefName,
|
|
422
|
+
Input,
|
|
423
|
+
Full,
|
|
424
|
+
Light,
|
|
425
|
+
Insight,
|
|
426
|
+
PurifiedInput,
|
|
427
|
+
DefaultInput,
|
|
428
|
+
StateLight,
|
|
429
|
+
StateInsight
|
|
430
|
+
>
|
|
420
431
|
: never;
|
|
421
432
|
|
|
422
433
|
export interface ScalarConstantModel<
|
|
@@ -18,6 +18,9 @@ export type FetchProxySignalInput<
|
|
|
18
18
|
|
|
19
19
|
export type FetchSignalInput = FetchProxySignalInput | DatabaseSignal | ServiceSignal;
|
|
20
20
|
|
|
21
|
+
export type IsAny<Type> = 0 extends 1 & Type ? true : false;
|
|
22
|
+
export type SafeFetchPart<Type, Fallback = unknown> = IsAny<Type> extends true ? Fallback : Type;
|
|
23
|
+
|
|
21
24
|
type MergeFetchParts<First, Second> = [First] extends [never]
|
|
22
25
|
? Second
|
|
23
26
|
: [Second] extends [never]
|
|
@@ -62,15 +62,15 @@ type PubsubSubscribeFn<E, Context> = (
|
|
|
62
62
|
]
|
|
63
63
|
) => () => void;
|
|
64
64
|
|
|
65
|
-
type PrimaryFetchFn<E, Context, ReqType = EndpInfoReqType<E>> =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
: never;
|
|
65
|
+
type PrimaryFetchFn<E, Context, ReqType = EndpInfoReqType<E>> = ReqType extends "query" | "mutation"
|
|
66
|
+
? QueryOrMutationFetchFn<E, Context>
|
|
67
|
+
: ReqType extends "message"
|
|
68
|
+
? MessageEmitFn<E, Context>
|
|
69
|
+
: never;
|
|
71
70
|
|
|
72
71
|
type UploadLikeArg = FileList | File | File[];
|
|
73
|
-
type HasUploadLikeArg<Args extends readonly unknown[]> =
|
|
72
|
+
type HasUploadLikeArg<Args extends readonly unknown[]> =
|
|
73
|
+
Extract<Args[number], UploadLikeArg> extends never ? false : true;
|
|
74
74
|
type RestApiArg<Arg> = Arg extends FileList ? FileList : Arg extends File | File[] ? FileList : Arg;
|
|
75
75
|
type RestApiArgs<Args extends readonly unknown[]> = {
|
|
76
76
|
[K in keyof Args]: RestApiArg<Args[K]>;
|
package/package.json
CHANGED
package/signal/sliceInfo.ts
CHANGED
|
@@ -275,19 +275,7 @@ export type SliceBuilder<
|
|
|
275
275
|
> = (
|
|
276
276
|
init: (
|
|
277
277
|
signalOption?: SignalOption,
|
|
278
|
-
) => SliceInfo<
|
|
279
|
-
_Payload["refName"],
|
|
280
|
-
_Input,
|
|
281
|
-
_Full,
|
|
282
|
-
_Light,
|
|
283
|
-
_Insight,
|
|
284
|
-
_Filter,
|
|
285
|
-
_Payload["srvs"],
|
|
286
|
-
[],
|
|
287
|
-
[],
|
|
288
|
-
[],
|
|
289
|
-
[]
|
|
290
|
-
>,
|
|
278
|
+
) => SliceInfo<_Payload["refName"], _Input, _Full, _Light, _Insight, _Filter, _Payload["srvs"], [], [], [], []>,
|
|
291
279
|
) => {
|
|
292
280
|
[key: string]: SliceInfo<_Payload["refName"], _Input, _Full, _Light, _Insight, _Filter, _Payload["srvs"]>;
|
|
293
281
|
};
|
|
@@ -12,6 +12,8 @@ export type FetchProxySignalInput<FetchType = unknown, SliceMetaObj extends Reco
|
|
|
12
12
|
_SliceMetaObj: SliceMetaObj;
|
|
13
13
|
};
|
|
14
14
|
export type FetchSignalInput = FetchProxySignalInput | DatabaseSignal | ServiceSignal;
|
|
15
|
+
export type IsAny<Type> = 0 extends 1 & Type ? true : false;
|
|
16
|
+
export type SafeFetchPart<Type, Fallback = unknown> = IsAny<Type> extends true ? Fallback : Type;
|
|
15
17
|
type MergeFetchParts<First, Second> = [First] extends [never] ? Second : [Second] extends [never] ? First : Assign<First, Second>;
|
|
16
18
|
export type FetchTypeOfSignal<Signal extends FetchSignalInput> = Signal extends {
|
|
17
19
|
_FetchType: infer FetchType;
|
|
@@ -58,10 +58,6 @@ export type SlicePayloadOf<SrvModule extends ServiceModel> = ConstantFetchViewOf
|
|
|
58
58
|
light: unknown;
|
|
59
59
|
insight: unknown;
|
|
60
60
|
} ? SlicePayload<SrvModule["srv"]["refName"], CnstView["input"], CnstView["full"], CnstView["light"], CnstView["insight"], NonNullable<SrvModule["db"]>["_Filter"], SrvModule["srvMap"]> : never;
|
|
61
|
-
export type SliceBuilder<SrvModule extends ServiceModel, _Payload extends SlicePayload = SlicePayloadOf<SrvModule>, _Input = _Payload["input"], _Full = _Payload["full"], _Light = _Payload["light"], _Insight = _Payload["insight"], _Filter extends FilterInstance = _Payload["filter"], _Sort = ExtractSort<_Filter>> = (init: (signalOption?: SignalOption) => SliceInfo<_Payload["refName"], _Input, _Full, _Light, _Insight, _Filter, _Payload["srvs"], [
|
|
62
|
-
], [
|
|
63
|
-
], [
|
|
64
|
-
], [
|
|
65
|
-
]>) => {
|
|
61
|
+
export type SliceBuilder<SrvModule extends ServiceModel, _Payload extends SlicePayload = SlicePayloadOf<SrvModule>, _Input = _Payload["input"], _Full = _Payload["full"], _Light = _Payload["light"], _Insight = _Payload["insight"], _Filter extends FilterInstance = _Payload["filter"], _Sort = ExtractSort<_Filter>> = (init: (signalOption?: SignalOption) => SliceInfo<_Payload["refName"], _Input, _Full, _Light, _Insight, _Filter, _Payload["srvs"], [], [], [], []>) => {
|
|
66
62
|
[key: string]: SliceInfo<_Payload["refName"], _Input, _Full, _Light, _Insight, _Filter, _Payload["srvs"]>;
|
|
67
63
|
};
|
|
@@ -3,7 +3,9 @@ export interface InfiniteScrollProps {
|
|
|
3
3
|
currentPage: number;
|
|
4
4
|
itemsPerPage: number;
|
|
5
5
|
onAddPage: (page: number) => Promise<void>;
|
|
6
|
-
onPageSelect: (page: number
|
|
6
|
+
onPageSelect: (page: number, option?: {
|
|
7
|
+
scrollToTop?: boolean;
|
|
8
|
+
}) => void;
|
|
7
9
|
children: React.ReactNode;
|
|
8
10
|
reverse?: boolean;
|
|
9
11
|
}
|
package/types/ui/More.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ interface MoreProps {
|
|
|
3
3
|
itemsPerPage: number;
|
|
4
4
|
currentPage: number;
|
|
5
5
|
onAddPage: (page: number) => Promise<void>;
|
|
6
|
-
onPageSelect: (page: number
|
|
6
|
+
onPageSelect: (page: number, option?: {
|
|
7
|
+
scrollToTop?: boolean;
|
|
8
|
+
}) => void;
|
|
7
9
|
children?: React.ReactNode;
|
|
8
10
|
className?: string;
|
|
9
11
|
reverse?: boolean;
|
package/ui/InfiniteScroll.tsx
CHANGED
|
@@ -7,7 +7,7 @@ export interface InfiniteScrollProps {
|
|
|
7
7
|
currentPage: number;
|
|
8
8
|
itemsPerPage: number;
|
|
9
9
|
onAddPage: (page: number) => Promise<void>;
|
|
10
|
-
onPageSelect: (page: number) => void;
|
|
10
|
+
onPageSelect: (page: number, option?: { scrollToTop?: boolean }) => void;
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
reverse?: boolean;
|
|
13
13
|
}
|
|
@@ -51,7 +51,7 @@ export const InfiniteScroll = ({
|
|
|
51
51
|
setIsFetching(true);
|
|
52
52
|
try {
|
|
53
53
|
await onAddPage(nextPage);
|
|
54
|
-
onPageSelect(nextPage);
|
|
54
|
+
onPageSelect(nextPage, { scrollToTop: false });
|
|
55
55
|
page.current = nextPage;
|
|
56
56
|
|
|
57
57
|
const restoreScroll = () => {
|
package/ui/Load/Units.tsx
CHANGED
|
@@ -156,11 +156,13 @@ function Render<RefName extends string, Light extends { id: string }>({
|
|
|
156
156
|
onAddPage: async (page: number) => {
|
|
157
157
|
await storeDo[namesOfSlice.addPageOfModel](page);
|
|
158
158
|
},
|
|
159
|
-
onPageSelect: (page: number) => {
|
|
159
|
+
onPageSelect: (page: number, option?: { scrollToTop?: boolean }) => {
|
|
160
160
|
void storeDo[namesOfSlice.setPageOfModel](page);
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
if (option?.scrollToTop !== false) {
|
|
163
|
+
window.parent.postMessage({ type: "pathChange", page }, "*");
|
|
164
|
+
window.scrollTo({ top: 0, behavior: "instant" });
|
|
165
|
+
}
|
|
164
166
|
},
|
|
165
167
|
reverse,
|
|
166
168
|
};
|
|
@@ -279,7 +281,7 @@ interface MoreProps {
|
|
|
279
281
|
itemsPerPage: number;
|
|
280
282
|
currentPage: number;
|
|
281
283
|
onAddPage: (page: number) => Promise<void>;
|
|
282
|
-
onPageSelect: (page: number) => void;
|
|
284
|
+
onPageSelect: (page: number, option?: { scrollToTop?: boolean }) => void;
|
|
283
285
|
children?: React.ReactNode;
|
|
284
286
|
className?: string;
|
|
285
287
|
reverse?: boolean;
|
package/ui/More.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { clsx, isMobileDevice } from "akanjs/client";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
3
4
|
import { InfiniteScroll } from "./InfiniteScroll";
|
|
4
5
|
import { Pagination } from "./Pagination";
|
|
5
6
|
|
|
@@ -8,7 +9,7 @@ interface MoreProps {
|
|
|
8
9
|
itemsPerPage: number;
|
|
9
10
|
currentPage: number;
|
|
10
11
|
onAddPage: (page: number) => Promise<void>;
|
|
11
|
-
onPageSelect: (page: number) => void;
|
|
12
|
+
onPageSelect: (page: number, option?: { scrollToTop?: boolean }) => void;
|
|
12
13
|
children?: React.ReactNode;
|
|
13
14
|
className?: string;
|
|
14
15
|
reverse?: boolean;
|
|
@@ -24,11 +25,17 @@ export const More = ({
|
|
|
24
25
|
className,
|
|
25
26
|
reverse,
|
|
26
27
|
}: MoreProps) => {
|
|
28
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setIsMobile(isMobileDevice());
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
27
34
|
if (total <= itemsPerPage) {
|
|
28
35
|
return <>{children}</>;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
if (
|
|
38
|
+
if (isMobile) {
|
|
32
39
|
return (
|
|
33
40
|
<InfiniteScroll
|
|
34
41
|
total={total}
|