@tailorkit/react 0.1.0-beta.3 → 0.1.0-beta.32

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.
Files changed (50) hide show
  1. package/LICENSE.md +74 -0
  2. package/README.md +3 -0
  3. package/dist/components/context.d.ts +7 -10
  4. package/dist/components/index.d.ts +1 -2
  5. package/dist/components/render-slot.d.ts +9 -0
  6. package/dist/hooks/use-apps.d.ts +6 -13
  7. package/dist/hooks/use-query-result.d.ts +9 -0
  8. package/dist/hooks/use-view-context.d.ts +6 -0
  9. package/dist/hooks/use-views.d.ts +7 -0
  10. package/dist/index.d.ts +7 -3
  11. package/dist/index.js +362 -839
  12. package/dist/primitives.d.ts +11 -21
  13. package/dist/remote-view.d.ts +12 -6
  14. package/dist/tailorkit.d.ts +45 -0
  15. package/package.json +42 -24
  16. package/LICENSE +0 -674
  17. package/dist/components/context.d.ts.map +0 -1
  18. package/dist/components/index.d.ts.map +0 -1
  19. package/dist/components/render.d.ts +0 -20
  20. package/dist/components/render.d.ts.map +0 -1
  21. package/dist/components/root.d.ts +0 -11
  22. package/dist/components/root.d.ts.map +0 -1
  23. package/dist/hooks/use-apps.d.ts.map +0 -1
  24. package/dist/hooks/use-current-screen.d.ts +0 -24
  25. package/dist/hooks/use-current-screen.d.ts.map +0 -1
  26. package/dist/index.d.ts.map +0 -1
  27. package/dist/node-store.d.ts +0 -17
  28. package/dist/node-store.d.ts.map +0 -1
  29. package/dist/primitives.d.ts.map +0 -1
  30. package/dist/remote-context.d.ts +0 -9
  31. package/dist/remote-context.d.ts.map +0 -1
  32. package/dist/remote-view.d.ts.map +0 -1
  33. package/dist/tailor-kit.d.ts +0 -117
  34. package/dist/tailor-kit.d.ts.map +0 -1
  35. package/src/__tests__/node-store.test.ts +0 -206
  36. package/src/__tests__/primitives.test.tsx +0 -85
  37. package/src/__tests__/tailor-kit.test.tsx +0 -424
  38. package/src/__tests__/tailor-kit.types.tsx +0 -151
  39. package/src/components/context.ts +0 -21
  40. package/src/components/index.ts +0 -1
  41. package/src/components/render.tsx +0 -116
  42. package/src/components/root.tsx +0 -37
  43. package/src/hooks/use-apps.ts +0 -47
  44. package/src/hooks/use-current-screen.ts +0 -81
  45. package/src/index.ts +0 -8
  46. package/src/node-store.ts +0 -131
  47. package/src/primitives.tsx +0 -261
  48. package/src/remote-context.ts +0 -11
  49. package/src/remote-view.tsx +0 -232
  50. package/src/tailor-kit.tsx +0 -501
@@ -1,38 +1,28 @@
1
- import type { CSSProperties, ReactNode } from "react";
1
+ import type { PrimitiveProps } from "@tailorkit/client-core";
2
2
  import type { TailorKitTheme } from "@tailorkit/core/schema";
3
- type PrimitiveProps = Record<string, unknown>;
3
+ import type { CSSProperties, ReactNode } from "react";
4
4
  interface PrimitiveThemeContextValue {
5
- screenId: string;
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: (screenId: string, theme: TailorKitTheme) => string;
10
9
  export declare const primitives: {
11
- readonly Box: ({ props, slots }: {
10
+ readonly Box: ({ props, children, }: {
12
11
  props: PrimitiveProps;
13
- slots: {
14
- default?: ReactNode;
15
- };
12
+ children?: ReactNode;
16
13
  }) => import("react").JSX.Element;
17
- readonly Flex: ({ props, slots }: {
14
+ readonly Flex: ({ props, children, }: {
18
15
  props: PrimitiveProps;
19
- slots: {
20
- default?: ReactNode;
21
- };
16
+ children?: ReactNode;
22
17
  }) => import("react").JSX.Element;
23
- readonly Grid: ({ props, slots }: {
18
+ readonly Grid: ({ props, children, }: {
24
19
  props: PrimitiveProps;
25
- slots: {
26
- default?: ReactNode;
27
- };
20
+ children?: ReactNode;
28
21
  }) => import("react").JSX.Element;
29
- readonly Inline: ({ props, slots }: {
22
+ readonly Inline: ({ props, children, }: {
30
23
  props: PrimitiveProps;
31
- slots: {
32
- default?: ReactNode;
33
- };
24
+ children?: ReactNode;
34
25
  }) => import("react").JSX.Element;
35
26
  };
36
27
  export type PrimitiveStyle = CSSProperties;
37
28
  export {};
38
- //# sourceMappingURL=primitives.d.ts.map
@@ -1,15 +1,21 @@
1
+ import type { ToolBridge, Session } from "@tailorkit/app/client";
2
+ import type { RemoteProps } from "@tailorkit/sandbox/protocol";
1
3
  import type { ReactNode } from "react";
2
4
  interface RemoteViewHostProps {
3
5
  appUrl: string | URL;
4
- components: Record<string, unknown>;
6
+ sourceText?: string;
7
+ toolBridge?: ToolBridge;
8
+ getBackendSession?: (options: {
9
+ refresh: boolean;
10
+ }) => Promise<Session>;
11
+ components: RemoteProps;
5
12
  createIframe?: () => HTMLIFrameElement;
6
- props?: Record<string, unknown>;
7
- runtimeUrl?: string | URL;
13
+ props?: RemoteProps;
8
14
  }
9
- export declare function RemoteViewHost({ appUrl, components, createIframe, props, runtimeUrl, }: RemoteViewHostProps): ReactNode;
15
+ export declare const RemoteViewHost: ({ appUrl, sourceText, toolBridge, getBackendSession, components, createIframe, props, }: RemoteViewHostProps) => ReactNode;
10
16
  interface RemoteViewProps {
11
17
  nodeId: string;
12
18
  }
13
- export declare const RemoteView: import("react").MemoExoticComponent<({ nodeId }: RemoteViewProps) => ReactNode>;
19
+ declare const RemoteViewComponent: ({ nodeId }: RemoteViewProps) => ReactNode;
20
+ export declare const RemoteView: import("react").MemoExoticComponent<typeof RemoteViewComponent>;
14
21
  export {};
15
- //# sourceMappingURL=remote-view.d.ts.map
@@ -0,0 +1,45 @@
1
+ import type { AnyComponentDefinition, ComponentRenderer, ComponentRenderers, CompleteComponentRenderers, TailorKitClientConfig, TailorKitApp, SlotMultiple, TailorKitCacheOptions } from "@tailorkit/client-core";
2
+ import type { TailorKitTheme, ViewDefinition, SlotDefinitions, TailorKitContract, ToolImplementations } from "@tailorkit/core/schema";
3
+ import type { ReactNode } from "react";
4
+ import type { RenderSlotComponent } from "./components/render-slot";
5
+ import type { UseAppsOptions, UseAppsResult } from "./hooks/use-apps";
6
+ import type { UseViewContext } from "./hooks/use-view-context";
7
+ import type { UseViewsOptions, UseViewsResult } from "./hooks/use-views";
8
+ import type { primitives } from "./primitives";
9
+ export type { TailorKitClientConfig } from "@tailorkit/client-core";
10
+ export type { TailorKitApp } from "@tailorkit/client-core";
11
+ export interface TailorKitProviderProps {
12
+ apps?: TailorKitApp[];
13
+ children?: ReactNode;
14
+ }
15
+ export interface TailorKitInstance<TViews extends Record<string, ViewDefinition> = Record<string, ViewDefinition>, TSlots extends SlotDefinitions = SlotDefinitions, TScopeNames extends string = string> extends TailorKitClientConfig {
16
+ readonly $slots?: TSlots;
17
+ readonly $views?: TViews;
18
+ readonly Provider: (props: TailorKitProviderProps) => ReactNode;
19
+ readonly RenderSlot: RenderSlotComponent<TViews, TSlots>;
20
+ readonly useApps: (options?: UseAppsOptions<TScopeNames>) => UseAppsResult;
21
+ readonly useViews: <TSlot extends keyof TSlots & string>(options: UseViewsOptions<TScopeNames, TSlot>) => UseViewsResult<SlotMultiple<TSlots[TSlot]>>;
22
+ readonly useViewContext: UseViewContext<TViews>;
23
+ }
24
+ type PrimitiveRenderers = typeof primitives;
25
+ type CustomComponentRenderers<TComponents extends Record<string, AnyComponentDefinition>> = {
26
+ [TName in Exclude<keyof TComponents, keyof PrimitiveRenderers>]?: ComponentRenderer<TComponents[TName], ReactNode>;
27
+ };
28
+ export declare const components: <TComponents extends Record<string, AnyComponentDefinition>>(_contract: {
29
+ components: TComponents;
30
+ }, customComponents: CustomComponentRenderers<TComponents>) => ComponentRenderers<TComponents, ReactNode>;
31
+ export declare const createClient: <const TContract extends TailorKitContract>(options: {
32
+ contract: TContract;
33
+ tools?: ToolImplementations<NoInfer<TContract["tools"]>, "client">;
34
+ baseUrl: string | URL;
35
+ assetsBaseUrl?: string | URL;
36
+ components?: CompleteComponentRenderers<NoInfer<TContract["components"]>, ReactNode>;
37
+ theme?: TailorKitTheme;
38
+ cache?: TailorKitCacheOptions;
39
+ fetch?: typeof fetch;
40
+ } & (keyof ToolImplementations<TContract["tools"], "client"> extends never ? {
41
+ tools?: ToolImplementations<TContract["tools"], "client">;
42
+ } : {
43
+ tools: ToolImplementations<TContract["tools"], "client">;
44
+ })) => TailorKitInstance<TContract["views"], TContract["slots"], keyof TContract["scopes"] & string>;
45
+ export type { ViewOptions } from "./hooks/use-view-context";
package/package.json CHANGED
@@ -1,29 +1,41 @@
1
1
  {
2
2
  "name": "@tailorkit/react",
3
- "version": "0.1.0-beta.3",
4
- "license": "AGPL-3.0-only",
3
+ "version": "0.1.0-beta.32",
4
+ "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/AlfieJones/tailorkit.git",
7
+ "url": "git+https://github.com/TailorKit-Labs/TailorKit.git",
8
8
  "directory": "packages/react"
9
9
  },
10
10
  "files": [
11
- "dist",
12
- "src"
11
+ "dist"
13
12
  ],
14
13
  "type": "module",
15
14
  "imports": {
16
- "#*": [
17
- "./src/*",
18
- "./src/*.ts",
19
- "./src/*.tsx",
20
- "./src/*/index.ts",
21
- "./src/*/index.tsx"
22
- ]
15
+ "#*": {
16
+ "development": [
17
+ "./src/*",
18
+ "./src/*.ts",
19
+ "./src/*.tsx",
20
+ "./src/*/index.ts",
21
+ "./src/*/index.tsx"
22
+ ],
23
+ "types": [
24
+ "./dist/*",
25
+ "./dist/*.d.ts",
26
+ "./dist/*/index.d.ts"
27
+ ],
28
+ "default": [
29
+ "./src/*",
30
+ "./src/*.ts",
31
+ "./src/*.tsx",
32
+ "./src/*/index.ts",
33
+ "./src/*/index.tsx"
34
+ ]
35
+ }
23
36
  },
24
37
  "exports": {
25
38
  ".": {
26
- "development": "./src/index.ts",
27
39
  "types": "./dist/index.d.ts",
28
40
  "import": "./dist/index.js"
29
41
  }
@@ -33,21 +45,25 @@
33
45
  },
34
46
  "dependencies": {
35
47
  "@floating-ui/react-dom": "^2.1.9",
48
+ "@nanostores/react": "2.0.1",
36
49
  "@standard-schema/spec": "^1.1.0",
37
- "@tailorkit/core": "0.1.0-beta.3",
38
- "@tailorkit/sandbox": "0.1.0-beta.3"
50
+ "@tailorkit/app": "0.1.0-beta.32",
51
+ "@tailorkit/client-core": "0.1.0-beta.32",
52
+ "@tailorkit/client-platform": "0.1.0-beta.32",
53
+ "@tailorkit/core": "0.1.0-beta.32",
54
+ "@tailorkit/sandbox": "0.1.0-beta.32",
55
+ "nanostores": "1.5.5"
39
56
  },
40
57
  "devDependencies": {
41
58
  "@tailorkit/config": "0.0.0",
42
- "@testing-library/react": "^16.3.2",
43
- "@types/node": "26.2.0",
44
- "@types/react": "^19.2.18",
45
- "happy-dom": "^20.11.6",
46
- "react": "^19.2.8",
47
- "react-dom": "^19.2.8",
59
+ "@testing-library/react": "^16.3.3",
60
+ "@types/node": "26.6.4",
61
+ "@types/react": "^19.3.0",
62
+ "happy-dom": "^20.14.6",
63
+ "react": "^19.3.0",
64
+ "react-dom": "^19.3.0",
48
65
  "tsup": "^8.5.1",
49
- "typescript": "^7.0.2",
50
- "vitest": "^4.1.11"
66
+ "typescript": "^7.0.2"
51
67
  },
52
68
  "peerDependencies": {
53
69
  "react": ">=19.2.6"
@@ -55,6 +71,8 @@
55
71
  "scripts": {
56
72
  "build": "tsup src/index.ts --format esm --target node20 --clean && tsc -p tsconfig.build.json",
57
73
  "check-types": "tsc --noEmit",
58
- "test": "vitest run"
74
+ "test": "vp test run",
75
+ "lint": "vp lint .",
76
+ "lint:fix": "vp lint --fix ."
59
77
  }
60
78
  }