@capybara-hq/plugin-client 0.1.0-rc.3 → 0.1.0-rc.5
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/design.d.ts +23 -1
- package/dist/design.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/testing/index.js +17 -2
- package/dist/ui-parts.generated.d.ts +1 -1
- package/dist/ui-parts.generated.js +9 -0
- package/package.json +1 -1
package/dist/design.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from "react";
|
|
2
2
|
import type { UiView } from "./types.js";
|
|
3
3
|
/** Every design name this package forwards to the host (one source for the package and its tests). */
|
|
4
|
-
export declare const DESIGN_NAMES: readonly ["Badge", "Button", "Icon", "Kbd", "KeyValue", "Logo", "PropertySection", "Spinner", "Stack", "Text", "Tooltip", "ViewBlocks"];
|
|
4
|
+
export declare const DESIGN_NAMES: readonly ["Badge", "Button", "Icon", "Kbd", "KeyValue", "Logo", "PropertySection", "Select", "Spinner", "Stack", "Text", "Tooltip", "ViewBlocks"];
|
|
5
5
|
type HostDesign = Record<string, ComponentType<never>>;
|
|
6
6
|
interface ClientHostGlobal {
|
|
7
7
|
design: HostDesign;
|
|
@@ -83,6 +83,27 @@ export interface PropertySectionProps {
|
|
|
83
83
|
onRetry?(): void;
|
|
84
84
|
children?: ReactNode;
|
|
85
85
|
}
|
|
86
|
+
export interface SelectOption {
|
|
87
|
+
value: string;
|
|
88
|
+
label: string;
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export interface SelectProps {
|
|
92
|
+
options: SelectOption[];
|
|
93
|
+
value?: string;
|
|
94
|
+
/** The chosen value, as a native select's change event carries it (`.target.value`). */
|
|
95
|
+
onChange?: (e: {
|
|
96
|
+
target: {
|
|
97
|
+
value: string;
|
|
98
|
+
};
|
|
99
|
+
}) => void;
|
|
100
|
+
disabled?: boolean;
|
|
101
|
+
/** Shown while the value matches no option. */
|
|
102
|
+
placeholder?: string;
|
|
103
|
+
density?: "comfortable" | "compact";
|
|
104
|
+
"aria-label"?: string;
|
|
105
|
+
"aria-labelledby"?: string;
|
|
106
|
+
}
|
|
86
107
|
export interface ViewBlocksProps {
|
|
87
108
|
view: UiView;
|
|
88
109
|
}
|
|
@@ -97,6 +118,7 @@ export declare const Stack: ComponentType<StackProps>;
|
|
|
97
118
|
export declare const Text: ComponentType<TextProps>;
|
|
98
119
|
export declare const Tooltip: ComponentType<TooltipProps>;
|
|
99
120
|
export declare const PropertySection: ComponentType<PropertySectionProps>;
|
|
121
|
+
export declare const Select: ComponentType<SelectProps>;
|
|
100
122
|
/** The host's renderer of a `UiView`. */
|
|
101
123
|
export declare const ViewBlocks: ComponentType<ViewBlocksProps>;
|
|
102
124
|
export {};
|
package/dist/design.js
CHANGED
|
@@ -8,6 +8,7 @@ export const DESIGN_NAMES = [
|
|
|
8
8
|
"KeyValue",
|
|
9
9
|
"Logo",
|
|
10
10
|
"PropertySection",
|
|
11
|
+
"Select",
|
|
11
12
|
"Spinner",
|
|
12
13
|
"Stack",
|
|
13
14
|
"Text",
|
|
@@ -45,5 +46,6 @@ export const Stack = forward("Stack");
|
|
|
45
46
|
export const Text = forward("Text");
|
|
46
47
|
export const Tooltip = forward("Tooltip");
|
|
47
48
|
export const PropertySection = forward("PropertySection");
|
|
49
|
+
export const Select = forward("Select");
|
|
48
50
|
/** The host's renderer of a `UiView`. */
|
|
49
51
|
export const ViewBlocks = forward("ViewBlocks");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { type ActionFn, PluginClientContextError, type ViewState } from "./context.js";
|
|
2
2
|
export { CLIENT_API_VERSION, type ClientComponent, type ClientExtension, type ClientExtensionDefinition, type ComponentProps, defineClientExtension, defineComponent, } from "./define.js";
|
|
3
|
-
export { Badge, type BadgeProps, Button, type ButtonProps, Icon, type IconProps, Kbd, type KbdProps, KeyValue, type KeyValueProps, Logo, type LogoProps, PropertySection, type PropertySectionProps, Spinner, type SpinnerProps, Stack, type StackProps, Text, type TextProps, Tooltip, type TooltipProps, ViewBlocks, type ViewBlocksProps, } from "./design.js";
|
|
3
|
+
export { Badge, type BadgeProps, Button, type ButtonProps, Icon, type IconProps, Kbd, type KbdProps, KeyValue, type KeyValueProps, Logo, type LogoProps, PropertySection, type PropertySectionProps, Select, type SelectOption, type SelectProps, Spinner, type SpinnerProps, Stack, type StackProps, Text, type TextProps, Tooltip, type TooltipProps, ViewBlocks, type ViewBlocksProps, } from "./design.js";
|
|
4
4
|
export { useAccess, useAction, useAssetUrl, useCapybaraEvents, useClientStorage, useLocale, usePrefersReducedMotion, useRunState, useSignIn, useTheme, useView, } from "./hooks.js";
|
|
5
5
|
export type { ComponentSlotId } from "./slots.generated.js";
|
|
6
6
|
export type { BaseComponentProps, CapybaraEvent, CapybaraEventOf, CapybaraEventType, ClientApi, ClientRole, ClientStorage, EventBase, JsonValue, RunState, SignIn, SlotComponentProps, UiView, } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { PluginClientContextError } from "./context.js";
|
|
2
2
|
export { CLIENT_API_VERSION, defineClientExtension, defineComponent, } from "./define.js";
|
|
3
|
-
export { Badge, Button, Icon, Kbd, KeyValue, Logo, PropertySection, Spinner, Stack, Text, Tooltip, ViewBlocks, } from "./design.js";
|
|
3
|
+
export { Badge, Button, Icon, Kbd, KeyValue, Logo, PropertySection, Select, Spinner, Stack, Text, Tooltip, ViewBlocks, } from "./design.js";
|
|
4
4
|
export { useAccess, useAction, useAssetUrl, useCapybaraEvents, useClientStorage, useLocale, usePrefersReducedMotion, useRunState, useSignIn, useTheme, useView, } from "./hooks.js";
|
package/dist/testing/index.js
CHANGED
|
@@ -2,12 +2,27 @@ import { act, createElement, useState, } from "react";
|
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
3
|
import { createPrefixedStorage, HostContext, } from "../context.js";
|
|
4
4
|
import { clientHost, DESIGN_NAMES, setClientHost } from "../design.js";
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Plain stand-ins for the host's design components: `<span data-fake-design="Name">`. `Select` is
|
|
7
|
+
* a native select over its options, so a test picks a value the way a person would.
|
|
8
|
+
*/
|
|
6
9
|
function fakeDesign() {
|
|
7
10
|
const out = {};
|
|
8
11
|
for (const name of DESIGN_NAMES) {
|
|
9
|
-
|
|
12
|
+
const Stub = ({ children }) => createElement("span", { "data-fake-design": name }, children);
|
|
13
|
+
out[name] = Stub;
|
|
10
14
|
}
|
|
15
|
+
const FakeSelect = (props) => createElement("select", {
|
|
16
|
+
value: props.value ?? "",
|
|
17
|
+
disabled: props.disabled,
|
|
18
|
+
"aria-label": props["aria-label"],
|
|
19
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
20
|
+
"data-fake-design": "Select",
|
|
21
|
+
onChange: (e) => props.onChange?.({ target: { value: e.target.value } }),
|
|
22
|
+
}, props.placeholder === undefined
|
|
23
|
+
? null
|
|
24
|
+
: createElement("option", { key: "__placeholder", value: "" }, props.placeholder), ...props.options.map((o) => createElement("option", { key: o.value, value: o.value, disabled: o.disabled }, o.label)));
|
|
25
|
+
out.Select = FakeSelect;
|
|
11
26
|
return out;
|
|
12
27
|
}
|
|
13
28
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type UiPartName = "shell" | "sidebar" | "sidebar.brand" | "sidebar.item" | "title-bar" | "page-header" | "thread" | "message.user" | "message.assistant" | "tool-row" | "composer" | "properties-panel" | "section" | "right-panel" | "status-bar" | "button" | "button.primary" | "card" | "input" | "dialog";
|
|
1
|
+
export type UiPartName = "shell" | "sidebar" | "sidebar.brand" | "sidebar.item" | "title-bar" | "page-header" | "thread" | "message.user" | "message.user.bubble" | "message.assistant" | "tool-row" | "composer" | "properties-panel" | "section" | "right-panel" | "status-bar" | "button" | "button.primary" | "card" | "input" | "dialog" | "code-block" | "menu" | "segmented" | "stat-card" | "switch" | "switch.knob" | "org-avatar" | "agent-chip";
|
|
2
2
|
/** Every part name plugin CSS and components may rely on. */
|
|
3
3
|
export declare const UI_PART_NAMES: readonly UiPartName[];
|
|
@@ -9,6 +9,7 @@ export const UI_PART_NAMES = [
|
|
|
9
9
|
"page-header",
|
|
10
10
|
"thread",
|
|
11
11
|
"message.user",
|
|
12
|
+
"message.user.bubble",
|
|
12
13
|
"message.assistant",
|
|
13
14
|
"tool-row",
|
|
14
15
|
"composer",
|
|
@@ -21,4 +22,12 @@ export const UI_PART_NAMES = [
|
|
|
21
22
|
"card",
|
|
22
23
|
"input",
|
|
23
24
|
"dialog",
|
|
25
|
+
"code-block",
|
|
26
|
+
"menu",
|
|
27
|
+
"segmented",
|
|
28
|
+
"stat-card",
|
|
29
|
+
"switch",
|
|
30
|
+
"switch.knob",
|
|
31
|
+
"org-avatar",
|
|
32
|
+
"agent-chip",
|
|
24
33
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/plugin-client",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.5",
|
|
4
4
|
"description": "Capybara plugin client SDK: the types, hooks and design re-exports a plugin's client entry is written against",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|