@tailorkit/react 0.1.0-beta.19 → 0.1.0-beta.21
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/README.md +3 -0
- package/dist/components/context.d.ts +1 -1
- package/dist/components/slot.d.ts +20 -11
- package/dist/hooks/use-apps.d.ts +5 -4
- package/dist/hooks/use-slot-instances.d.ts +7 -7
- package/dist/index.js +195 -794
- package/dist/remote-context.d.ts +1 -1
- package/dist/scope-query.d.ts +1 -5
- package/dist/slot-view.d.ts +1 -22
- package/dist/tailorkit.d.ts +5 -36
- package/package.json +6 -5
- package/dist/node-store.d.ts +0 -16
- package/dist/preview-manager.d.ts +0 -11
- package/dist/store.d.ts +0 -43
- package/dist/view-registry.d.ts +0 -14
package/README.md
ADDED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { ViewInstance } from "@tailorkit/app/client";
|
|
1
2
|
import type { SlotDefinitions, ViewDefinition } from "@tailorkit/core/schema";
|
|
2
3
|
import type { ReactNode } from "react";
|
|
3
4
|
import type { ViewContext, ViewName } from "../hooks/use-register-view";
|
|
4
|
-
import type { SlotInstance } from "../hooks/use-slot-instances";
|
|
5
5
|
import type { TailorKitApp } from "../tailorkit";
|
|
6
6
|
type DefaultViews = Record<`/${string}`, ViewDefinition>;
|
|
7
7
|
type ContextPaths<TViews extends Record<string, ViewDefinition>, TView extends ViewName<TViews>> = {
|
|
@@ -11,24 +11,33 @@ type ContextFields<TView> = undefined extends ViewContext<TView> ? Partial<Exclu
|
|
|
11
11
|
export type SlotContext<TViews extends Record<string, ViewDefinition>, TView extends ViewName<TViews>> = {
|
|
12
12
|
[P in ContextPaths<TViews, TView>]: (context: ContextFields<TViews[P]>) => void;
|
|
13
13
|
}[ContextPaths<TViews, TView>] extends (context: infer TContext) => void ? TContext : never;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
14
|
+
type InstanceProps<TSlot, TKey extends string, TValue> = boolean extends (TSlot extends {
|
|
15
|
+
multiple?: infer T;
|
|
16
|
+
} ? T : false) ? {
|
|
17
|
+
[K in TKey]?: TValue;
|
|
18
|
+
} : TSlot extends {
|
|
19
|
+
multiple: true;
|
|
20
|
+
} ? {
|
|
21
|
+
[K in TKey]: TValue;
|
|
22
|
+
} : {
|
|
23
|
+
[K in TKey]?: never;
|
|
24
|
+
};
|
|
25
|
+
export type SlotProps<TSlots extends SlotDefinitions = SlotDefinitions> = {
|
|
26
|
+
[TSlot in keyof TSlots & string]: {
|
|
27
|
+
app: TailorKitApp;
|
|
28
|
+
name: TSlot;
|
|
29
|
+
} & InstanceProps<TSlots[TSlot], "instanceKey", string>;
|
|
30
|
+
}[keyof TSlots & string];
|
|
21
31
|
export type ControlledSlotProps<TViews extends Record<string, ViewDefinition> = DefaultViews, TSlots extends SlotDefinitions = SlotDefinitions> = {
|
|
22
32
|
[TSlot in keyof TSlots & string]: {
|
|
23
33
|
[TView in Extract<ViewName<TViews>, TSlots[TSlot]["views"][number]>]: {
|
|
24
34
|
app: TailorKitApp;
|
|
25
35
|
name: TSlot;
|
|
26
36
|
view: TView;
|
|
27
|
-
} & ({
|
|
37
|
+
} & (({
|
|
28
38
|
context: SlotContext<TViews, TView>;
|
|
29
39
|
status: "ready";
|
|
30
|
-
|
|
31
|
-
} | {
|
|
40
|
+
} & InstanceProps<TSlots[TSlot], "instance", ViewInstance>) | {
|
|
32
41
|
context?: never;
|
|
33
42
|
status: "loading" | "error";
|
|
34
43
|
instance?: never;
|
package/dist/hooks/use-apps.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { TailorKitApp } from "../tailorkit";
|
|
2
|
-
import type { TailorKitAppsSnapshot, TailorKitStore } from "
|
|
3
|
-
export interface UseAppsOptions<TScopeNames extends string = string> {
|
|
2
|
+
import type { FetchCacheOptions, TailorKitAppsSnapshot, TailorKitStore } from "@tailorkit/client-core";
|
|
3
|
+
export interface UseAppsOptions<TScopeNames extends string = string> extends Pick<FetchCacheOptions, "staleTime"> {
|
|
4
4
|
scopes?: readonly TScopeNames[];
|
|
5
5
|
appIds?: readonly string[];
|
|
6
6
|
}
|
|
7
7
|
export interface UseAppsResult {
|
|
8
8
|
data: TailorKitApp[] | undefined;
|
|
9
9
|
error: Error | null;
|
|
10
|
+
isFetching: boolean;
|
|
10
11
|
isError: boolean;
|
|
11
12
|
isLoading: boolean;
|
|
12
13
|
isPending: boolean;
|
|
@@ -16,6 +17,6 @@ export interface UseAppsResult {
|
|
|
16
17
|
}
|
|
17
18
|
export declare function useApps(options?: UseAppsOptions): UseAppsResult;
|
|
18
19
|
export declare function useAppsStore(store: TailorKitStore, options?: UseAppsOptions): UseAppsResult;
|
|
19
|
-
export
|
|
20
|
-
export declare function useAppsSnapshot(store: TailorKitStore): TailorKitAppsSnapshot;
|
|
20
|
+
export { matchesApp } from "@tailorkit/client-core";
|
|
21
|
+
export declare function useAppsSnapshot(store: TailorKitStore, options?: Pick<FetchCacheOptions, "staleTime">): TailorKitAppsSnapshot;
|
|
21
22
|
export declare function toUseAppsResult(snapshot: TailorKitAppsSnapshot, refetch: () => Promise<void>): UseAppsResult;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TailorKitApp } from "../tailorkit";
|
|
1
|
+
import type { FetchCacheOptions, TailorKitApp, SlotInstance } from "@tailorkit/client-core";
|
|
3
2
|
import type { UseAppsResult } from "./use-apps";
|
|
4
|
-
export type SlotInstance
|
|
5
|
-
export interface UseSlotInstancesOptions<TSlot extends string = string> {
|
|
6
|
-
app: TailorKitApp;
|
|
3
|
+
export type { SlotInstance } from "@tailorkit/client-core";
|
|
4
|
+
export interface UseSlotInstancesOptions<TSlot extends string = string> extends FetchCacheOptions {
|
|
7
5
|
slot: TSlot;
|
|
8
6
|
}
|
|
9
7
|
export interface UseSlotInstancesResult extends Omit<UseAppsResult, "data"> {
|
|
10
8
|
data: SlotInstance[] | undefined;
|
|
11
9
|
}
|
|
12
|
-
/**
|
|
13
|
-
export declare function useSlotInstances({
|
|
10
|
+
/** Resolve instances across discovered apps while sharing endpoint state in client-core. */
|
|
11
|
+
export declare function useSlotInstances({ slot, staleTime, gcTime, }: UseSlotInstancesOptions): UseSlotInstancesResult;
|
|
12
|
+
/** Managed Slot resolves only its explicitly supplied app. */
|
|
13
|
+
export declare function useAppSlotInstances(app: TailorKitApp, slot: string): UseSlotInstancesResult;
|