sparkdesign 0.3.0 → 0.3.2
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 +7 -5
- package/cli/dist/index.js +0 -0
- package/cli/dist/utils/tokens.js +103 -17
- package/cli/registry/basic/button.test.tsx +333 -0
- package/cli/registry/chat/{question-part.tsx → ask-user-part.tsx} +4 -4
- package/cli/registry/chat/{browser-use-part.tsx → browser-action-part.tsx} +6 -6
- package/cli/registry/chat/{suggestion-part.tsx → hint-banner.tsx} +4 -4
- package/cli/registry/chat/markdown.test.tsx +387 -0
- package/cli/registry/chat/{reasoning-step.tsx → reasoning-step/compound.tsx} +163 -185
- package/cli/registry/chat/reasoning-step/context.tsx +114 -0
- package/cli/registry/chat/reasoning-step/index.tsx +45 -0
- package/cli/registry/chat/reasoning-step/types.ts +109 -0
- package/cli/registry/chat/response/compound.tsx +210 -0
- package/cli/registry/chat/{response.tsx → response/context.tsx} +65 -136
- package/cli/registry/chat/response/index.tsx +87 -0
- package/cli/registry/chat/response/types.ts +123 -0
- package/cli/registry/chat/thinking-indicator.test.tsx +244 -0
- package/cli/registry/chat/tool-invocation-card.test.tsx +346 -0
- package/cli/registry/chat/{request.tsx → user-message.tsx} +3 -3
- package/cli/registry/chat/user-question/compound.tsx +324 -0
- package/cli/registry/chat/user-question/context.tsx +456 -0
- package/cli/registry/chat/user-question/index.tsx +71 -316
- package/cli/registry/chat/user-question/useUserQuestionKeyboard.ts +5 -6
- package/cli/registry/tokens/index.css +31 -0
- package/cli/registry/tokens/scale/computed.css +103 -0
- package/cli/registry/tokens/scale/config.css +110 -0
- package/cli/registry/tokens/scale/index.css +30 -0
- package/cli/registry/tokens/scale/presets/compact.css +30 -0
- package/cli/registry/tokens/scale/presets/dense.css +64 -0
- package/cli/registry/tokens/scale/presets/sharp.css +40 -0
- package/cli/registry/tokens/scale/presets/soft.css +16 -0
- package/cli/registry/tokens/scale.css +12 -298
- package/cli/registry/tokens/scrollbar-utility.css +35 -0
- package/cli/registry/tokens/themes/dark-parchment.css +132 -0
- package/cli/registry/tokens/themes/dark-qoder.css +132 -0
- package/cli/registry/tokens/themes/light-parchment.css +123 -0
- package/cli/registry/tokens/themes/light-qoder.css +131 -0
- package/dist/qoder-design.css +1 -1
- package/dist/registry/chat/ask-user-part.d.ts +24 -0
- package/dist/registry/chat/browser-action-part.d.ts +28 -0
- package/dist/registry/chat/{suggestion-part.d.ts → hint-banner.d.ts} +4 -4
- package/dist/registry/chat/reasoning-step/compound.d.ts +17 -0
- package/dist/registry/chat/reasoning-step/context.d.ts +10 -0
- package/dist/registry/chat/reasoning-step/index.d.ts +14 -0
- package/dist/registry/chat/reasoning-step/types.d.ts +95 -0
- package/dist/registry/chat/response/compound.d.ts +25 -0
- package/dist/registry/chat/response/context.d.ts +9 -0
- package/dist/registry/chat/response/index.d.ts +15 -0
- package/dist/registry/chat/response/types.d.ts +99 -0
- package/dist/registry/chat/user-message.d.ts +6 -0
- package/dist/registry/chat/user-question/compound.d.ts +37 -0
- package/dist/registry/chat/user-question/context.d.ts +55 -0
- package/dist/registry/chat/user-question/index.d.ts +13 -5
- package/dist/registry/chat/user-question/useUserQuestionKeyboard.d.ts +2 -3
- package/dist/scale.css +9 -303
- package/dist/spark-design.cjs.js +62 -62
- package/dist/spark-design.es.js +3992 -3826
- package/dist/src/components/chat/AskUserPart/index.d.ts +6 -0
- package/dist/src/components/chat/BrowserActionPart/index.d.ts +7 -0
- package/dist/src/components/chat/HintBanner/index.d.ts +6 -0
- package/dist/src/components/chat/ReasoningStep/index.d.ts +11 -5
- package/dist/src/components/chat/Response/index.d.ts +16 -6
- package/dist/src/components/chat/UserMessage/index.d.ts +7 -0
- package/dist/src/components/chat/UserQuestion/index.d.ts +18 -4
- package/dist/src/components/index.d.ts +63 -63
- package/dist/theme.css +13 -800
- package/package.json +27 -3
- package/dist/registry/chat/browser-use-part.d.ts +0 -28
- package/dist/registry/chat/question-part.d.ts +0 -24
- package/dist/registry/chat/reasoning-step.d.ts +0 -35
- package/dist/registry/chat/request.d.ts +0 -6
- package/dist/registry/chat/response.d.ts +0 -28
- package/dist/src/components/chat/BrowserUsePart/index.d.ts +0 -7
- package/dist/src/components/chat/QuestionPart/index.d.ts +0 -6
- package/dist/src/components/chat/Request/index.d.ts +0 -7
- package/dist/src/components/chat/SuggestionPart/index.d.ts +0 -6
- /package/dist/src/components/{foundation → basic}/AlertDialog/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Avatar/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Button/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Collapse/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Collapsible/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/CollapsibleSection/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/DropdownMenu/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/EllipsisText/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/IconButton/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Kbd/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/OptionList/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Pagination/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Progress/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/RadioGroup/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Resizable/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Scrollbar/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Select/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Skeleton/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Slider/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Spinner/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Switch/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Table/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Tabs/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Tag/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Toast/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Toggle/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Tooltip/index.d.ts +0 -0
- /package/dist/src/components/{foundation → basic}/Typography/index.d.ts +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [INPUT]: N/A
|
|
3
|
+
* [OUTPUT]: Type definitions for ReasoningStep compound component
|
|
4
|
+
* [POS]: registry/chat/reasoning-step - ReasoningStep 组件类型定义
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
export type ReasoningStepDetail = {
|
|
8
|
+
type: 'action';
|
|
9
|
+
action: string;
|
|
10
|
+
desc?: string;
|
|
11
|
+
details?: ReasoningStepDetail[];
|
|
12
|
+
} | {
|
|
13
|
+
type: 'file';
|
|
14
|
+
filename: string;
|
|
15
|
+
lines?: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
fileType?: string;
|
|
18
|
+
details?: ReasoningStepDetail[];
|
|
19
|
+
};
|
|
20
|
+
export type ReasoningStepStatus = 'completed' | 'in-progress';
|
|
21
|
+
export interface ReasoningStepRootProps {
|
|
22
|
+
/** 主文本 */
|
|
23
|
+
text: ReactNode;
|
|
24
|
+
/** 描述文本 */
|
|
25
|
+
description?: string;
|
|
26
|
+
/** 状态 */
|
|
27
|
+
status?: ReasoningStepStatus;
|
|
28
|
+
/** 自定义图标 */
|
|
29
|
+
icon?: ReactNode;
|
|
30
|
+
/** 是否显示图标 */
|
|
31
|
+
showIcon?: boolean;
|
|
32
|
+
/** 详情数据 */
|
|
33
|
+
details?: ReasoningStepDetail[];
|
|
34
|
+
/** 子组件 */
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
/** 动画持续时间 */
|
|
37
|
+
duration?: number;
|
|
38
|
+
/** 动画扩散度 */
|
|
39
|
+
spread?: number;
|
|
40
|
+
/** 禁用展开动画 */
|
|
41
|
+
disableExpandAnimation?: boolean;
|
|
42
|
+
/** 默认展开 */
|
|
43
|
+
defaultExpanded?: boolean;
|
|
44
|
+
/** 受控展开状态 */
|
|
45
|
+
expanded?: boolean;
|
|
46
|
+
/** 展开状态变化回调 */
|
|
47
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
48
|
+
/** 自定义眼睛图标 */
|
|
49
|
+
eyeIcon?: ReactNode;
|
|
50
|
+
/** 自定义箭头图标 */
|
|
51
|
+
arrowRightIcon?: ReactNode;
|
|
52
|
+
}
|
|
53
|
+
export type ReasoningStepProps = ReasoningStepRootProps;
|
|
54
|
+
export interface ReasoningStepHeaderProps {
|
|
55
|
+
className?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ReasoningStepDetailsProps {
|
|
58
|
+
className?: string;
|
|
59
|
+
children?: ReactNode;
|
|
60
|
+
}
|
|
61
|
+
export interface ReasoningStepDetailRowProps {
|
|
62
|
+
detail: ReasoningStepDetail;
|
|
63
|
+
depth?: number;
|
|
64
|
+
pathKey?: string;
|
|
65
|
+
className?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ReasoningStepContextValue {
|
|
68
|
+
status: ReasoningStepStatus;
|
|
69
|
+
isExpanded: boolean;
|
|
70
|
+
isHovered: boolean;
|
|
71
|
+
setIsHovered: (hovered: boolean) => void;
|
|
72
|
+
toggleExpanded: () => void;
|
|
73
|
+
effectiveExpanded: boolean;
|
|
74
|
+
effectiveShowIcon: boolean;
|
|
75
|
+
hasExpandableContent: boolean;
|
|
76
|
+
text: ReactNode;
|
|
77
|
+
description?: string;
|
|
78
|
+
details?: ReasoningStepDetail[];
|
|
79
|
+
detailsChildren?: ReactNode;
|
|
80
|
+
duration: number;
|
|
81
|
+
spread: number;
|
|
82
|
+
disableExpandAnimation: boolean;
|
|
83
|
+
detailIndent: string;
|
|
84
|
+
expandedNestedKeys: Set<string>;
|
|
85
|
+
toggleNested: (pathKey: string) => void;
|
|
86
|
+
icon?: ReactNode;
|
|
87
|
+
eyeIcon: ReactNode;
|
|
88
|
+
arrowRightIcon: ReactNode;
|
|
89
|
+
}
|
|
90
|
+
export interface ReasoningStepCompound {
|
|
91
|
+
Root: React.FC<ReasoningStepRootProps>;
|
|
92
|
+
Header: React.FC<ReasoningStepHeaderProps>;
|
|
93
|
+
Details: React.FC<ReasoningStepDetailsProps>;
|
|
94
|
+
DetailRow: React.FC<ReasoningStepDetailRowProps>;
|
|
95
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ResponseThinkingProps, ResponseStepsProps, ResponseStepProps, ResponseContentProps, ResponseImageGeneratingProps, ResponseDefaultLayoutProps } from './types';
|
|
2
|
+
export declare function ResponseThinking({ className }: ResponseThinkingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export declare namespace ResponseThinking {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function ResponseSteps({ className, children }: ResponseStepsProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace ResponseSteps {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function ResponseStepComponent({ step, status }: ResponseStepProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare namespace ResponseStepComponent {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function ResponseContent({ markdown, streaming, onStreamComplete, className, }: ResponseContentProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare namespace ResponseContent {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function ResponseImageGenerating({ width, height, className, }: ResponseImageGeneratingProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare namespace ResponseImageGenerating {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function ResponseDefaultLayout({ className }: ResponseDefaultLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare namespace ResponseDefaultLayout {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResponseContextValue, ResponseRootProps, ResponseRound } from './types';
|
|
2
|
+
declare const DEMO_ROUNDS: ResponseRound[];
|
|
3
|
+
declare const DEMO_FINAL_MD = "## Plan\n\nI will organize your **1,000 local photos** by building an index, clustering them into albums, and then performing a safe rename + move operation.\n\n### Folder structure\n\n```text\nPictures/\n Organized/\n 2026-01-18 \u2014 San Francisco \u2014 Golden Gate Park/\n 2026-01-05 \u2014 Home \u2014 Documents/\n 2025-12-31 \u2014 New Year's Eve/\n _Duplicates/\n _Unsorted/\n```\n\n### Naming scheme\n\n`YYYY-MM-DD_HH-mm-ss__<Location>__<Scene>__<Counter>.<ext>`\n\nExample:\n\n`2026-01-18_15-42-11__San-Francisco__Outdoor__001.jpg`\n\n### Safety checks\n\n- [x] Dry-run all operations\n- [x] Detect collisions and append counters\n- [x] Keep an audit log (CSV)\n- [ ] Execute moves (requires confirmation)\n\n---\n\n## Next step\n\nIf you want, I can generate a **preview report** first (top 50 renames + album summary) before applying changes.\n";
|
|
4
|
+
export declare function useResponseContext(): ResponseContextValue;
|
|
5
|
+
export declare function ResponseRootProvider({ simulate, phase, rounds, finalMarkdown, onSimulateComplete, onStepChange, thinkingIndicator, children, }: ResponseRootProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare namespace ResponseRootProvider {
|
|
7
|
+
var displayName: string;
|
|
8
|
+
}
|
|
9
|
+
export { DEMO_ROUNDS, DEMO_FINAL_MD };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [INPUT]: ResponseProps
|
|
3
|
+
* [OUTPUT]: Response compound component
|
|
4
|
+
* [POS]: registry/chat/response - Response 复合组件主入口
|
|
5
|
+
*
|
|
6
|
+
* 设计模式:shadcn 风格复合组件
|
|
7
|
+
* - Response = 便捷导出(Root + DefaultLayout)
|
|
8
|
+
* - Response.Root/Thinking/Steps/Step/Content/ImageGenerating = 复合子组件
|
|
9
|
+
*/
|
|
10
|
+
import type { HTMLAttributes } from 'react';
|
|
11
|
+
import { useResponseContext, DEMO_ROUNDS, DEMO_FINAL_MD } from './context';
|
|
12
|
+
import type { ResponseProps, ResponseCompound, ResponsePhase, ResponseStep, ResponseStepToolType, ResponseRound, ResponseBlock, BlockType } from './types';
|
|
13
|
+
export declare const Response: React.FC<ResponseProps & HTMLAttributes<HTMLDivElement>> & ResponseCompound;
|
|
14
|
+
export type { ResponseProps, ResponsePhase, ResponseStep, ResponseStepToolType, ResponseRound, ResponseBlock, BlockType, ResponseCompound, };
|
|
15
|
+
export { useResponseContext, DEMO_ROUNDS, DEMO_FINAL_MD };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [INPUT]: N/A
|
|
3
|
+
* [OUTPUT]: Type definitions for Response compound component
|
|
4
|
+
* [POS]: registry/chat/response - Response 组件类型定义
|
|
5
|
+
*/
|
|
6
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
7
|
+
import type { ReasoningStepDetail } from '../reasoning-step';
|
|
8
|
+
export type ResponsePhase = 'thinking' | 'streaming' | 'done' | 'imageGenerating';
|
|
9
|
+
export type ResponseStepToolType = 'read' | 'edit' | 'search';
|
|
10
|
+
export interface ResponseStep {
|
|
11
|
+
text: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
details?: ReasoningStepDetail[];
|
|
14
|
+
toolType?: ResponseStepToolType;
|
|
15
|
+
}
|
|
16
|
+
export interface ResponseRound {
|
|
17
|
+
step: ResponseStep;
|
|
18
|
+
simpleMd: string;
|
|
19
|
+
}
|
|
20
|
+
export type BlockType = 'think' | 'composer' | 'md';
|
|
21
|
+
export interface ResponseBlock {
|
|
22
|
+
type: BlockType;
|
|
23
|
+
step?: ResponseStep;
|
|
24
|
+
md?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ResponseRootProps {
|
|
27
|
+
/** 是否启用流式模拟 */
|
|
28
|
+
simulate?: boolean;
|
|
29
|
+
/** 当前阶段 */
|
|
30
|
+
phase?: ResponsePhase;
|
|
31
|
+
/** 响应轮次数据 */
|
|
32
|
+
rounds?: ResponseRound[];
|
|
33
|
+
/** 最终 Markdown 内容 */
|
|
34
|
+
finalMarkdown?: string;
|
|
35
|
+
/** 模拟完成回调 */
|
|
36
|
+
onSimulateComplete?: () => void;
|
|
37
|
+
/** 步骤变化回调 */
|
|
38
|
+
onStepChange?: (text: string, toolType?: ResponseStepToolType) => void;
|
|
39
|
+
/** 自定义 ThinkingIndicator(主库注入 Lottie) */
|
|
40
|
+
thinkingIndicator?: ReactNode;
|
|
41
|
+
/** 自定义 className */
|
|
42
|
+
className?: string;
|
|
43
|
+
/** 子组件 */
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
}
|
|
46
|
+
export interface ResponseProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'>, ResponseRootProps {
|
|
47
|
+
}
|
|
48
|
+
export interface ResponseThinkingProps {
|
|
49
|
+
className?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ResponseStepsProps {
|
|
52
|
+
className?: string;
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export interface ResponseStepProps {
|
|
56
|
+
step: ResponseStep;
|
|
57
|
+
status?: 'completed' | 'in-progress';
|
|
58
|
+
}
|
|
59
|
+
export interface ResponseContentProps {
|
|
60
|
+
/** Markdown 内容 */
|
|
61
|
+
markdown?: string;
|
|
62
|
+
/** 是否流式渲染 */
|
|
63
|
+
streaming?: boolean;
|
|
64
|
+
/** 流式渲染完成回调 */
|
|
65
|
+
onStreamComplete?: () => void;
|
|
66
|
+
className?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ResponseImageGeneratingProps {
|
|
69
|
+
width?: string;
|
|
70
|
+
height?: string;
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ResponseDefaultLayoutProps {
|
|
74
|
+
className?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface ResponseContextValue {
|
|
77
|
+
phase: ResponsePhase;
|
|
78
|
+
simulate: boolean;
|
|
79
|
+
rounds: ResponseRound[];
|
|
80
|
+
finalMarkdown: string;
|
|
81
|
+
blocks: ResponseBlock[];
|
|
82
|
+
visibleIndex: number;
|
|
83
|
+
setVisibleIndex: React.Dispatch<React.SetStateAction<number>>;
|
|
84
|
+
isSimDone: boolean;
|
|
85
|
+
currentBlock: ResponseBlock | null;
|
|
86
|
+
showThink: boolean;
|
|
87
|
+
onSimulateComplete?: () => void;
|
|
88
|
+
onStepChange?: (text: string, toolType?: ResponseStepToolType) => void;
|
|
89
|
+
thinkingIndicator: ReactNode;
|
|
90
|
+
}
|
|
91
|
+
export interface ResponseCompound {
|
|
92
|
+
Root: React.FC<ResponseRootProps>;
|
|
93
|
+
Thinking: React.FC<ResponseThinkingProps>;
|
|
94
|
+
Steps: React.FC<ResponseStepsProps>;
|
|
95
|
+
Step: React.FC<ResponseStepProps>;
|
|
96
|
+
Content: React.FC<ResponseContentProps>;
|
|
97
|
+
ImageGenerating: React.FC<ResponseImageGeneratingProps>;
|
|
98
|
+
DefaultLayout: React.FC<ResponseDefaultLayoutProps>;
|
|
99
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface UserMessageProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
maxWidth?: string | number;
|
|
5
|
+
}
|
|
6
|
+
export declare const UserMessage: import("react").ForwardRefExoticComponent<UserMessageProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { UserQuestionItem } from './types';
|
|
3
|
+
export interface UserQuestionHeaderProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function UserQuestionHeader({ className }: UserQuestionHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare namespace UserQuestionHeader {
|
|
8
|
+
var displayName: string;
|
|
9
|
+
}
|
|
10
|
+
export interface UserQuestionCardProps {
|
|
11
|
+
question: UserQuestionItem;
|
|
12
|
+
qIndex: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function UserQuestionCard({ question, qIndex, className }: UserQuestionCardProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare namespace UserQuestionCard {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
19
|
+
export interface UserQuestionCardsProps {
|
|
20
|
+
className?: string;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export declare function UserQuestionCards({ className, children }: UserQuestionCardsProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare namespace UserQuestionCards {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
27
|
+
export interface UserQuestionFooterProps {
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function UserQuestionFooter({ className }: UserQuestionFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare namespace UserQuestionFooter {
|
|
32
|
+
var displayName: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function UserQuestionDefaultLayout(): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare namespace UserQuestionDefaultLayout {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ReactNode, MutableRefObject, Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { type UserQuestionItem, type UserQuestionLabels, type UserQuestionHandle } from './types';
|
|
3
|
+
export interface UserQuestionContextValue {
|
|
4
|
+
questions: UserQuestionItem[];
|
|
5
|
+
labels: Required<UserQuestionLabels>;
|
|
6
|
+
currentQuestionIndex: number;
|
|
7
|
+
setCurrentQuestionIndex: (i: number) => void;
|
|
8
|
+
answers: Record<string, string[]>;
|
|
9
|
+
setAnswers: Dispatch<SetStateAction<Record<string, string[]>>>;
|
|
10
|
+
customInputs: Record<string, string>;
|
|
11
|
+
setCustomInputs: Dispatch<SetStateAction<Record<string, string>>>;
|
|
12
|
+
focusedOptionIndex: number;
|
|
13
|
+
setFocusedOptionIndex: (i: number) => void;
|
|
14
|
+
isSubmitting: boolean;
|
|
15
|
+
setIsSubmitting: (v: boolean) => void;
|
|
16
|
+
maxQuestionHeight: number | undefined;
|
|
17
|
+
scrollContainerRef: MutableRefObject<HTMLDivElement | null>;
|
|
18
|
+
questionRefs: MutableRefObject<Map<number, HTMLDivElement>>;
|
|
19
|
+
customInputRefs: MutableRefObject<Map<string, HTMLInputElement>>;
|
|
20
|
+
setShouldScrollToQuestion: (v: boolean) => void;
|
|
21
|
+
currentQuestion: UserQuestionItem | undefined;
|
|
22
|
+
currentOptions: {
|
|
23
|
+
label: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
}[];
|
|
26
|
+
allQuestionsAnswered: boolean;
|
|
27
|
+
currentQuestionHasAnswer: boolean;
|
|
28
|
+
getSelectedOptionIndex: (i: number) => number;
|
|
29
|
+
handleOptionClick: (questionText: string, optionLabel: string, questionIndex: number) => void;
|
|
30
|
+
handlePrevious: () => void;
|
|
31
|
+
handleNext: () => void;
|
|
32
|
+
handleContinue: () => void;
|
|
33
|
+
handleSkip: () => void;
|
|
34
|
+
handleRecommend: () => void;
|
|
35
|
+
chat4Icon: ReactNode;
|
|
36
|
+
arrowUpSIcon: ReactNode;
|
|
37
|
+
arrowDownSIcon: ReactNode;
|
|
38
|
+
sparklingIcon: ReactNode;
|
|
39
|
+
hasCustomText: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare function useUserQuestionContext(): UserQuestionContextValue;
|
|
42
|
+
export interface UserQuestionRootProps {
|
|
43
|
+
questions: UserQuestionItem[];
|
|
44
|
+
resetKey?: string;
|
|
45
|
+
onAnswer: (answers: Record<string, string>) => void;
|
|
46
|
+
onSkip: () => void;
|
|
47
|
+
hasCustomText?: boolean;
|
|
48
|
+
labels?: UserQuestionLabels;
|
|
49
|
+
chat4Icon?: ReactNode;
|
|
50
|
+
arrowUpSIcon?: ReactNode;
|
|
51
|
+
arrowDownSIcon?: ReactNode;
|
|
52
|
+
sparklingIcon?: ReactNode;
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export declare const UserQuestionRootProvider: import("react").ForwardRefExoticComponent<UserQuestionRootProps & import("react").RefAttributes<UserQuestionHandle>>;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useUserQuestionContext, type UserQuestionRootProps } from './context';
|
|
2
|
+
import { UserQuestionHeader, UserQuestionCard, UserQuestionCards, UserQuestionFooter, UserQuestionDefaultLayout } from './compound';
|
|
3
|
+
import type { UserQuestionProps, UserQuestionHandle } from './types';
|
|
2
4
|
export type { UserQuestionOption, UserQuestionItem, UserQuestionLabels, UserQuestionProps, UserQuestionHandle, } from './types';
|
|
3
5
|
export { DEFAULT_LABELS, NO_PREFERENCE_VALUE } from './types';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export interface UserQuestionCompound {
|
|
7
|
+
Root: React.ForwardRefExoticComponent<UserQuestionRootProps & React.RefAttributes<UserQuestionHandle>>;
|
|
8
|
+
Header: typeof UserQuestionHeader;
|
|
9
|
+
Card: typeof UserQuestionCard;
|
|
10
|
+
Cards: typeof UserQuestionCards;
|
|
11
|
+
Footer: typeof UserQuestionFooter;
|
|
12
|
+
DefaultLayout: typeof UserQuestionDefaultLayout;
|
|
13
|
+
}
|
|
14
|
+
export declare const UserQuestion: React.ForwardRefExoticComponent<UserQuestionProps & React.RefAttributes<UserQuestionHandle>> & UserQuestionCompound;
|
|
15
|
+
export { useUserQuestionContext, UserQuestionDefaultLayout };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { MutableRefObject } from 'react';
|
|
2
1
|
import type { UserQuestionItem, UserQuestionOption } from './types';
|
|
3
2
|
export interface UseUserQuestionKeyboardProps {
|
|
4
3
|
isSubmitting: boolean;
|
|
@@ -10,9 +9,9 @@ export interface UseUserQuestionKeyboardProps {
|
|
|
10
9
|
setFocusedOptionIndex: (n: number) => void;
|
|
11
10
|
currentQuestionHasAnswer: boolean;
|
|
12
11
|
getSelectedOptionIndex: (i: number) => number;
|
|
13
|
-
|
|
12
|
+
setShouldScrollToQuestion: (v: boolean) => void;
|
|
14
13
|
setCurrentQuestionIndex: (i: number) => void;
|
|
15
14
|
handleOptionClick: (questionText: string, optionLabel: string, questionIndex: number) => void;
|
|
16
15
|
handleContinue: () => void;
|
|
17
16
|
}
|
|
18
|
-
export declare function useUserQuestionKeyboard({ isSubmitting, currentQuestion, currentOptions, currentQuestionIndex, questions, focusedOptionIndex, setFocusedOptionIndex, currentQuestionHasAnswer, getSelectedOptionIndex,
|
|
17
|
+
export declare function useUserQuestionKeyboard({ isSubmitting, currentQuestion, currentOptions, currentQuestionIndex, questions, focusedOptionIndex, setFocusedOptionIndex, currentQuestionHasAnswer, getSelectedOptionIndex, setShouldScrollToQuestion, setCurrentQuestionIndex, handleOptionClick, handleContinue, }: UseUserQuestionKeyboardProps): void;
|