dishui 0.0.89 → 0.0.97
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/.release-verified.json +6 -0
- package/dist/ai.js +22 -0
- package/dist/components/Card/Metric2.js +11 -11
- package/dist/components/Card/Metric2.js.map +1 -1
- package/dist/components/Card/index.d.ts +20 -0
- package/dist/components/Card/index.js +184 -179
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/GroupButton/index.js +4 -4
- package/dist/components/GroupButton/index.js.map +1 -1
- package/dist/components/GroupedTable/index.js +10 -10
- package/dist/components/GroupedTable/index.js.map +1 -1
- package/dist/components/NavigationList/index.js +9 -9
- package/dist/components/NavigationList/index.js.map +1 -1
- package/dist/components/Section/index.js +11 -11
- package/dist/components/Section/index.js.map +1 -1
- package/dist/components/Skeleton/index.js +1 -1
- package/dist/components/Skeleton/index.js.map +1 -1
- package/dist/components/Table/index.d.ts +23 -2
- package/dist/components/Table/index.js +153 -101
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/ai/AgentChat/index.d.ts +54 -0
- package/dist/components/ai/AgentChat/index.js +176 -0
- package/dist/components/ai/AgentChat/index.js.map +1 -0
- package/dist/components/ai/AgentScreen/index.d.ts +50 -0
- package/dist/components/ai/AgentScreen/index.js +233 -0
- package/dist/components/ai/AgentScreen/index.js.map +1 -0
- package/dist/components/ai/ApprovalCard/index.d.ts +26 -0
- package/dist/components/ai/ApprovalCard/index.js +89 -0
- package/dist/components/ai/ApprovalCard/index.js.map +1 -0
- package/dist/components/ai/CodeView/index.d.ts +30 -0
- package/dist/components/ai/CodeView/index.js +149 -0
- package/dist/components/ai/CodeView/index.js.map +1 -0
- package/dist/components/ai/CommandSearch/index.d.ts +39 -0
- package/dist/components/ai/CommandSearch/index.js +217 -0
- package/dist/components/ai/CommandSearch/index.js.map +1 -0
- package/dist/components/ai/ContextCards/index.d.ts +42 -0
- package/dist/components/ai/ContextCards/index.js +106 -0
- package/dist/components/ai/ContextCards/index.js.map +1 -0
- package/dist/components/ai/DiffTable/index.d.ts +70 -0
- package/dist/components/ai/DiffTable/index.js +235 -0
- package/dist/components/ai/DiffTable/index.js.map +1 -0
- package/dist/components/ai/FilterTable/index.d.ts +35 -0
- package/dist/components/ai/FilterTable/index.js +86 -0
- package/dist/components/ai/FilterTable/index.js.map +1 -0
- package/dist/components/ai/FineTuneCard/index.d.ts +24 -0
- package/dist/components/ai/FineTuneCard/index.js +75 -0
- package/dist/components/ai/FineTuneCard/index.js.map +1 -0
- package/dist/components/ai/InsightCards/index.d.ts +23 -0
- package/dist/components/ai/InsightCards/index.js +64 -0
- package/dist/components/ai/InsightCards/index.js.map +1 -0
- package/dist/components/ai/LoadingState/index.d.ts +22 -0
- package/dist/components/ai/LoadingState/index.js +80 -0
- package/dist/components/ai/LoadingState/index.js.map +1 -0
- package/dist/components/ai/PromptBar/index.d.ts +26 -0
- package/dist/components/ai/PromptBar/index.js +117 -0
- package/dist/components/ai/PromptBar/index.js.map +1 -0
- package/dist/components/ai/RecommendationCard/index.d.ts +44 -0
- package/dist/components/ai/RecommendationCard/index.js +142 -0
- package/dist/components/ai/RecommendationCard/index.js.map +1 -0
- package/dist/components/ai/RecordsTable/index.d.ts +65 -0
- package/dist/components/ai/RecordsTable/index.js +334 -0
- package/dist/components/ai/RecordsTable/index.js.map +1 -0
- package/dist/components/ai/SelectionActions/index.d.ts +19 -0
- package/dist/components/ai/SelectionActions/index.js +40 -0
- package/dist/components/ai/SelectionActions/index.js.map +1 -0
- package/dist/components/ai/StateFlow/index.d.ts +24 -0
- package/dist/components/ai/StateFlow/index.js +50 -0
- package/dist/components/ai/StateFlow/index.js.map +1 -0
- package/dist/components/ai/StreamingText/index.d.ts +44 -0
- package/dist/components/ai/StreamingText/index.js +211 -0
- package/dist/components/ai/StreamingText/index.js.map +1 -0
- package/dist/components/ai/TaskRows/index.d.ts +53 -0
- package/dist/components/ai/TaskRows/index.js +186 -0
- package/dist/components/ai/TaskRows/index.js.map +1 -0
- package/dist/components/ai/Thinking/index.d.ts +47 -0
- package/dist/components/ai/Thinking/index.js +197 -0
- package/dist/components/ai/Thinking/index.js.map +1 -0
- package/dist/components/ai/ToolChips/index.d.ts +21 -0
- package/dist/components/ai/ToolChips/index.js +63 -0
- package/dist/components/ai/ToolChips/index.js.map +1 -0
- package/dist/components/ai/index.d.ts +50 -0
- package/dist/components/ai/shared.d.ts +13 -0
- package/dist/components/ai/shared.js +25 -0
- package/dist/components/ai/shared.js.map +1 -0
- package/dist/components/pro/DataTable/DataTable.js +70 -51
- package/dist/components/pro/DataTable/DataTable.js.map +1 -1
- package/dist/components/pro/DataTable/components/TableBody.d.ts +3 -1
- package/dist/components/pro/DataTable/components/TableBody.js +41 -39
- package/dist/components/pro/DataTable/components/TableBody.js.map +1 -1
- package/dist/components/pro/DataTable/components/TableToolbar.d.ts +2 -1
- package/dist/components/pro/DataTable/components/TableToolbar.js +25 -19
- package/dist/components/pro/DataTable/components/TableToolbar.js.map +1 -1
- package/dist/components/pro/DataTable/index.d.ts +1 -1
- package/dist/components/pro/DataTable/rowDetailExtension.js +1 -1
- package/dist/components/pro/DataTable/rowDetailExtension.js.map +1 -1
- package/dist/components/pro/DataTable/types.d.ts +19 -0
- package/dist/data-table.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +128 -107
- package/dist/layouts/Sidebar.d.ts +16 -0
- package/dist/layouts/Sidebar.js +85 -52
- package/dist/layouts/Sidebar.js.map +1 -1
- package/dist/lite.d.ts +2 -0
- package/dist/lite.js +22 -21
- package/package.json +10 -3
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { cn as e } from "../../../utils/cn.js";
|
|
2
|
+
import { AGENT_STATUS_LABEL as t, formatDuration as n, formatElapsed as r } from "../shared.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { useId as i, useState as a } from "react";
|
|
5
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ai/Thinking/index.tsx
|
|
7
|
+
var l = {
|
|
8
|
+
steps: "step",
|
|
9
|
+
reasoning: "reasoning",
|
|
10
|
+
search: "search",
|
|
11
|
+
coding: "coding"
|
|
12
|
+
}, u = () => /* @__PURE__ */ s("svg", {
|
|
13
|
+
width: "16",
|
|
14
|
+
height: "16",
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
fill: "none",
|
|
17
|
+
stroke: "currentColor",
|
|
18
|
+
strokeWidth: "2",
|
|
19
|
+
strokeLinecap: "round",
|
|
20
|
+
strokeLinejoin: "round",
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
children: /* @__PURE__ */ s("path", { d: "m6 9 6 6 6-6" })
|
|
23
|
+
}), d = () => /* @__PURE__ */ s("svg", {
|
|
24
|
+
width: "10",
|
|
25
|
+
height: "10",
|
|
26
|
+
viewBox: "0 0 24 24",
|
|
27
|
+
fill: "none",
|
|
28
|
+
stroke: "currentColor",
|
|
29
|
+
strokeWidth: "3",
|
|
30
|
+
strokeLinecap: "round",
|
|
31
|
+
strokeLinejoin: "round",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
children: /* @__PURE__ */ s("path", { d: "M20 6 9 17l-5-5" })
|
|
34
|
+
}), f = () => /* @__PURE__ */ s("svg", {
|
|
35
|
+
width: "10",
|
|
36
|
+
height: "10",
|
|
37
|
+
viewBox: "0 0 24 24",
|
|
38
|
+
fill: "none",
|
|
39
|
+
stroke: "currentColor",
|
|
40
|
+
strokeWidth: "3",
|
|
41
|
+
strokeLinecap: "round",
|
|
42
|
+
strokeLinejoin: "round",
|
|
43
|
+
"aria-hidden": "true",
|
|
44
|
+
children: /* @__PURE__ */ s("path", { d: "M18 6 6 18M6 6l12 12" })
|
|
45
|
+
}), p = ({ status: n }) => /* @__PURE__ */ c("span", {
|
|
46
|
+
className: e("dishui-ai-thinking__marker", `dishui-ai-thinking__marker--${n}`),
|
|
47
|
+
title: t[n],
|
|
48
|
+
children: [
|
|
49
|
+
n === "completed" && /* @__PURE__ */ s(d, {}),
|
|
50
|
+
n === "failed" && /* @__PURE__ */ s(f, {}),
|
|
51
|
+
/* @__PURE__ */ s("span", {
|
|
52
|
+
className: "dishui-ai-thinking__sr",
|
|
53
|
+
children: t[n]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
}), m = (e) => (e.domain ?? e.title).trim().charAt(0).toUpperCase(), h = ({ step: t, kind: n }) => {
|
|
57
|
+
let i = t.status ?? "completed";
|
|
58
|
+
return /* @__PURE__ */ c("li", {
|
|
59
|
+
className: e("dishui-ai-thinking__step", `dishui-ai-thinking__step--${n}`, `dishui-ai-thinking__step--${i}`),
|
|
60
|
+
children: [/* @__PURE__ */ s(p, { status: i }), /* @__PURE__ */ c("div", {
|
|
61
|
+
className: "dishui-ai-thinking__content",
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ c("div", {
|
|
64
|
+
className: "dishui-ai-thinking__step-row",
|
|
65
|
+
children: [/* @__PURE__ */ s("span", {
|
|
66
|
+
className: "dishui-ai-thinking__step-title",
|
|
67
|
+
children: t.title
|
|
68
|
+
}), t.durationMs !== void 0 && /* @__PURE__ */ s("span", {
|
|
69
|
+
className: "dishui-ai-thinking__step-duration",
|
|
70
|
+
children: r(t.durationMs)
|
|
71
|
+
})]
|
|
72
|
+
}),
|
|
73
|
+
t.detail !== void 0 && /* @__PURE__ */ s("div", {
|
|
74
|
+
className: "dishui-ai-thinking__detail",
|
|
75
|
+
children: t.detail
|
|
76
|
+
}),
|
|
77
|
+
n === "search" && t.results && t.results.length > 0 && /* @__PURE__ */ s("ul", {
|
|
78
|
+
className: "dishui-ai-thinking__results",
|
|
79
|
+
children: t.results.map((e) => {
|
|
80
|
+
let t = /* @__PURE__ */ c(o, { children: [
|
|
81
|
+
/* @__PURE__ */ s("span", {
|
|
82
|
+
className: "dishui-ai-thinking__result-initial",
|
|
83
|
+
"aria-hidden": "true",
|
|
84
|
+
children: m(e)
|
|
85
|
+
}),
|
|
86
|
+
/* @__PURE__ */ s("span", {
|
|
87
|
+
className: "dishui-ai-thinking__result-title",
|
|
88
|
+
children: e.title
|
|
89
|
+
}),
|
|
90
|
+
e.domain && /* @__PURE__ */ s("span", {
|
|
91
|
+
className: "dishui-ai-thinking__result-domain",
|
|
92
|
+
children: e.domain
|
|
93
|
+
})
|
|
94
|
+
] });
|
|
95
|
+
return /* @__PURE__ */ s("li", { children: e.url ? /* @__PURE__ */ s("a", {
|
|
96
|
+
className: "dishui-ai-thinking__result",
|
|
97
|
+
href: e.url,
|
|
98
|
+
target: "_blank",
|
|
99
|
+
rel: "noreferrer",
|
|
100
|
+
children: t
|
|
101
|
+
}) : /* @__PURE__ */ s("span", {
|
|
102
|
+
className: "dishui-ai-thinking__result",
|
|
103
|
+
children: t
|
|
104
|
+
}) }, `${e.url ?? ""}-${e.domain ?? ""}-${e.title}`);
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
n === "coding" && t.code && /* @__PURE__ */ c("div", {
|
|
108
|
+
className: "dishui-ai-thinking__code",
|
|
109
|
+
children: [/* @__PURE__ */ c("div", {
|
|
110
|
+
className: "dishui-ai-thinking__code-header",
|
|
111
|
+
children: [/* @__PURE__ */ s("span", {
|
|
112
|
+
className: "dishui-ai-thinking__code-file",
|
|
113
|
+
children: t.code.file ?? "snippet"
|
|
114
|
+
}), t.code.language && /* @__PURE__ */ s("span", {
|
|
115
|
+
className: "dishui-ai-thinking__code-lang",
|
|
116
|
+
children: t.code.language
|
|
117
|
+
})]
|
|
118
|
+
}), /* @__PURE__ */ s("pre", {
|
|
119
|
+
className: "dishui-ai-thinking__code-body",
|
|
120
|
+
children: /* @__PURE__ */ s("code", { children: t.code.content })
|
|
121
|
+
})]
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
})]
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
function g({ steps: t, status: r, durationMs: o, title: d, expanded: f, defaultExpanded: p = !1, onExpandedChange: m, mode: g = "auto", className: _, ...v }) {
|
|
128
|
+
let [y, b] = a(p), x = f !== void 0, S = x ? f : y, C = i(), w = t.find((e) => e.status === "running"), T = (r ?? (w ? "thinking" : "done")) === "thinking", E = t.reduce((e, t) => t.durationMs === void 0 ? e : (e ?? 0) + t.durationMs, void 0), D = o ?? E, O = T ? "Thinking" : D === void 0 ? "Thought" : `Thought for ${n(D)}`, k = d !== void 0 && !T && D !== void 0, A = () => {
|
|
129
|
+
let e = !S;
|
|
130
|
+
x || b(e), m?.(e);
|
|
131
|
+
};
|
|
132
|
+
return /* @__PURE__ */ c("div", {
|
|
133
|
+
...v,
|
|
134
|
+
className: e("dishui-ai-thinking", T && "dishui-ai-thinking--thinking", S && "dishui-ai-thinking--expanded", _),
|
|
135
|
+
children: [/* @__PURE__ */ c("button", {
|
|
136
|
+
type: "button",
|
|
137
|
+
className: "dishui-ai-thinking__header",
|
|
138
|
+
"aria-expanded": S,
|
|
139
|
+
"aria-controls": C,
|
|
140
|
+
onClick: A,
|
|
141
|
+
children: [
|
|
142
|
+
T && /* @__PURE__ */ c("span", {
|
|
143
|
+
className: "dishui-ai-thinking__glyph",
|
|
144
|
+
"aria-hidden": "true",
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ s("span", { className: "dishui-ai-thinking__cell" }),
|
|
147
|
+
/* @__PURE__ */ s("span", { className: "dishui-ai-thinking__cell" }),
|
|
148
|
+
/* @__PURE__ */ s("span", { className: "dishui-ai-thinking__cell" })
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ s("span", {
|
|
152
|
+
className: "dishui-ai-thinking__title",
|
|
153
|
+
children: d ?? O
|
|
154
|
+
}),
|
|
155
|
+
!S && T && w && /* @__PURE__ */ s("span", {
|
|
156
|
+
className: "dishui-ai-thinking__summary",
|
|
157
|
+
children: w.title
|
|
158
|
+
}),
|
|
159
|
+
!S && !T && t.length > 0 && /* @__PURE__ */ c("span", {
|
|
160
|
+
className: "dishui-ai-thinking__meta",
|
|
161
|
+
children: [
|
|
162
|
+
t.length,
|
|
163
|
+
" ",
|
|
164
|
+
t.length === 1 ? "step" : "steps"
|
|
165
|
+
]
|
|
166
|
+
}),
|
|
167
|
+
k && /* @__PURE__ */ s("span", {
|
|
168
|
+
className: "dishui-ai-thinking__meta",
|
|
169
|
+
children: n(D)
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ s("span", {
|
|
172
|
+
className: "dishui-ai-thinking__chevron",
|
|
173
|
+
"aria-hidden": "true",
|
|
174
|
+
children: /* @__PURE__ */ s(u, {})
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
}), /* @__PURE__ */ s("div", {
|
|
178
|
+
id: C,
|
|
179
|
+
className: "dishui-ai-thinking__body",
|
|
180
|
+
hidden: !S,
|
|
181
|
+
children: t.length === 0 ? /* @__PURE__ */ s("p", {
|
|
182
|
+
className: "dishui-ai-thinking__empty",
|
|
183
|
+
children: "No steps recorded."
|
|
184
|
+
}) : /* @__PURE__ */ s("ol", {
|
|
185
|
+
className: "dishui-ai-thinking__trace",
|
|
186
|
+
children: t.map((e) => /* @__PURE__ */ s(h, {
|
|
187
|
+
step: e,
|
|
188
|
+
kind: g === "auto" ? e.kind : l[g]
|
|
189
|
+
}, e.id))
|
|
190
|
+
})
|
|
191
|
+
})]
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
export { g as default };
|
|
196
|
+
|
|
197
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/ai/Thinking/index.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\nimport { cn } from '../../../utils/cn';\nimport { formatDuration, formatElapsed, AGENT_STATUS_LABEL } from '../shared';\nimport type { AgentStatus } from '../shared';\nimport './Thinking.css';\n\nexport type ThinkingStepKind = 'step' | 'reasoning' | 'search' | 'coding';\nexport type ThinkingMode = 'steps' | 'reasoning' | 'search' | 'coding' | 'auto';\nexport type ThinkingStatus = 'thinking' | 'done';\n\nexport type ThinkingSearchResult = { title: string; url?: string; domain?: string };\nexport type ThinkingCode = { language?: string; content: string; file?: string };\n\nexport type ThinkingStep = {\n id: string;\n kind: ThinkingStepKind;\n title: React.ReactNode;\n detail?: React.ReactNode;\n /** Defaults to `completed`. */\n status?: AgentStatus;\n durationMs?: number;\n /** Result chips rendered by `search` steps. */\n results?: ThinkingSearchResult[];\n /** Code block rendered by `coding` steps. */\n code?: ThinkingCode;\n};\n\nexport type ThinkingProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {\n steps: ThinkingStep[];\n /** Derived from the steps when omitted: any running step → `thinking`. */\n status?: ThinkingStatus;\n /** Total time; rendered as “Thought for 4s” once done. Falls back to the sum of step durations. */\n durationMs?: number;\n /** Overrides the default “Thinking” / “Thought for …” header text. */\n title?: React.ReactNode;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Rendering emphasis. `auto` renders each step by its own `kind`. */\n mode?: ThinkingMode;\n};\n\nconst MODE_KIND: Record<Exclude<ThinkingMode, 'auto'>, ThinkingStepKind> = {\n steps: 'step',\n reasoning: 'reasoning',\n search: 'search',\n coding: 'coding',\n};\n\nconst ChevronIcon = () => (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n);\nconst CheckIcon = () => (\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n);\nconst XIcon = () => (\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M18 6 6 18M6 6l12 12\" />\n </svg>\n);\n\nconst Marker: React.FC<{ status: AgentStatus }> = ({ status }) => (\n <span className={cn('dishui-ai-thinking__marker', `dishui-ai-thinking__marker--${status}`)} title={AGENT_STATUS_LABEL[status]}>\n {status === 'completed' && <CheckIcon />}\n {status === 'failed' && <XIcon />}\n <span className=\"dishui-ai-thinking__sr\">{AGENT_STATUS_LABEL[status]}</span>\n </span>\n);\n\nconst initialOf = (result: ThinkingSearchResult) => (result.domain ?? result.title).trim().charAt(0).toUpperCase();\n\nconst StepBody: React.FC<{ step: ThinkingStep; kind: ThinkingStepKind }> = ({ step, kind }) => {\n const status = step.status ?? 'completed';\n return (\n <li className={cn('dishui-ai-thinking__step', `dishui-ai-thinking__step--${kind}`, `dishui-ai-thinking__step--${status}`)}>\n <Marker status={status} />\n <div className=\"dishui-ai-thinking__content\">\n <div className=\"dishui-ai-thinking__step-row\">\n <span className=\"dishui-ai-thinking__step-title\">{step.title}</span>\n {step.durationMs !== undefined && <span className=\"dishui-ai-thinking__step-duration\">{formatElapsed(step.durationMs)}</span>}\n </div>\n {step.detail !== undefined && <div className=\"dishui-ai-thinking__detail\">{step.detail}</div>}\n {kind === 'search' && step.results && step.results.length > 0 && (\n <ul className=\"dishui-ai-thinking__results\">\n {step.results.map(result => {\n const inner = (\n <>\n <span className=\"dishui-ai-thinking__result-initial\" aria-hidden=\"true\">{initialOf(result)}</span>\n <span className=\"dishui-ai-thinking__result-title\">{result.title}</span>\n {result.domain && <span className=\"dishui-ai-thinking__result-domain\">{result.domain}</span>}\n </>\n );\n return (\n <li key={`${result.url ?? ''}-${result.domain ?? ''}-${result.title}`}>\n {result.url ? (\n <a className=\"dishui-ai-thinking__result\" href={result.url} target=\"_blank\" rel=\"noreferrer\">{inner}</a>\n ) : (\n <span className=\"dishui-ai-thinking__result\">{inner}</span>\n )}\n </li>\n );\n })}\n </ul>\n )}\n {kind === 'coding' && step.code && (\n <div className=\"dishui-ai-thinking__code\">\n <div className=\"dishui-ai-thinking__code-header\">\n <span className=\"dishui-ai-thinking__code-file\">{step.code.file ?? 'snippet'}</span>\n {step.code.language && <span className=\"dishui-ai-thinking__code-lang\">{step.code.language}</span>}\n </div>\n <pre className=\"dishui-ai-thinking__code-body\"><code>{step.code.content}</code></pre>\n </div>\n )}\n </div>\n </li>\n );\n};\n\n/**\n * Expandable reasoning trace. Collapsed by default; the header summarises the\n * currently running step while collapsed and reads “Thought for …” once done.\n */\nexport default function Thinking({\n steps,\n status: statusProp,\n durationMs,\n title,\n expanded: expandedProp,\n defaultExpanded = false,\n onExpandedChange,\n mode = 'auto',\n className,\n ...rest\n}: ThinkingProps) {\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const controlled = expandedProp !== undefined;\n const expanded = controlled ? expandedProp : internalExpanded;\n const bodyId = useId();\n\n const running = steps.find(step => step.status === 'running');\n const status: ThinkingStatus = statusProp ?? (running ? 'thinking' : 'done');\n const thinking = status === 'thinking';\n\n const stepDurations = steps.reduce<number | undefined>(\n (sum, step) => (step.durationMs === undefined ? sum : (sum ?? 0) + step.durationMs),\n undefined,\n );\n const totalMs = durationMs ?? stepDurations;\n\n const defaultTitle = thinking ? 'Thinking' : totalMs !== undefined ? `Thought for ${formatDuration(totalMs)}` : 'Thought';\n const showDurationMeta = title !== undefined && !thinking && totalMs !== undefined;\n\n const toggle = () => {\n const next = !expanded;\n if (!controlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n };\n\n return (\n <div\n {...rest}\n className={cn('dishui-ai-thinking', thinking && 'dishui-ai-thinking--thinking', expanded && 'dishui-ai-thinking--expanded', className)}\n >\n <button type=\"button\" className=\"dishui-ai-thinking__header\" aria-expanded={expanded} aria-controls={bodyId} onClick={toggle}>\n {thinking && (\n <span className=\"dishui-ai-thinking__glyph\" aria-hidden=\"true\">\n <span className=\"dishui-ai-thinking__cell\" />\n <span className=\"dishui-ai-thinking__cell\" />\n <span className=\"dishui-ai-thinking__cell\" />\n </span>\n )}\n <span className=\"dishui-ai-thinking__title\">{title ?? defaultTitle}</span>\n {!expanded && thinking && running && <span className=\"dishui-ai-thinking__summary\">{running.title}</span>}\n {!expanded && !thinking && steps.length > 0 && (\n <span className=\"dishui-ai-thinking__meta\">{steps.length} {steps.length === 1 ? 'step' : 'steps'}</span>\n )}\n {showDurationMeta && <span className=\"dishui-ai-thinking__meta\">{formatDuration(totalMs)}</span>}\n <span className=\"dishui-ai-thinking__chevron\" aria-hidden=\"true\"><ChevronIcon /></span>\n </button>\n <div id={bodyId} className=\"dishui-ai-thinking__body\" hidden={!expanded}>\n {steps.length === 0 ? (\n <p className=\"dishui-ai-thinking__empty\">No steps recorded.</p>\n ) : (\n <ol className=\"dishui-ai-thinking__trace\">\n {steps.map(step => (\n <StepBody key={step.id} step={step} kind={mode === 'auto' ? step.kind : MODE_KIND[mode]} />\n ))}\n </ol>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AA0CA,IAAM,IAAqE;CACzE,OAAO;CACP,WAAW;CACX,QAAQ;CACR,QAAQ;AACV,GAEM,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,QAAO;CAAe,aAAY;CAAI,eAAc;CAAQ,gBAAe;CAAQ,eAAY;CACzJ,UAAA,kBAAC,QAAD,EAAM,GAAE,eAAgB,CAAA;AACrB,CAAA,GAED,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,QAAO;CAAe,aAAY;CAAI,eAAc;CAAQ,gBAAe;CAAQ,eAAY;CACzJ,UAAA,kBAAC,QAAD,EAAM,GAAE,kBAAmB,CAAA;AACxB,CAAA,GAED,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAA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ChF;EACR,CAAA,GAAA,kBAAC,OAAD;GAAK,IAAI;GAAQ,WAAU;GAA2B,QAAQ,CAAC;GAC5D,UAAA,EAAM,WAAW,IAChB,kBAAC,KAAD;IAAG,WAAU;IAA4B,UAAA;GAAqB,CAAA,IAE9D,kBAAC,MAAD;IAAI,WAAU;IACX,UAAA,EAAM,KAAI,MACT,kBAAC,GAAD;KAA8B;KAAM,MAAM,MAAS,SAAS,EAAK,OAAO,EAAU;IAAQ,GAA3E,EAAK,EAAsE,CAC3F;GACC,CAAA;EAEH,CAAA,CACF;;AAET"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AgentStatus } from '../shared';
|
|
3
|
+
export type ToolChip = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
status?: AgentStatus;
|
|
7
|
+
detail?: React.ReactNode;
|
|
8
|
+
duration?: string;
|
|
9
|
+
onRetry?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export type ToolChipsProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
12
|
+
tools: ToolChip[];
|
|
13
|
+
expanded?: string[];
|
|
14
|
+
defaultExpanded?: string[];
|
|
15
|
+
onExpandedChange?: (ids: string[]) => void;
|
|
16
|
+
labels?: Partial<Record<AgentStatus, string>> & {
|
|
17
|
+
retry?: string;
|
|
18
|
+
empty?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default function ToolChips({ tools, expanded, defaultExpanded, onExpandedChange, labels, className, ...rest }: ToolChipsProps): React.JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { cn as e } from "../../../utils/cn.js";
|
|
2
|
+
import { AGENT_STATUS_LABEL as t } from "../shared.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { useState as n } from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ai/ToolChips/index.tsx
|
|
7
|
+
var a = [];
|
|
8
|
+
function o({ tools: o, expanded: s, defaultExpanded: c = a, onExpandedChange: l, labels: u, className: d, ...f }) {
|
|
9
|
+
let [p, m] = n(c), h = s ?? p, g = (e) => {
|
|
10
|
+
let t = h.includes(e) ? h.filter((t) => t !== e) : [...h, e];
|
|
11
|
+
s === void 0 && m(t), l?.(t);
|
|
12
|
+
};
|
|
13
|
+
return o.length ? /* @__PURE__ */ r("div", {
|
|
14
|
+
...f,
|
|
15
|
+
className: e("dishui-ai-tool-chips", d),
|
|
16
|
+
children: o.map((n) => {
|
|
17
|
+
let a = n.status ?? "completed", o = h.includes(n.id), s = `tool-${n.id}-detail`;
|
|
18
|
+
return /* @__PURE__ */ i("div", {
|
|
19
|
+
className: e("dishui-ai-tool-chips__item", `dishui-ai-tool-chips__item--${a}`),
|
|
20
|
+
children: [/* @__PURE__ */ i("button", {
|
|
21
|
+
type: "button",
|
|
22
|
+
className: "dishui-ai-tool-chips__chip",
|
|
23
|
+
"aria-expanded": n.detail ? o : void 0,
|
|
24
|
+
"aria-controls": n.detail ? s : void 0,
|
|
25
|
+
onClick: () => n.detail && g(n.id),
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ r("span", {
|
|
28
|
+
className: "dishui-ai-tool-chips__mark",
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
children: a === "completed" ? "✓" : a === "failed" ? "!" : a === "running" ? "…" : "·"
|
|
31
|
+
}),
|
|
32
|
+
/* @__PURE__ */ r("span", { children: n.label }),
|
|
33
|
+
/* @__PURE__ */ r("span", {
|
|
34
|
+
className: "dishui-ai-tool-chips__status",
|
|
35
|
+
children: u?.[a] ?? t[a]
|
|
36
|
+
}),
|
|
37
|
+
n.duration && /* @__PURE__ */ r("span", {
|
|
38
|
+
className: "dishui-ai-tool-chips__duration",
|
|
39
|
+
children: n.duration
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
}), n.detail && /* @__PURE__ */ i("div", {
|
|
43
|
+
id: s,
|
|
44
|
+
hidden: !o,
|
|
45
|
+
className: "dishui-ai-tool-chips__detail",
|
|
46
|
+
children: [n.detail, a === "failed" && n.onRetry && /* @__PURE__ */ r("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
onClick: n.onRetry,
|
|
49
|
+
children: u?.retry ?? "Retry"
|
|
50
|
+
})]
|
|
51
|
+
})]
|
|
52
|
+
}, n.id);
|
|
53
|
+
})
|
|
54
|
+
}) : /* @__PURE__ */ r("div", {
|
|
55
|
+
...f,
|
|
56
|
+
className: e("dishui-ai-tool-chips dishui-ai-tool-chips--empty", d),
|
|
57
|
+
children: u?.empty ?? "No tools used"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { o as default };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/ai/ToolChips/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { cn } from '../../../utils/cn';\nimport type { AgentStatus } from '../shared';\nimport { AGENT_STATUS_LABEL } from '../shared';\nimport './ToolChips.css';\n\nconst EMPTY_EXPANDED: string[] = [];\n\nexport type ToolChip = { id: string; label: React.ReactNode; status?: AgentStatus; detail?: React.ReactNode; duration?: string; onRetry?: () => void };\nexport type ToolChipsProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & { tools: ToolChip[]; expanded?: string[]; defaultExpanded?: string[]; onExpandedChange?: (ids: string[]) => void; labels?: Partial<Record<AgentStatus, string>> & { retry?: string; empty?: string } };\n\nexport default function ToolChips({ tools, expanded, defaultExpanded = EMPTY_EXPANDED, onExpandedChange, labels, className, ...rest }: ToolChipsProps) {\n const [internal, setInternal] = useState(defaultExpanded);\n const open = expanded ?? internal;\n const toggle = (id: string) => { const next = open.includes(id) ? open.filter(x => x !== id) : [...open, id]; if (expanded === undefined) setInternal(next); onExpandedChange?.(next); };\n if (!tools.length) return <div {...rest} className={cn('dishui-ai-tool-chips dishui-ai-tool-chips--empty', className)}>{labels?.empty ?? 'No tools used'}</div>;\n return <div {...rest} className={cn('dishui-ai-tool-chips', className)}>{tools.map(tool => { const status = tool.status ?? 'completed'; const isOpen = open.includes(tool.id); const panelId = `tool-${tool.id}-detail`; return <div key={tool.id} className={cn('dishui-ai-tool-chips__item', `dishui-ai-tool-chips__item--${status}`)}><button type=\"button\" className=\"dishui-ai-tool-chips__chip\" aria-expanded={tool.detail ? isOpen : undefined} aria-controls={tool.detail ? panelId : undefined} onClick={() => tool.detail && toggle(tool.id)}><span className=\"dishui-ai-tool-chips__mark\" aria-hidden=\"true\">{status === 'completed' ? '✓' : status === 'failed' ? '!' : status === 'running' ? '…' : '·'}</span><span>{tool.label}</span><span className=\"dishui-ai-tool-chips__status\">{labels?.[status] ?? AGENT_STATUS_LABEL[status]}</span>{tool.duration && <span className=\"dishui-ai-tool-chips__duration\">{tool.duration}</span>}</button>{tool.detail && <div id={panelId} hidden={!isOpen} className=\"dishui-ai-tool-chips__detail\">{tool.detail}{status === 'failed' && tool.onRetry && <button type=\"button\" onClick={tool.onRetry}>{labels?.retry ?? 'Retry'}</button>}</div>}</div>; })}</div>;\n}\n"],"mappings":";;;;;;AAMA,IAAM,IAA2B,CAAC;AAKlC,SAAwB,EAAU,EAAE,UAAO,aAAU,qBAAkB,GAAgB,qBAAkB,WAAQ,cAAW,GAAG,KAAwB;CACrJ,IAAM,CAAC,GAAU,KAAe,EAAS,CAAe,GAClD,IAAO,KAAY,GACnB,KAAU,MAAe;EAAE,IAAM,IAAO,EAAK,SAAS,CAAE,IAAI,EAAK,QAAO,MAAK,MAAM,CAAE,IAAI,CAAC,GAAG,GAAM,CAAE;EAAkD,AAA3C,MAAa,KAAA,KAAW,EAAY,CAAI,GAAG,IAAmB,CAAI;CAAG;CAEvL,OADK,EAAM,SACJ,kBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,EAAG,wBAAwB,CAAS;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
|
+
* agent task rows, streaming answers and the surrounding chrome agents
|
|
4
|
+
* need to talk to humans. Also published as the `dishui/ai` subpath.
|
|
5
|
+
*/
|
|
6
|
+
export { formatElapsed, formatDuration, AGENT_STATUS_LABEL } from './shared';
|
|
7
|
+
export type { AgentStatus } from './shared';
|
|
8
|
+
export { default as LoadingState } from './LoadingState';
|
|
9
|
+
export type { LoadingStateProps, LoadingStateVariant } from './LoadingState';
|
|
10
|
+
export { default as Thinking } from './Thinking';
|
|
11
|
+
export type { ThinkingProps, ThinkingStep, ThinkingStepKind, ThinkingMode, ThinkingStatus, ThinkingSearchResult, ThinkingCode } from './Thinking';
|
|
12
|
+
export { default as StreamingText } from './StreamingText';
|
|
13
|
+
export type { StreamingTextProps, StreamingSource, StreamingAction, StreamingFeedback } from './StreamingText';
|
|
14
|
+
export { default as ApprovalCard } from './ApprovalCard';
|
|
15
|
+
export type { ApprovalCardProps, ApprovalOption } from './ApprovalCard';
|
|
16
|
+
export { default as ToolChips } from './ToolChips';
|
|
17
|
+
export type { ToolChipsProps, ToolChip } from './ToolChips';
|
|
18
|
+
export { default as TaskRows } from './TaskRows';
|
|
19
|
+
export type { TaskRowsProps, AgentTask, AgentSubtask, TaskRowsView, TaskRowsLabels } from './TaskRows';
|
|
20
|
+
export { default as AgentChat } from './AgentChat';
|
|
21
|
+
export type { AgentChatProps, AgentChatMessage, AgentChatReasoningStep, ChatThread, AgentChatLabels } from './AgentChat';
|
|
22
|
+
export { default as PromptBar } from './PromptBar';
|
|
23
|
+
export type { PromptBarProps, PromptAttachment } from './PromptBar';
|
|
24
|
+
export { default as RecommendationCard } from './RecommendationCard';
|
|
25
|
+
export { confidenceLevel } from './RecommendationCard';
|
|
26
|
+
export type { RecommendationCardProps, Recommendation, RecommendationAlternative, RecommendationCardLabels, ConfidenceLevel } from './RecommendationCard';
|
|
27
|
+
export { default as ContextCards } from './ContextCards';
|
|
28
|
+
export type { ContextCardsProps, ContextChunk, ContextSource, ContextSourceKind, ContextCardsLabels } from './ContextCards';
|
|
29
|
+
export { default as DiffTable } from './DiffTable';
|
|
30
|
+
export { isDiffCellChange, diffRowChange } from './DiffTable';
|
|
31
|
+
export type { DiffTableProps, DiffTableColumn, DiffCellValue, DiffCell, DiffRowChange, DiffRow, DiffDecision } from './DiffTable';
|
|
32
|
+
export { default as RecordsTable } from './RecordsTable';
|
|
33
|
+
export { STRENGTH_LABEL, strengthPercent, formatRelativeTime } from './RecordsTable';
|
|
34
|
+
export type { RecordsTableProps, RecordRow, RecordStrength, RecordsSortKey, RecordsSort } from './RecordsTable';
|
|
35
|
+
export { default as FilterTable } from './FilterTable';
|
|
36
|
+
export type { FilterTableProps, FilterTableColumn, FilterTableFilter } from './FilterTable';
|
|
37
|
+
export { default as CommandSearch } from './CommandSearch';
|
|
38
|
+
export type { CommandSearchProps, CommandSearchItem } from './CommandSearch';
|
|
39
|
+
export { default as StateFlow } from './StateFlow';
|
|
40
|
+
export type { StateFlowProps, StateFlowNode, StateFlowEdge } from './StateFlow';
|
|
41
|
+
export { default as InsightCards } from './InsightCards';
|
|
42
|
+
export type { InsightCardsProps, InsightCardItem } from './InsightCards';
|
|
43
|
+
export { default as CodeView } from './CodeView';
|
|
44
|
+
export type { CodeViewProps } from './CodeView';
|
|
45
|
+
export { default as FineTuneCard } from './FineTuneCard';
|
|
46
|
+
export type { FineTuneCardProps, FineTuneMetric } from './FineTuneCard';
|
|
47
|
+
export { default as SelectionActions } from './SelectionActions';
|
|
48
|
+
export type { SelectionActionsProps, SelectionAction } from './SelectionActions';
|
|
49
|
+
export { default as AgentScreen } from './AgentScreen';
|
|
50
|
+
export type { AgentScreenProps, AgentScreenStatus, AgentScreenLabels } from './AgentScreen';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the AI-native component set (`src/components/ai`).
|
|
3
|
+
* Keep this file dependency-free so every component can import it cheaply.
|
|
4
|
+
*/
|
|
5
|
+
/** Format elapsed milliseconds as `0.0s`, `12s`, `1m 04s`. */
|
|
6
|
+
export declare function formatElapsed(ms: number): string;
|
|
7
|
+
/** Format a duration for prose, e.g. `for 4s`, `for 1m 04s`. */
|
|
8
|
+
export declare function formatDuration(ms: number): string;
|
|
9
|
+
/** Status vocabulary shared by task rows, tool chips and thinking steps. */
|
|
10
|
+
export type AgentStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
|
|
11
|
+
export declare const AGENT_STATUS_LABEL: Record<AgentStatus, string>;
|
|
12
|
+
/** Clamp a number into `[min, max]`. */
|
|
13
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/components/ai/shared.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
(!Number.isFinite(e) || e < 0) && (e = 0);
|
|
4
|
+
let t = e / 1e3;
|
|
5
|
+
return t < 10 ? `${t.toFixed(1)}s` : t < 60 ? `${Math.floor(t)}s` : `${Math.floor(t / 60)}m ${Math.floor(t % 60).toString().padStart(2, "0")}s`;
|
|
6
|
+
}
|
|
7
|
+
function t(e) {
|
|
8
|
+
(!Number.isFinite(e) || e < 0) && (e = 0);
|
|
9
|
+
let t = Math.round(e / 1e3);
|
|
10
|
+
return t < 60 ? `${t}s` : `${Math.floor(t / 60)}m ${(t % 60).toString().padStart(2, "0")}s`;
|
|
11
|
+
}
|
|
12
|
+
var n = {
|
|
13
|
+
pending: "Pending",
|
|
14
|
+
running: "Running",
|
|
15
|
+
completed: "Completed",
|
|
16
|
+
failed: "Failed",
|
|
17
|
+
skipped: "Skipped"
|
|
18
|
+
};
|
|
19
|
+
function r(e, t, n) {
|
|
20
|
+
return Math.min(n, Math.max(t, e));
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { n as AGENT_STATUS_LABEL, r as clamp, t as formatDuration, e as formatElapsed };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../../src/components/ai/shared.ts"],"sourcesContent":["/**\n * Shared helpers for the AI-native component set (`src/components/ai`).\n * Keep this file dependency-free so every component can import it cheaply.\n */\n\n/** Format elapsed milliseconds as `0.0s`, `12s`, `1m 04s`. */\nexport function formatElapsed(ms: number): string {\n if (!Number.isFinite(ms) || ms < 0) ms = 0;\n const seconds = ms / 1000;\n if (seconds < 10) return `${seconds.toFixed(1)}s`;\n if (seconds < 60) return `${Math.floor(seconds)}s`;\n const minutes = Math.floor(seconds / 60);\n const rest = Math.floor(seconds % 60);\n return `${minutes}m ${rest.toString().padStart(2, '0')}s`;\n}\n\n/** Format a duration for prose, e.g. `for 4s`, `for 1m 04s`. */\nexport function formatDuration(ms: number): string {\n if (!Number.isFinite(ms) || ms < 0) ms = 0;\n const seconds = Math.round(ms / 1000);\n if (seconds < 60) return `${seconds}s`;\n const minutes = Math.floor(seconds / 60);\n const rest = seconds % 60;\n return `${minutes}m ${rest.toString().padStart(2, '0')}s`;\n}\n\n/** Status vocabulary shared by task rows, tool chips and thinking steps. */\nexport type AgentStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';\n\nexport const AGENT_STATUS_LABEL: Record<AgentStatus, string> = {\n pending: 'Pending',\n running: 'Running',\n completed: 'Completed',\n failed: 'Failed',\n skipped: 'Skipped',\n};\n\n/** Clamp a number into `[min, max]`. */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n"],"mappings":";AAMA,SAAgB,EAAc,GAAoB;CAChD,CAAI,CAAC,OAAO,SAAS,CAAE,KAAK,IAAK,OAAG,IAAK;CACzC,IAAM,IAAU,IAAK;CAKrB,OAJI,IAAU,KAAW,GAAG,EAAQ,QAAQ,CAAC,EAAE,KAC3C,IAAU,KAAW,GAAG,KAAK,MAAM,CAAO,EAAE,KAGzC,GAFS,KAAK,MAAM,IAAU,EAE3B,EAAQ,IADL,KAAK,MAAM,IAAU,EACZ,CAAA,CAAK,SAAS,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE;AACzD;AAGA,SAAgB,EAAe,GAAoB;CACjD,CAAI,CAAC,OAAO,SAAS,CAAE,KAAK,IAAK,OAAG,IAAK;CACzC,IAAM,IAAU,KAAK,MAAM,IAAK,GAAI;CAIpC,OAHI,IAAU,KAAW,GAAG,EAAQ,KAG7B,GAFS,KAAK,MAAM,IAAU,EAE3B,EAAQ,KADL,IAAU,GAAA,CACI,SAAS,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE;AACzD;AAKA,IAAa,IAAkD;CAC7D,SAAS;CACT,SAAS;CACT,WAAW;CACX,QAAQ;CACR,SAAS;AACX;AAGA,SAAgB,EAAM,GAAe,GAAa,GAAqB;CACrE,OAAO,KAAK,IAAI,GAAK,KAAK,IAAI,GAAK,CAAK,CAAC;AAC3C"}
|
|
@@ -5,31 +5,33 @@ import { TableBody as r } from "./components/TableBody.js";
|
|
|
5
5
|
import { TablePagination as i } from "./components/TablePagination.js";
|
|
6
6
|
import { treeRowAnimationStyles as a } from "./treeDataUtils.js";
|
|
7
7
|
import { useDataTableModel as o } from "./useDataTableModel.js";
|
|
8
|
-
import { useColumnDragReorder as
|
|
9
|
-
import
|
|
10
|
-
import { Fragment as
|
|
8
|
+
import { useColumnDragReorder as ee } from "./useColumnDragReorder.js";
|
|
9
|
+
import s, { useCallback as c, useEffect as l, useState as u } from "react";
|
|
10
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/pro/DataTable/DataTable.tsx
|
|
12
|
-
function
|
|
13
|
-
let { data:
|
|
12
|
+
function m(m) {
|
|
13
|
+
let { data: h, columns: te, className: ne = "", viewMode: g, defaultViewMode: _ = "table", onViewModeChange: v, enableViewSwitcher: y = !1, viewSwitcherLabels: b, cardOptions: x, enableSorting: S = !0, enablePagination: C = !0, enableColumnReordering: w = !0, enableExpanding: re = !1, indentSize: ie = 16, toolbar: ae = {
|
|
14
14
|
enabled: !1,
|
|
15
15
|
enableColumnSelector: !1,
|
|
16
16
|
enableFiltering: !1,
|
|
17
17
|
enableBulkActions: !1
|
|
18
|
-
}, customFilterPanel:
|
|
18
|
+
}, customFilterPanel: oe, onRowClick: se, onRowDoubleClick: ce, onRowMouseEnter: le, onRowMouseLeave: T, onCellClick: E, onCellDoubleClick: D, onCellMouseEnter: O, onCellMouseLeave: k, onColumnMouseEnter: A, onColumnMouseLeave: j, extensions: M = [] } = m, { table: N, rowSelection: P, visibilityState: F, columnOrderState: I, setColumnOrderState: L, expandedRowsState: R, handleRowExpand: z, resolveRowId: B, handlePaginationChange: ue } = o(m), [V, H] = u(null), [U, de] = u(_), W = g ?? U, fe = (e) => {
|
|
19
|
+
e !== W && (g === void 0 && de(e), v?.(e));
|
|
20
|
+
}, { draggedColumnId: G, handleDragStart: K, handleDragOver: pe, handleDrop: q } = ee(I, L), J = {
|
|
19
21
|
table: N,
|
|
20
|
-
data:
|
|
22
|
+
data: h,
|
|
21
23
|
rows: N.getRowModel().rows,
|
|
22
24
|
selectedRows: N.getSelectedRowModel().flatRows.map((e) => e.original),
|
|
23
25
|
getRowId: B
|
|
24
|
-
}, [Y, X] =
|
|
25
|
-
|
|
26
|
+
}, [Y, X] = u(null);
|
|
27
|
+
l(() => {
|
|
26
28
|
if (!Y) return;
|
|
27
29
|
let e = () => X(null);
|
|
28
30
|
return window.addEventListener("click", e), window.addEventListener("scroll", e, !0), () => {
|
|
29
31
|
window.removeEventListener("click", e), window.removeEventListener("scroll", e, !0);
|
|
30
32
|
};
|
|
31
33
|
}, [Y]);
|
|
32
|
-
let
|
|
34
|
+
let me = c((e, t, n, r) => {
|
|
33
35
|
if (M.length === 0) return;
|
|
34
36
|
let i = n?.id ?? "", a = {
|
|
35
37
|
value: n?.id == null ? void 0 : t[n.id],
|
|
@@ -62,85 +64,102 @@ function h(h) {
|
|
|
62
64
|
break;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
return
|
|
67
|
+
return l(() => {
|
|
66
68
|
let e = document.createElement("style");
|
|
67
69
|
return e.textContent = a, document.head.appendChild(e), () => {
|
|
68
70
|
document.head.removeChild(e);
|
|
69
71
|
};
|
|
70
|
-
}, []), /* @__PURE__ */
|
|
71
|
-
className: `w-full ${
|
|
72
|
+
}, []), /* @__PURE__ */ p("div", {
|
|
73
|
+
className: `w-full ${ne}`,
|
|
72
74
|
children: [
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
toolbar:
|
|
75
|
+
/* @__PURE__ */ f(t, {
|
|
76
|
+
toolbar: ae,
|
|
75
77
|
table: N,
|
|
76
|
-
columns:
|
|
78
|
+
columns: te,
|
|
77
79
|
columnOrderState: I,
|
|
78
80
|
visibilityState: F,
|
|
79
|
-
activeFilter:
|
|
80
|
-
setActiveFilter:
|
|
81
|
-
customFilterPanel:
|
|
82
|
-
draggedColumnId:
|
|
83
|
-
handleDragStart:
|
|
81
|
+
activeFilter: V,
|
|
82
|
+
setActiveFilter: H,
|
|
83
|
+
customFilterPanel: oe,
|
|
84
|
+
draggedColumnId: G,
|
|
85
|
+
handleDragStart: K,
|
|
84
86
|
toggleColumnVisibility: (e) => {
|
|
85
87
|
N.getColumn(e)?.toggleVisibility();
|
|
86
88
|
},
|
|
87
89
|
rowSelection: P,
|
|
88
|
-
data:
|
|
89
|
-
enableColumnReordering:
|
|
90
|
-
handleDrop: q
|
|
90
|
+
data: h,
|
|
91
|
+
enableColumnReordering: w,
|
|
92
|
+
handleDrop: q,
|
|
93
|
+
viewSwitcher: y && $ === void 0 ? /* @__PURE__ */ f("div", {
|
|
94
|
+
role: "group",
|
|
95
|
+
"aria-label": b?.label ?? "显示方式",
|
|
96
|
+
className: "flex items-center gap-1",
|
|
97
|
+
children: ["table", "card"].map((e) => /* @__PURE__ */ f("button", {
|
|
98
|
+
type: "button",
|
|
99
|
+
className: `btn btn-sm ${W === e ? "btn-neutral" : "btn-ghost"}`,
|
|
100
|
+
"aria-pressed": W === e,
|
|
101
|
+
disabled: g !== void 0 && !v,
|
|
102
|
+
onClick: () => fe(e),
|
|
103
|
+
children: b?.[e] ?? (e === "table" ? "表格" : "卡片")
|
|
104
|
+
}, e))
|
|
105
|
+
}) : void 0
|
|
91
106
|
}),
|
|
92
|
-
Z.length > 0 && /* @__PURE__ */
|
|
107
|
+
Z.length > 0 && /* @__PURE__ */ f("div", {
|
|
93
108
|
className: "flex flex-wrap items-start gap-3 mb-4",
|
|
94
|
-
children: Z.map((e) => /* @__PURE__ */
|
|
109
|
+
children: Z.map((e) => /* @__PURE__ */ f(s.Fragment, { children: e.node }, e.name))
|
|
95
110
|
}),
|
|
96
|
-
$ === void 0 ? /* @__PURE__ */
|
|
111
|
+
$ === void 0 ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
|
|
97
112
|
className: "overflow-x-auto",
|
|
98
|
-
children: /* @__PURE__ */
|
|
113
|
+
children: /* @__PURE__ */ p(e, {
|
|
99
114
|
className: "table-sm w-full",
|
|
100
|
-
|
|
115
|
+
card: W === "card",
|
|
116
|
+
cardOptions: x,
|
|
117
|
+
children: [/* @__PURE__ */ f(n, {
|
|
101
118
|
table: N,
|
|
102
119
|
visibilityState: F,
|
|
103
|
-
enableSorting:
|
|
104
|
-
enableColumnReordering:
|
|
105
|
-
draggedColumnId:
|
|
120
|
+
enableSorting: S,
|
|
121
|
+
enableColumnReordering: w,
|
|
122
|
+
draggedColumnId: G,
|
|
106
123
|
onColumnMouseEnter: A,
|
|
107
124
|
onColumnMouseLeave: j,
|
|
108
|
-
handleDragStart:
|
|
109
|
-
handleDragOver:
|
|
125
|
+
handleDragStart: K,
|
|
126
|
+
handleDragOver: pe,
|
|
110
127
|
handleDrop: q
|
|
111
|
-
}), /* @__PURE__ */
|
|
128
|
+
}), /* @__PURE__ */ f(r, {
|
|
112
129
|
table: N,
|
|
130
|
+
card: W === "card",
|
|
131
|
+
fieldLabels: x?.fieldLabels,
|
|
113
132
|
expandedRowsState: R,
|
|
114
|
-
onRowClick:
|
|
115
|
-
onRowDoubleClick:
|
|
116
|
-
onRowMouseEnter:
|
|
117
|
-
onRowMouseLeave:
|
|
133
|
+
onRowClick: se,
|
|
134
|
+
onRowDoubleClick: ce,
|
|
135
|
+
onRowMouseEnter: le,
|
|
136
|
+
onRowMouseLeave: T,
|
|
118
137
|
onCellClick: E,
|
|
119
138
|
onCellDoubleClick: D,
|
|
120
139
|
onCellMouseEnter: O,
|
|
121
140
|
onCellMouseLeave: k,
|
|
122
|
-
enableExpanding:
|
|
123
|
-
indentSize:
|
|
141
|
+
enableExpanding: re,
|
|
142
|
+
indentSize: ie,
|
|
124
143
|
handleRowExpand: z,
|
|
125
144
|
extensions: M,
|
|
126
145
|
extensionApi: J,
|
|
127
146
|
getRowId: B,
|
|
128
|
-
onCellContextMenu:
|
|
147
|
+
onCellContextMenu: me
|
|
129
148
|
})]
|
|
130
149
|
})
|
|
131
|
-
}), /* @__PURE__ */
|
|
132
|
-
enablePagination:
|
|
150
|
+
}), /* @__PURE__ */ f(i, {
|
|
151
|
+
enablePagination: C,
|
|
133
152
|
table: N,
|
|
134
|
-
onPaginationChange:
|
|
135
|
-
})] }) : /* @__PURE__ */
|
|
153
|
+
onPaginationChange: ue
|
|
154
|
+
})] }) : /* @__PURE__ */ f("div", {
|
|
136
155
|
className: "w-full",
|
|
137
156
|
children: $
|
|
138
157
|
}),
|
|
139
|
-
Q.length > 0 && /* @__PURE__ */
|
|
158
|
+
Q.length > 0 && /* @__PURE__ */ f("div", {
|
|
140
159
|
className: "flex flex-wrap items-center gap-3 mt-4",
|
|
141
|
-
children: Q.map((e) => /* @__PURE__ */
|
|
160
|
+
children: Q.map((e) => /* @__PURE__ */ f(s.Fragment, { children: e.node }, e.name))
|
|
142
161
|
}),
|
|
143
|
-
Y && /* @__PURE__ */
|
|
162
|
+
Y && /* @__PURE__ */ f("ul", {
|
|
144
163
|
className: "menu bg-base-100 rounded-box shadow-lg border border-base-300 z-1000 p-1",
|
|
145
164
|
style: {
|
|
146
165
|
position: "fixed",
|
|
@@ -148,7 +167,7 @@ function h(h) {
|
|
|
148
167
|
left: Y.x,
|
|
149
168
|
minWidth: 160
|
|
150
169
|
},
|
|
151
|
-
children: Y.items.map((e) => e.separator ? /* @__PURE__ */
|
|
170
|
+
children: Y.items.map((e) => e.separator ? /* @__PURE__ */ f("li", { className: "my-1 border-t border-base-300" }, e.key) : /* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
152
171
|
type: "button",
|
|
153
172
|
disabled: e.disabled,
|
|
154
173
|
onClick: () => {
|
|
@@ -161,6 +180,6 @@ function h(h) {
|
|
|
161
180
|
});
|
|
162
181
|
}
|
|
163
182
|
//#endregion
|
|
164
|
-
export {
|
|
183
|
+
export { m as default };
|
|
165
184
|
|
|
166
185
|
//# sourceMappingURL=DataTable.js.map
|