@tailorkit/react 0.1.0-beta.2 → 0.1.0-beta.22
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.md +201 -0
- package/README.md +3 -0
- package/dist/components/context.d.ts +5 -8
- package/dist/components/index.d.ts +1 -1
- package/dist/components/render.d.ts +0 -1
- package/dist/components/root.d.ts +3 -5
- package/dist/components/slot.d.ts +51 -0
- package/dist/hooks/use-apps.d.ts +12 -3
- package/dist/hooks/use-register-view.d.ts +25 -0
- package/dist/hooks/use-slot.d.ts +13 -0
- package/dist/hooks/use-stable-context.d.ts +2 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +513 -517
- package/dist/primitives.d.ts +10 -19
- package/dist/remote-context.d.ts +3 -4
- package/dist/remote-view.d.ts +8 -4
- package/dist/scope-query.d.ts +1 -0
- package/dist/slot-view.d.ts +1 -0
- package/dist/tailorkit.d.ts +81 -0
- package/package.json +16 -24
- package/LICENSE +0 -674
- package/dist/components/context.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/render.d.ts.map +0 -1
- package/dist/components/root.d.ts.map +0 -1
- package/dist/hooks/use-apps.d.ts.map +0 -1
- package/dist/hooks/use-current-screen.d.ts +0 -24
- package/dist/hooks/use-current-screen.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/node-store.d.ts +0 -17
- package/dist/node-store.d.ts.map +0 -1
- package/dist/primitives.d.ts.map +0 -1
- package/dist/remote-context.d.ts.map +0 -1
- package/dist/remote-view.d.ts.map +0 -1
- package/dist/tailor-kit.d.ts +0 -117
- package/dist/tailor-kit.d.ts.map +0 -1
package/dist/primitives.d.ts
CHANGED
|
@@ -2,37 +2,28 @@ import type { CSSProperties, ReactNode } from "react";
|
|
|
2
2
|
import type { TailorKitTheme } from "@tailorkit/core/schema";
|
|
3
3
|
type PrimitiveProps = Record<string, unknown>;
|
|
4
4
|
interface PrimitiveThemeContextValue {
|
|
5
|
-
|
|
5
|
+
viewId: string;
|
|
6
6
|
theme: TailorKitTheme;
|
|
7
7
|
}
|
|
8
8
|
export declare const PrimitiveThemeContext: import("react").Context<PrimitiveThemeContextValue | null>;
|
|
9
|
-
export declare const buildThemeCss: (
|
|
9
|
+
export declare const buildThemeCss: (viewId: string, theme: TailorKitTheme) => string;
|
|
10
10
|
export declare const primitives: {
|
|
11
|
-
readonly Box: ({ props,
|
|
11
|
+
readonly Box: ({ props, children }: {
|
|
12
12
|
props: PrimitiveProps;
|
|
13
|
-
|
|
14
|
-
default?: ReactNode;
|
|
15
|
-
};
|
|
13
|
+
children?: ReactNode;
|
|
16
14
|
}) => import("react").JSX.Element;
|
|
17
|
-
readonly Flex: ({ props,
|
|
15
|
+
readonly Flex: ({ props, children }: {
|
|
18
16
|
props: PrimitiveProps;
|
|
19
|
-
|
|
20
|
-
default?: ReactNode;
|
|
21
|
-
};
|
|
17
|
+
children?: ReactNode;
|
|
22
18
|
}) => import("react").JSX.Element;
|
|
23
|
-
readonly Grid: ({ props,
|
|
19
|
+
readonly Grid: ({ props, children }: {
|
|
24
20
|
props: PrimitiveProps;
|
|
25
|
-
|
|
26
|
-
default?: ReactNode;
|
|
27
|
-
};
|
|
21
|
+
children?: ReactNode;
|
|
28
22
|
}) => import("react").JSX.Element;
|
|
29
|
-
readonly Inline: ({ props,
|
|
23
|
+
readonly Inline: ({ props, children }: {
|
|
30
24
|
props: PrimitiveProps;
|
|
31
|
-
|
|
32
|
-
default?: ReactNode;
|
|
33
|
-
};
|
|
25
|
+
children?: ReactNode;
|
|
34
26
|
}) => import("react").JSX.Element;
|
|
35
27
|
};
|
|
36
28
|
export type PrimitiveStyle = CSSProperties;
|
|
37
29
|
export {};
|
|
38
|
-
//# sourceMappingURL=primitives.d.ts.map
|
package/dist/remote-context.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NodeStore } from "
|
|
1
|
+
import type { HostToIframePayload } from "@tailorkit/sandbox/protocol";
|
|
2
|
+
import type { NodeStore } from "@tailorkit/client-core";
|
|
3
3
|
export interface RemoteViewContext {
|
|
4
4
|
components: Record<string, unknown>;
|
|
5
|
-
dispatch: (payload:
|
|
5
|
+
dispatch: (payload: HostToIframePayload) => void;
|
|
6
6
|
store: NodeStore;
|
|
7
7
|
}
|
|
8
8
|
export declare const RemoteUIContext: import("react").Context<RemoteViewContext | null>;
|
|
9
|
-
//# sourceMappingURL=remote-context.d.ts.map
|
package/dist/remote-view.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import type { Session } from "@tailorkit/app/client";
|
|
1
2
|
import type { ReactNode } from "react";
|
|
2
3
|
interface RemoteViewHostProps {
|
|
3
4
|
appUrl: string | URL;
|
|
5
|
+
sourceText?: string;
|
|
6
|
+
getBackendSession?: (options: {
|
|
7
|
+
refresh: boolean;
|
|
8
|
+
}) => Promise<Session>;
|
|
4
9
|
components: Record<string, unknown>;
|
|
5
10
|
createIframe?: () => HTMLIFrameElement;
|
|
6
11
|
props?: Record<string, unknown>;
|
|
7
|
-
runtimeUrl?: string | URL;
|
|
8
12
|
}
|
|
9
|
-
export declare function RemoteViewHost({ appUrl, components, createIframe, props,
|
|
13
|
+
export declare function RemoteViewHost({ appUrl, sourceText, getBackendSession, components, createIframe, props, }: RemoteViewHostProps): ReactNode;
|
|
10
14
|
interface RemoteViewProps {
|
|
11
15
|
nodeId: string;
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
declare function RemoteViewComponent({ nodeId }: RemoteViewProps): ReactNode;
|
|
18
|
+
export declare const RemoteView: import("react").MemoExoticComponent<typeof RemoteViewComponent>;
|
|
14
19
|
export {};
|
|
15
|
-
//# sourceMappingURL=remote-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { appendScopeSelection, normalizeScopeSelection } from "@tailorkit/client-core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolveSlotView, selectSlotView } from "@tailorkit/client-core";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TailorKitFetchClient, TailorKitCacheOptions } from "@tailorkit/client-core";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { TailorKitTheme, CallbackMap, ComponentDefinition, ComponentProps, Schema, ViewDefinition, SlotDefinitions, TailorKitSchema } from "@tailorkit/core/schema";
|
|
4
|
+
import type { primitives } from "./primitives";
|
|
5
|
+
import type { UseRegisterView } from "./hooks/use-register-view";
|
|
6
|
+
import type { UseAppsOptions, UseAppsResult } from "./hooks/use-apps";
|
|
7
|
+
import type { UseSlotOptions, UseSlotResult } from "./hooks/use-slot";
|
|
8
|
+
import type { SlotComponent } from "./components/slot";
|
|
9
|
+
type AnyComponentDefinition = ComponentDefinition<Schema | undefined, CallbackMap, boolean | undefined>;
|
|
10
|
+
type ComponentRenderer<TComponent extends AnyComponentDefinition> = (args: {
|
|
11
|
+
props: ComponentProps<TComponent>;
|
|
12
|
+
children?: TComponent extends {
|
|
13
|
+
children: true;
|
|
14
|
+
} ? ReactNode : never;
|
|
15
|
+
}) => ReactNode;
|
|
16
|
+
type ComponentRenderers<TComponents extends Record<string, AnyComponentDefinition>> = {
|
|
17
|
+
[TName in keyof TComponents]?: ComponentRenderer<TComponents[TName]>;
|
|
18
|
+
};
|
|
19
|
+
type CompleteComponentRenderers<TComponents extends Record<string, AnyComponentDefinition>> = {
|
|
20
|
+
[TName in keyof TComponents]-?: ComponentRenderer<TComponents[TName]>;
|
|
21
|
+
};
|
|
22
|
+
export type { TailorKitApp } from "@tailorkit/client-core";
|
|
23
|
+
export interface TailorKitClientConfig {
|
|
24
|
+
readonly baseUrl: string | URL;
|
|
25
|
+
readonly fetchClient?: TailorKitFetchClient;
|
|
26
|
+
readonly components: Record<string, unknown>;
|
|
27
|
+
readonly theme: TailorKitTheme;
|
|
28
|
+
}
|
|
29
|
+
export interface TailorKitInstance<TViews extends Record<string, ViewDefinition> = Record<string, ViewDefinition>, TSlots extends SlotDefinitions = SlotDefinitions, TScopeNames extends string = string> extends TailorKitClientConfig {
|
|
30
|
+
readonly $slots?: TSlots;
|
|
31
|
+
readonly $views?: TViews;
|
|
32
|
+
readonly Slot: SlotComponent<TViews, TSlots>;
|
|
33
|
+
readonly useApps: (options?: UseAppsOptions<TScopeNames>) => UseAppsResult;
|
|
34
|
+
readonly useSlot: <TSlot extends keyof TSlots & string>(options: UseSlotOptions<TScopeNames, TSlot>) => UseSlotResult<SlotMultiple<TSlots[TSlot]>>;
|
|
35
|
+
readonly useRegisterView: UseRegisterView<TViews>;
|
|
36
|
+
}
|
|
37
|
+
type SlotMultiple<TSlot> = TSlot extends {
|
|
38
|
+
multiple: infer TMultiple extends boolean;
|
|
39
|
+
} ? TMultiple : TSlot extends {
|
|
40
|
+
multiple?: infer TMultiple extends boolean;
|
|
41
|
+
} ? TMultiple | false : false;
|
|
42
|
+
type PrimitiveRenderers = typeof primitives;
|
|
43
|
+
type CustomComponentRenderers<TComponents extends Record<string, AnyComponentDefinition>> = {
|
|
44
|
+
[TName in Exclude<keyof TComponents, keyof PrimitiveRenderers>]?: ComponentRenderer<TComponents[TName]>;
|
|
45
|
+
};
|
|
46
|
+
export declare function components<TComponents extends Record<string, AnyComponentDefinition>>(_schema: TailorKitSchema<TComponents, Record<string, ViewDefinition>>, customComponents: CustomComponentRenderers<TComponents>): ComponentRenderers<TComponents>;
|
|
47
|
+
interface TailorKitServerShape {
|
|
48
|
+
$internal: {
|
|
49
|
+
schema: {
|
|
50
|
+
components: Record<string, unknown>;
|
|
51
|
+
views: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
type ServerComponentMap<TTailor extends TailorKitServerShape> = TTailor["$internal"]["schema"]["components"];
|
|
56
|
+
type ServerComponents<TTailor extends TailorKitServerShape> = {
|
|
57
|
+
[TName in keyof ServerComponentMap<TTailor>]: ServerComponentMap<TTailor>[TName] extends AnyComponentDefinition ? ServerComponentMap<TTailor>[TName] : never;
|
|
58
|
+
};
|
|
59
|
+
type ServerViewMap<TTailor extends TailorKitServerShape> = TTailor["$internal"]["schema"]["views"];
|
|
60
|
+
type ServerScopeNames<TTailor extends TailorKitServerShape> = TTailor extends {
|
|
61
|
+
handler: (request: Request, options: infer TOptions) => unknown;
|
|
62
|
+
} ? TOptions extends {
|
|
63
|
+
authenticate: infer TAuthenticate;
|
|
64
|
+
} ? TAuthenticate extends (...args: infer _TArgs) => infer TResult ? Extract<Awaited<TResult>, {
|
|
65
|
+
scopes: unknown;
|
|
66
|
+
}> extends {
|
|
67
|
+
scopes: infer TScopes;
|
|
68
|
+
} ? keyof TScopes & string : never : never : never : never;
|
|
69
|
+
type ServerViews<TTailor extends TailorKitServerShape> = {
|
|
70
|
+
[TName in keyof ServerViewMap<TTailor>]: ServerViewMap<TTailor>[TName] extends ViewDefinition ? ServerViewMap<TTailor>[TName] : never;
|
|
71
|
+
};
|
|
72
|
+
export declare function createTailorKitClient<TTailor extends TailorKitServerShape>(options: {
|
|
73
|
+
baseUrl: string | URL;
|
|
74
|
+
components?: CompleteComponentRenderers<ServerComponents<TTailor>>;
|
|
75
|
+
theme?: TailorKitTheme;
|
|
76
|
+
cache?: TailorKitCacheOptions;
|
|
77
|
+
fetch?: typeof fetch;
|
|
78
|
+
}): TailorKitInstance<ServerViews<TTailor>, TTailor extends {
|
|
79
|
+
readonly $slots?: infer V extends SlotDefinitions;
|
|
80
|
+
} ? V : SlotDefinitions, ServerScopeNames<TTailor>>;
|
|
81
|
+
export type { ViewOptions } from "./hooks/use-register-view";
|
package/package.json
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailorkit/react",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "0.1.0-beta.22",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/tailorkit-labs/TailorKit.git",
|
|
8
8
|
"directory": "packages/react"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"type": "module",
|
|
14
|
-
"imports": {
|
|
15
|
-
"#*": [
|
|
16
|
-
"./src/*",
|
|
17
|
-
"./src/*.ts",
|
|
18
|
-
"./src/*.tsx",
|
|
19
|
-
"./src/*/index.ts",
|
|
20
|
-
"./src/*/index.tsx"
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
14
|
"exports": {
|
|
24
15
|
".": {
|
|
25
|
-
"development": "./src/index.ts",
|
|
26
16
|
"types": "./dist/index.d.ts",
|
|
27
17
|
"import": "./dist/index.js"
|
|
28
18
|
}
|
|
@@ -33,20 +23,22 @@
|
|
|
33
23
|
"dependencies": {
|
|
34
24
|
"@floating-ui/react-dom": "^2.1.9",
|
|
35
25
|
"@standard-schema/spec": "^1.1.0",
|
|
36
|
-
"@tailorkit/
|
|
37
|
-
"@tailorkit/
|
|
26
|
+
"@tailorkit/app": "0.1.0-beta.22",
|
|
27
|
+
"@tailorkit/client-core": "0.1.0-beta.22",
|
|
28
|
+
"@tailorkit/client-platform": "0.1.0-beta.22",
|
|
29
|
+
"@tailorkit/core": "0.1.0-beta.22",
|
|
30
|
+
"@tailorkit/sandbox": "0.1.0-beta.22"
|
|
38
31
|
},
|
|
39
32
|
"devDependencies": {
|
|
40
33
|
"@tailorkit/config": "0.0.0",
|
|
41
|
-
"@testing-library/react": "^16.3.
|
|
42
|
-
"@types/node": "26.
|
|
43
|
-
"@types/react": "^19.
|
|
44
|
-
"happy-dom": "^20.
|
|
45
|
-
"react": "^19.
|
|
46
|
-
"react-dom": "^19.
|
|
34
|
+
"@testing-library/react": "^16.3.3",
|
|
35
|
+
"@types/node": "26.6.4",
|
|
36
|
+
"@types/react": "^19.3.0",
|
|
37
|
+
"happy-dom": "^20.14.5",
|
|
38
|
+
"react": "^19.3.0",
|
|
39
|
+
"react-dom": "^19.3.0",
|
|
47
40
|
"tsup": "^8.5.1",
|
|
48
|
-
"typescript": "^7.0.2"
|
|
49
|
-
"vitest": "^4.1.11"
|
|
41
|
+
"typescript": "^7.0.2"
|
|
50
42
|
},
|
|
51
43
|
"peerDependencies": {
|
|
52
44
|
"react": ">=19.2.6"
|
|
@@ -54,6 +46,6 @@
|
|
|
54
46
|
"scripts": {
|
|
55
47
|
"build": "tsup src/index.ts --format esm --target node20 --clean && tsc -p tsconfig.build.json",
|
|
56
48
|
"check-types": "tsc --noEmit",
|
|
57
|
-
"test": "
|
|
49
|
+
"test": "vp test run"
|
|
58
50
|
}
|
|
59
51
|
}
|