routelit-client 0.0.1
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/LICENSE +201 -0
- package/README.md +33 -0
- package/dist/client.d.ts +2 -0
- package/dist/components/button.d.ts +6 -0
- package/dist/components/checkbox-group.d.ts +15 -0
- package/dist/components/checkbox.d.ts +6 -0
- package/dist/components/container.d.ts +4 -0
- package/dist/components/dialog.d.ts +7 -0
- package/dist/components/expander.d.ts +9 -0
- package/dist/components/flex.d.ts +12 -0
- package/dist/components/form.d.ts +7 -0
- package/dist/components/fragment.d.ts +6 -0
- package/dist/components/head.d.ts +6 -0
- package/dist/components/heading.d.ts +292 -0
- package/dist/components/image.d.ts +6 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/link.d.ts +7 -0
- package/dist/components/markdown.d.ts +6 -0
- package/dist/components/radio.d.ts +15 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/textarea.d.ts +6 -0
- package/dist/core/actions.d.ts +5 -0
- package/dist/core/component-store.d.ts +13 -0
- package/dist/core/context.d.ts +17 -0
- package/dist/core/initializer.d.ts +3 -0
- package/dist/core/manager.d.ts +40 -0
- package/dist/core/react-renderer.d.ts +8 -0
- package/dist/core/server-api.d.ts +1 -0
- package/dist/lib.d.ts +30 -0
- package/dist/routelit-client.es.dev.js +21081 -0
- package/dist/routelit-client.es.dev.js.map +1 -0
- package/dist/routelit-client.es.js +15376 -0
- package/dist/routelit-client.umd.dev.js +21097 -0
- package/dist/routelit-client.umd.dev.js.map +1 -0
- package/dist/routelit-client.umd.js +15 -0
- package/dist/vite.svg +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
2
|
+
isExternal?: boolean;
|
|
3
|
+
text?: string;
|
|
4
|
+
replace?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function Link({ text, children, id, href, replace, ...props }: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default Link;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type RadioGroupProps = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
flexDirection?: "row" | "col";
|
|
7
|
+
options: Array<{
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
caption?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
} | string>;
|
|
13
|
+
};
|
|
14
|
+
declare const RadioGroup: import("react").NamedExoticComponent<RadioGroupProps>;
|
|
15
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface SelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
|
|
2
|
+
label?: string;
|
|
3
|
+
helperText?: string;
|
|
4
|
+
errorText?: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
id: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
options: Array<{
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
} | string>;
|
|
13
|
+
}
|
|
14
|
+
declare const Select: import("react").NamedExoticComponent<SelectProps>;
|
|
15
|
+
export default Select;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare function TextareaComponent({ id, label, value, ...props }: {
|
|
2
|
+
id: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
} & React.TextareaHTMLAttributes<HTMLTextAreaElement>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const Textarea: import("react").MemoExoticComponent<typeof TextareaComponent>;
|
|
6
|
+
export default Textarea;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function applyAddAction(componentsTree: RouteLitComponent[], action: AddAction): void;
|
|
2
|
+
export declare function applyRemoveAction(componentsTree: RouteLitComponent[], action: RemoveAction): void;
|
|
3
|
+
export declare function applyUpdateAction(componentsTree: RouteLitComponent[], action: UpdateAction): void;
|
|
4
|
+
export declare function prependAddressToActions(actionResponse: ActionsResponse, address: number[]): ActionsResponse;
|
|
5
|
+
export declare function applyActions(componentsTree: RouteLitComponent[], actions: Action[]): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class ComponentStore {
|
|
2
|
+
private listeners;
|
|
3
|
+
private componentStore;
|
|
4
|
+
private version;
|
|
5
|
+
constructor();
|
|
6
|
+
register: (name: string, component: React.ComponentType<any>) => void;
|
|
7
|
+
unregister: (name: string) => void;
|
|
8
|
+
get: (name: string) => import("react").ComponentType<any> | undefined;
|
|
9
|
+
getVersion: () => number;
|
|
10
|
+
subscribe: (listener: (v: number) => void) => () => void;
|
|
11
|
+
notifyListeners: () => void;
|
|
12
|
+
forceUpdate: () => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ComponentStore } from "./component-store";
|
|
2
|
+
import { type RouteLitManager } from "./manager";
|
|
3
|
+
type RouteLitContextType = {
|
|
4
|
+
manager: RouteLitManager;
|
|
5
|
+
componentStore: ComponentStore;
|
|
6
|
+
parentManager?: RouteLitManager;
|
|
7
|
+
};
|
|
8
|
+
export declare const RouteLitContext: import("react").Context<RouteLitContextType>;
|
|
9
|
+
export declare function useRouteLitContext(): RouteLitContextType;
|
|
10
|
+
export declare function useDispatcher(): (event: CustomEvent<UIEventPayload>) => void;
|
|
11
|
+
export declare function useDispatcherWith(id: string, type: string): (data: Record<string, unknown>) => void;
|
|
12
|
+
export declare function useDispatcherWithAttr(id: string, type: string, attr: string): (value: unknown) => void;
|
|
13
|
+
export declare function useFormDispatcher(id: string, type: string): (data: Record<string, unknown>) => void;
|
|
14
|
+
export declare function useFormDispatcherWithAttr(id: string, type: string, attr: string): (value: unknown) => void;
|
|
15
|
+
export declare function useIsLoading(): boolean;
|
|
16
|
+
export declare function useError(): Error | undefined;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type Handler = (args: RouteLitComponent[]) => void;
|
|
2
|
+
type IsLoadingHandler = (args: boolean) => void;
|
|
3
|
+
type ErrorHandler = (args: Error) => void;
|
|
4
|
+
interface RouteLitManagerProps {
|
|
5
|
+
componentsTree?: RouteLitComponent[];
|
|
6
|
+
fragmentId?: string;
|
|
7
|
+
parentManager?: RouteLitManager;
|
|
8
|
+
address?: number[];
|
|
9
|
+
}
|
|
10
|
+
export declare class RouteLitManager {
|
|
11
|
+
private listeners;
|
|
12
|
+
private isLoadingListeners;
|
|
13
|
+
private errorListeners;
|
|
14
|
+
private componentsTree?;
|
|
15
|
+
private _isLoading;
|
|
16
|
+
private _error?;
|
|
17
|
+
private fragmentId?;
|
|
18
|
+
private parentManager?;
|
|
19
|
+
private address?;
|
|
20
|
+
private lastURL?;
|
|
21
|
+
constructor(props: RouteLitManagerProps);
|
|
22
|
+
getLastURL: () => string;
|
|
23
|
+
handleEvent: (e: CustomEvent<UIEventPayload>) => Promise<void>;
|
|
24
|
+
handleError: (e: Error) => void;
|
|
25
|
+
applyActions: (actionsResp: ActionsResponse, shouldNotify?: boolean) => void;
|
|
26
|
+
initialize: () => void;
|
|
27
|
+
handlePopState: () => void;
|
|
28
|
+
terminate: () => void;
|
|
29
|
+
getComponentsTree: () => RouteLitComponent[];
|
|
30
|
+
isLoading: () => boolean;
|
|
31
|
+
getError: () => Error | undefined;
|
|
32
|
+
getAtAddress: (address: number[]) => RouteLitComponent[];
|
|
33
|
+
subscribe: (listener: Handler) => (() => void);
|
|
34
|
+
subscribeIsLoading: (listener: IsLoadingHandler) => (() => void);
|
|
35
|
+
subscribeError: (listener: ErrorHandler) => (() => void);
|
|
36
|
+
private notifyListeners;
|
|
37
|
+
private notifyIsLoading;
|
|
38
|
+
private notifyError;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type RouteLitManager } from "./manager";
|
|
2
|
+
import { type ComponentStore } from "./component-store";
|
|
3
|
+
interface Props {
|
|
4
|
+
manager: RouteLitManager;
|
|
5
|
+
componentStore: ComponentStore;
|
|
6
|
+
}
|
|
7
|
+
declare function ReactRenderer({ manager, componentStore }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default ReactRenderer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sendEvent(event: CustomEvent<UIEventPayload>, fragmentId?: string): Promise<ActionsResponse>;
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as ReactDOM from "react-dom";
|
|
3
|
+
import * as jsxRuntime from "react/jsx-runtime";
|
|
4
|
+
import { ComponentStore } from "./core/component-store";
|
|
5
|
+
import { useDispatcherWith, useDispatcherWithAttr, useFormDispatcherWithAttr, useFormDispatcher, useIsLoading, useError } from "./core/context";
|
|
6
|
+
import { RouteLitManager } from "./core/manager";
|
|
7
|
+
export interface RoutelitClientType {
|
|
8
|
+
manager: RouteLitManager;
|
|
9
|
+
componentStore: ComponentStore;
|
|
10
|
+
useDispatcherWith: typeof useDispatcherWith;
|
|
11
|
+
useDispatcherWithAttr: typeof useDispatcherWithAttr;
|
|
12
|
+
useFormDispatcherWithAttr: typeof useFormDispatcherWithAttr;
|
|
13
|
+
useFormDispatcher: typeof useFormDispatcher;
|
|
14
|
+
useIsLoading: typeof useIsLoading;
|
|
15
|
+
useError: typeof useError;
|
|
16
|
+
}
|
|
17
|
+
declare let manager: RouteLitManager;
|
|
18
|
+
declare let componentStore: ComponentStore;
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
React: typeof React;
|
|
22
|
+
ReactDOM: typeof ReactDOM;
|
|
23
|
+
jsxRuntime: typeof jsxRuntime;
|
|
24
|
+
RoutelitClient?: RoutelitClientType;
|
|
25
|
+
componentStore?: ComponentStore;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export { useDispatcherWith, manager, componentStore, useDispatcherWithAttr, useIsLoading, useError, useFormDispatcherWithAttr, useFormDispatcher, };
|
|
29
|
+
declare const RoutelitClient: RoutelitClientType;
|
|
30
|
+
export { React, ReactDOM, jsxRuntime, RoutelitClient };
|