@sisense/sdk-ui-preact 1.33.0 → 2.0.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/ai.cjs +133 -21
- package/dist/ai.js +1089 -892
- package/dist/index.cjs +30 -17
- package/dist/index.js +4813 -4687
- package/dist/packages/sdk-ui-preact/src/component-adapter/component-adapter.d.ts +6 -8
- package/dist/packages/sdk-ui-preact/src/component-adapter/context-connector.d.ts +6 -12
- package/dist/packages/sdk-ui-preact/src/component-adapter/hook-adapter.d.ts +15 -0
- package/dist/packages/sdk-ui-preact/src/component-adapter/hook-wrapper-component.d.ts +18 -0
- package/dist/packages/sdk-ui-preact/src/component-adapter/index.d.ts +3 -0
- package/dist/packages/sdk-ui-preact/src/component-adapter/types.d.ts +11 -0
- package/dist/packages/sdk-ui-preact/src/component-adapter/utils/create-hook-api-facade.d.ts +31 -0
- package/dist/packages/sdk-ui-preact/src/component-adapter/utils/data-observer.d.ts +12 -0
- package/dist/packages/sdk-ui-preact/src/component-adapter/utils/index.d.ts +3 -0
- package/dist/packages/sdk-ui-preact/src/component-adapter/utils/observable.d.ts +10 -0
- package/dist/packages/sdk-ui-preact/src/index.d.ts +2 -2
- package/dist/packages/sdk-ui-preact/src/render.d.ts +2 -2
- package/dist/{use-common-filters--WPkVexd-14a82a3c.js → use-common-filters-Cmyb86sc-4037986b.js} +22968 -22946
- package/dist/{use-common-filters--WPkVexd-ae572f5f.cjs → use-common-filters-Cmyb86sc-79bec783.cjs} +272 -272
- package/package.json +6 -6
- package/dist/packages/sdk-ui-preact/src/component-adapter/utils.d.ts +0 -5
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { type VNode } from 'preact';
|
|
2
1
|
import { ContextConnector } from './context-connector';
|
|
3
|
-
type ContextData
|
|
4
|
-
type ComponentBuilder = () => VNode;
|
|
2
|
+
import type { AnyComponentFunction, ContextData } from './types';
|
|
5
3
|
/** @internal */
|
|
6
|
-
export declare class ComponentAdapter {
|
|
7
|
-
private
|
|
4
|
+
export declare class ComponentAdapter<Component extends AnyComponentFunction> {
|
|
5
|
+
private component;
|
|
8
6
|
private contextConnectors;
|
|
9
7
|
private rootElement;
|
|
10
8
|
private contexts;
|
|
11
9
|
private subscriptions;
|
|
12
|
-
|
|
10
|
+
private props;
|
|
11
|
+
constructor(component: Component, contextConnectors?: ContextConnector<ContextData>[]);
|
|
13
12
|
private prepareContexts;
|
|
14
13
|
private renderComponentWithContext;
|
|
15
|
-
render(rootElement: HTMLElement): void;
|
|
14
|
+
render(rootElement: HTMLElement, props: Parameters<Component>[0]): void;
|
|
16
15
|
destroy(): void;
|
|
17
16
|
}
|
|
18
|
-
export {};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import
|
|
1
|
+
import { type CustomContextProviderProps } from '@sisense/sdk-ui';
|
|
2
|
+
import { AnyComponentFunction } from './types';
|
|
3
|
+
import { DataObserver } from './utils/data-observer';
|
|
3
4
|
/** @internal */
|
|
4
|
-
export type ContextConnector<
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export type ContextConnector<P extends CustomContextProviderProps<any>> = {
|
|
6
|
+
propsObserver: DataObserver<P>;
|
|
7
|
+
providerComponent: AnyComponentFunction<P>;
|
|
7
8
|
};
|
|
8
|
-
type AbstractContextProviderProps = {
|
|
9
|
-
context?: any;
|
|
10
|
-
error?: Error;
|
|
11
|
-
};
|
|
12
|
-
/** @internal */
|
|
13
|
-
export declare function createContextProviderRenderer<T extends AbstractContextProviderProps>(provider: FunctionComponent<T>): (contextData: T['context'], children: VNode, error?: Error) => VNode<{}>;
|
|
14
|
-
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ContextConnector } from './context-connector';
|
|
2
|
+
import { AnyHookFunction, ContextData } from './types';
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare class HookAdapter<Hook extends AnyHookFunction> {
|
|
5
|
+
private hook;
|
|
6
|
+
private rootElement;
|
|
7
|
+
private componentAdapter;
|
|
8
|
+
private resultObserver;
|
|
9
|
+
private params;
|
|
10
|
+
constructor(hook: Hook, contextConnectors?: ContextConnector<ContextData>[]);
|
|
11
|
+
private handleHookResult;
|
|
12
|
+
run(...params: Parameters<Hook>): void;
|
|
13
|
+
subscribe(listener: (result: ReturnType<Hook>) => void): import("./utils").Subscription;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
import { AnyHookFunction } from './types';
|
|
3
|
+
interface HookWrapperComponentProps<Hook extends AnyHookFunction> {
|
|
4
|
+
/**
|
|
5
|
+
* The hook to call
|
|
6
|
+
*/
|
|
7
|
+
hook: Hook;
|
|
8
|
+
/**
|
|
9
|
+
* The parameters to pass to the hook
|
|
10
|
+
*/
|
|
11
|
+
params: Parameters<Hook>;
|
|
12
|
+
/**
|
|
13
|
+
* The hook result callback function
|
|
14
|
+
*/
|
|
15
|
+
onResult: (result: ReturnType<Hook>) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function HookWrapperComponent<Hook extends AnyHookFunction>({ hook, params, onResult, }: HookWrapperComponentProps<Hook>): null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type VNode } from 'preact';
|
|
2
|
+
export type ContextData = any;
|
|
3
|
+
export type ComponentBuilder = () => VNode;
|
|
4
|
+
export type Context = {
|
|
5
|
+
isReady: boolean;
|
|
6
|
+
data?: ContextData;
|
|
7
|
+
error?: Error;
|
|
8
|
+
};
|
|
9
|
+
export type AnyHookFunction = (...args: any[]) => any;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export type AnyComponentFunction<P = any> = (props: P) => any;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { HookAdapter } from '../hook-adapter';
|
|
2
|
+
import { AnyHookFunction } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the keys of an object `T` whose values are functions.
|
|
5
|
+
*/
|
|
6
|
+
type FunctionKeys<T> = {
|
|
7
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
8
|
+
}[keyof T];
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the names of all functions returned by a given hook.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam Hook - A function that returns an object.
|
|
13
|
+
*/
|
|
14
|
+
type HookApiName<Hook extends AnyHookFunction> = FunctionKeys<ReturnType<Hook>>;
|
|
15
|
+
/**
|
|
16
|
+
* Extracts the parameter types of a specific function (by name) returned from a given hook.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam Hook - A hook function that returns an object.
|
|
19
|
+
* @typeParam Name - The key of the API method within the returned object.
|
|
20
|
+
*/
|
|
21
|
+
type HookApiParameters<Hook extends AnyHookFunction, Name extends HookApiName<Hook> = HookApiName<Hook>> = Parameters<ReturnType<Hook>[Name]>;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts the return type of a specific function (by name) returned from a given hook.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam Hook - A hook function that returns an object.
|
|
26
|
+
* @typeParam Name - The key of the API method within the returned object.
|
|
27
|
+
*/
|
|
28
|
+
type HookApiReturnType<Hook extends AnyHookFunction, Name extends HookApiName<Hook> = HookApiName<Hook>> = ReturnType<ReturnType<Hook>[Name]>;
|
|
29
|
+
export declare function createHookApiFacade<Hook extends AnyHookFunction, Name extends HookApiName<Hook>>(hookAdapter: HookAdapter<Hook>, apiName: Name, shouldReturnHookApiResult: true): (...args: HookApiParameters<Hook, Name>) => Promise<HookApiReturnType<Hook, Name>>;
|
|
30
|
+
export declare function createHookApiFacade<Hook extends AnyHookFunction, Name extends HookApiName<Hook>>(hookAdapter: HookAdapter<Hook>, apiName: Name, shouldReturnHookApiResult?: false): (...args: HookApiParameters<Hook, Name>) => void;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Listener, Subscription } from './observable';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare class DataObserver<T> {
|
|
4
|
+
private data;
|
|
5
|
+
private observable;
|
|
6
|
+
constructor(initialValue?: T);
|
|
7
|
+
subscribe(listener: Listener<T>, immediateTriggerLastData?: boolean): Subscription;
|
|
8
|
+
setValue(newValue: T): void;
|
|
9
|
+
getValue(): T | undefined;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function isDataObserver<T>(object: any): object is DataObserver<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Listener<T> = (newValue: T) => void;
|
|
2
|
+
export interface Subscription {
|
|
3
|
+
unsubscribe: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class Observable<T> {
|
|
6
|
+
private listeners;
|
|
7
|
+
subscribe(listener: Listener<T>): Subscription;
|
|
8
|
+
notify(newValue: T): void;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentChildren, type FunctionComponent, type VNode } from 'preact';
|
|
2
2
|
/** @internal */
|
|
3
3
|
export declare const preactRenderComponent: <P>(rootElement: HTMLDivElement, component: FunctionComponent<P>, componentProps: P) => void;
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare const createElement: <P>(component: FunctionComponent<P>, props: P, children?: ComponentChildren) => VNode;
|
|
6
6
|
/** @internal */
|
|
7
|
-
export declare const createWrapperElement: (nativeElement: HTMLDivElement) =>
|
|
7
|
+
export declare const createWrapperElement: <R = VNode<{}>>(nativeElement: HTMLDivElement) => R;
|
|
8
8
|
type AnyObject = Record<string, any>;
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare const createWrapperElementHandler: <P extends AnyObject>(handler: (props: P) => HTMLDivElement) => (props: P) => VNode<{}>;
|