@sqrzro/ui 4.0.0-alpha.22 → 4.0.0-alpha.25
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.
|
@@ -4,7 +4,7 @@ export interface ActionProps<Data extends object | null = null> extends Omit<Act
|
|
|
4
4
|
readonly label?: React.ReactNode;
|
|
5
5
|
readonly render: (props: ActionComponentProps<Data>) => React.ReactElement;
|
|
6
6
|
}
|
|
7
|
-
export interface ActionComponentProps<Data extends object | null = null> extends Pick<ActionProps<Data>, 'href' | 'icon' | 'isDisabled' | 'isLoading' | 'isSubmittable' | 'onClick' | 'searchParams' | 'variant'> {
|
|
7
|
+
export interface ActionComponentProps<Data extends object | null = null> extends Pick<ActionProps<Data>, 'action' | 'confirmable' | 'data' | 'href' | 'icon' | 'isDisabled' | 'isLoading' | 'isSubmittable' | 'onClick' | 'searchParams' | 'variant'> {
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
declare function Action<Data extends object | null = null>(props: ActionProps<Data>): React.ReactElement;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { NavigationObject } from '../../../navigation/interfaces';
|
|
3
2
|
import type { NextPageProps } from '../../../utility/interfaces';
|
|
3
|
+
type Fn = (params?: Promise<Record<string, string>> | null) => Promise<any>;
|
|
4
|
+
type FnReturn<T extends Fn> = T extends (...args: any[]) => Promise<infer R> ? R : never;
|
|
4
5
|
interface PageTemplateProps {
|
|
5
6
|
children: React.ReactNode;
|
|
6
7
|
tabs: NavigationObject[] | null;
|
|
7
8
|
title: React.ReactNode;
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
10
|
+
export type PageProps<T extends Fn | undefined = undefined> = {
|
|
11
|
+
readonly fn?: T;
|
|
12
|
+
readonly children: React.ReactNode | ((data: T extends Fn ? FnReturn<T> : null, pageProps?: NextPageProps) => React.ReactNode);
|
|
12
13
|
readonly pageProps?: NextPageProps;
|
|
13
|
-
readonly tabs?: NavigationObject[] | ((data: T) => NavigationObject[] | null);
|
|
14
|
+
readonly tabs?: NavigationObject[] | ((data: T extends Fn ? FnReturn<T> : null, pageProps?: NextPageProps) => NavigationObject[] | null);
|
|
14
15
|
readonly template?: (props: PageTemplateProps) => React.ReactElement;
|
|
15
|
-
readonly title?: React.ReactNode | ((data: T) => React.ReactNode);
|
|
16
|
-
}
|
|
17
|
-
declare function Page<T>(props: PageProps<T>):
|
|
16
|
+
readonly title?: React.ReactNode | ((data: T extends Fn ? FnReturn<T> : null, pageProps?: NextPageProps) => React.ReactNode);
|
|
17
|
+
};
|
|
18
|
+
declare function Page<T extends Fn | undefined = undefined>(props: PageProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
export default Page;
|
|
@@ -1,30 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Suspense } from 'react';
|
|
3
|
-
function getChildren(props, data) {
|
|
4
|
-
if (typeof props.children === 'function') {
|
|
5
|
-
return data ? props.children(data) : null;
|
|
6
|
-
}
|
|
7
|
-
return props.children;
|
|
8
|
-
}
|
|
9
|
-
function getTabs(props, data) {
|
|
10
|
-
if (typeof props.tabs === 'function') {
|
|
11
|
-
return data ? props.tabs(data) : null;
|
|
12
|
-
}
|
|
13
|
-
return props.tabs ?? null;
|
|
14
|
-
}
|
|
15
|
-
function getTitle(props, data) {
|
|
16
|
-
if (typeof props.title === 'function') {
|
|
17
|
-
return data ? props.title(data) : null;
|
|
18
|
-
}
|
|
19
|
-
return props.title;
|
|
20
|
-
}
|
|
21
3
|
async function PageComponent(props) {
|
|
22
4
|
const data = props.fn ? await props.fn(props.pageProps?.params) : null;
|
|
23
|
-
const children =
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
const children = typeof props.children === 'function'
|
|
6
|
+
? props.children(data, props.pageProps)
|
|
7
|
+
: props.children;
|
|
8
|
+
const tabs = typeof props.tabs === 'function' ? props.tabs(data, props.pageProps) : props.tabs;
|
|
9
|
+
const title = typeof props.title === 'function' ? props.title(data, props.pageProps) : props.title;
|
|
26
10
|
if (props.template) {
|
|
27
|
-
return props.template({ children, tabs, title });
|
|
11
|
+
return props.template({ children, tabs: tabs ?? null, title });
|
|
28
12
|
}
|
|
29
13
|
return children;
|
|
30
14
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import type { NavigationObject } from '../navigation';
|
|
2
|
+
export interface AppConfigObject {
|
|
3
|
+
app: {
|
|
4
|
+
name: string;
|
|
5
|
+
url: string;
|
|
6
|
+
};
|
|
7
|
+
navigation: NavigationObject[];
|
|
8
|
+
}
|
|
1
9
|
export interface ConfirmableObject {
|
|
2
10
|
actions?: Omit<ActionObject, 'confirmable'>[];
|
|
3
11
|
confirmText?: string;
|
|
@@ -33,6 +41,10 @@ export interface NextLayoutProps {
|
|
|
33
41
|
children: React.ReactNode;
|
|
34
42
|
params?: Promise<Record<string, string>> | null;
|
|
35
43
|
}
|
|
44
|
+
export interface AwaitedNextPageProps {
|
|
45
|
+
params?: Record<string, string> | null;
|
|
46
|
+
searchParams?: Record<string, string> | null;
|
|
47
|
+
}
|
|
36
48
|
export interface NextPageProps {
|
|
37
49
|
params?: Promise<Record<string, string>> | null;
|
|
38
50
|
searchParams?: Promise<Record<string, string>> | null;
|