@celljs/ta-glance 4.16.0 → 4.18.0
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/extension/index.mjs +41 -16
- package/package.json +4 -3
- package/web/index.js +829 -407
package/web/index.js
CHANGED
|
@@ -1,7 +1,544 @@
|
|
|
1
|
+
// web-src/glance-util.ts
|
|
2
|
+
function percent(before, after) {
|
|
3
|
+
if (!before) {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
const change = Math.round((after - before) / Math.abs(before) * 100);
|
|
7
|
+
return `${change > 0 ? "+" : ""}${change}%`;
|
|
8
|
+
}
|
|
9
|
+
function range(values) {
|
|
10
|
+
const low = Math.min(...values);
|
|
11
|
+
const high = Math.max(...values);
|
|
12
|
+
if (!values.length) {
|
|
13
|
+
return { low: 0, high: 1 };
|
|
14
|
+
}
|
|
15
|
+
if (low === high) {
|
|
16
|
+
return { low: low - 1, high: high + 1 };
|
|
17
|
+
}
|
|
18
|
+
const margin = (high - low) * 0.08;
|
|
19
|
+
return { low: low - margin, high: high + margin };
|
|
20
|
+
}
|
|
21
|
+
function points(values, count, { low, high }, width, height) {
|
|
22
|
+
const step = count > 1 ? width / (count - 1) : 0;
|
|
23
|
+
return values.map((value, index) => [count > 1 ? index * step : width / 2, height - (value - low) / (high - low) * height]);
|
|
24
|
+
}
|
|
25
|
+
function share(part, total) {
|
|
26
|
+
const value = total > 0 ? part / total * 100 : 0;
|
|
27
|
+
return value > 0 && value < 1 ? "<1%" : `${Math.round(value)}%`;
|
|
28
|
+
}
|
|
29
|
+
function wordy(value) {
|
|
30
|
+
return !/\d/.test(value) || /[,;。、]|[,;]\s/.test(value) || value.length > 12;
|
|
31
|
+
}
|
|
32
|
+
function plain(text) {
|
|
33
|
+
return text.replace(/\*\*|`/g, "").trim();
|
|
34
|
+
}
|
|
35
|
+
function showsStatus(card) {
|
|
36
|
+
return card.status === "done" ? !!card.title : !(card.status === "blocked" && card.blocks.some((block) => block.type === "options"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// web-src/react.ts
|
|
40
|
+
var React;
|
|
41
|
+
function bind(react) {
|
|
42
|
+
React = react;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// web-src/card-charts.tsx
|
|
46
|
+
var WIDTH = 300;
|
|
47
|
+
var HEIGHT = 100;
|
|
48
|
+
function count(value) {
|
|
49
|
+
return Math.abs(value) >= 1000 ? value.toLocaleString() : String(Number(value.toFixed(2)));
|
|
50
|
+
}
|
|
51
|
+
function glanceCharts({ Text }) {
|
|
52
|
+
function Polyline({
|
|
53
|
+
values,
|
|
54
|
+
count: count2,
|
|
55
|
+
scale,
|
|
56
|
+
area,
|
|
57
|
+
index
|
|
58
|
+
}) {
|
|
59
|
+
const at = points(values, count2, scale, WIDTH, HEIGHT);
|
|
60
|
+
const line = at.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
|
|
61
|
+
const last = at[at.length - 1];
|
|
62
|
+
return /* @__PURE__ */ React.createElement("g", {
|
|
63
|
+
className: "tag-series",
|
|
64
|
+
"data-index": index
|
|
65
|
+
}, area && at.length > 1 && /* @__PURE__ */ React.createElement("polygon", {
|
|
66
|
+
className: "tag-series-area",
|
|
67
|
+
points: `0,${HEIGHT} ${line} ${last[0].toFixed(1)},${HEIGHT}`
|
|
68
|
+
}), /* @__PURE__ */ React.createElement("polyline", {
|
|
69
|
+
points: line,
|
|
70
|
+
fill: "none",
|
|
71
|
+
vectorEffect: "non-scaling-stroke"
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
function Sparkline({ values }) {
|
|
75
|
+
return /* @__PURE__ */ React.createElement("svg", {
|
|
76
|
+
className: "tag-spark",
|
|
77
|
+
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
78
|
+
preserveAspectRatio: "none",
|
|
79
|
+
"aria-hidden": "true"
|
|
80
|
+
}, /* @__PURE__ */ React.createElement(Polyline, {
|
|
81
|
+
values,
|
|
82
|
+
count: values.length,
|
|
83
|
+
scale: range(values),
|
|
84
|
+
area: true,
|
|
85
|
+
index: 0
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
function Line({ block }) {
|
|
89
|
+
const size = Math.max(block.labels.length, ...block.series.map((line) => line.values.length));
|
|
90
|
+
const scale = range(block.series.flatMap((line) => line.values));
|
|
91
|
+
const unit = block.unit ? ` ${block.unit}` : "";
|
|
92
|
+
const marks = [...new Set(size >= 5 ? [0, Math.round((size - 1) / 2), size - 1] : [0, size - 1])].filter((index) => block.labels[index] !== undefined);
|
|
93
|
+
const where = (index) => size > 1 ? index / (size - 1) * 100 : 50;
|
|
94
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
95
|
+
className: "tag-line"
|
|
96
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
97
|
+
className: "tag-section-head tag-legend"
|
|
98
|
+
}, block.series.map((line, index) => {
|
|
99
|
+
const first = line.values[0];
|
|
100
|
+
const last = line.values[line.values.length - 1];
|
|
101
|
+
const change = line.values.length > 1 ? percent(first, last) : "";
|
|
102
|
+
const better = block.better === "higher" ? last > first : last < first;
|
|
103
|
+
const tone = !block.better || last === first ? "neutral" : better ? "good" : "bad";
|
|
104
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
105
|
+
key: index,
|
|
106
|
+
className: "tag-line-key",
|
|
107
|
+
"data-index": index
|
|
108
|
+
}, /* @__PURE__ */ React.createElement("i", null), line.label && /* @__PURE__ */ React.createElement(Text, {
|
|
109
|
+
text: line.label
|
|
110
|
+
}), /* @__PURE__ */ React.createElement("b", null, count(last), unit), change && /* @__PURE__ */ React.createElement("span", {
|
|
111
|
+
className: "tag-delta",
|
|
112
|
+
"data-tone": tone
|
|
113
|
+
}, change));
|
|
114
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
115
|
+
className: "tag-plot"
|
|
116
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
117
|
+
className: "tag-plot-area"
|
|
118
|
+
}, /* @__PURE__ */ React.createElement("svg", {
|
|
119
|
+
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
120
|
+
preserveAspectRatio: "none",
|
|
121
|
+
"aria-hidden": "true"
|
|
122
|
+
}, [0, HEIGHT / 2, HEIGHT].map((y) => /* @__PURE__ */ React.createElement("line", {
|
|
123
|
+
key: y,
|
|
124
|
+
className: "tag-grid",
|
|
125
|
+
x1: 0,
|
|
126
|
+
x2: WIDTH,
|
|
127
|
+
y1: y,
|
|
128
|
+
y2: y,
|
|
129
|
+
vectorEffect: "non-scaling-stroke"
|
|
130
|
+
})), block.series.map((line, index) => /* @__PURE__ */ React.createElement(Polyline, {
|
|
131
|
+
key: index,
|
|
132
|
+
values: line.values,
|
|
133
|
+
count: size,
|
|
134
|
+
scale,
|
|
135
|
+
area: index === 0 && block.series.length === 1,
|
|
136
|
+
index
|
|
137
|
+
}))), block.series.map((line, index) => {
|
|
138
|
+
const [x, y] = points(line.values, size, scale, WIDTH, HEIGHT)[line.values.length - 1];
|
|
139
|
+
return /* @__PURE__ */ React.createElement("i", {
|
|
140
|
+
key: index,
|
|
141
|
+
className: "tag-plot-dot",
|
|
142
|
+
"data-index": index,
|
|
143
|
+
style: { left: `${x / WIDTH * 100}%`, top: `${y / HEIGHT * 100}%` }
|
|
144
|
+
});
|
|
145
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
146
|
+
className: "tag-plot-axis",
|
|
147
|
+
"aria-hidden": "true"
|
|
148
|
+
}, /* @__PURE__ */ React.createElement("span", null, count(Math.max(...block.series.flatMap((line) => line.values)))), /* @__PURE__ */ React.createElement("span", null, count(Math.min(...block.series.flatMap((line) => line.values))))), marks.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
149
|
+
className: "tag-plot-labels"
|
|
150
|
+
}, marks.map((index) => /* @__PURE__ */ React.createElement("span", {
|
|
151
|
+
key: index,
|
|
152
|
+
"data-at": index === 0 ? "start" : index === size - 1 ? "end" : "middle",
|
|
153
|
+
style: { left: `${where(index)}%` }
|
|
154
|
+
}, block.labels[index])))));
|
|
155
|
+
}
|
|
156
|
+
function Share({ block }) {
|
|
157
|
+
const total = block.items.reduce((sum, item) => sum + item.value, 0);
|
|
158
|
+
const unit = block.unit ? ` ${block.unit}` : "";
|
|
159
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
160
|
+
className: "tag-share"
|
|
161
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
162
|
+
className: "tag-share-bar",
|
|
163
|
+
"aria-hidden": "true"
|
|
164
|
+
}, block.items.map((item, index) => /* @__PURE__ */ React.createElement("i", {
|
|
165
|
+
key: index,
|
|
166
|
+
"data-index": index,
|
|
167
|
+
style: { flexGrow: item.value }
|
|
168
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
169
|
+
className: "tag-share-keys"
|
|
170
|
+
}, block.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
171
|
+
key: index,
|
|
172
|
+
className: "tag-share-key",
|
|
173
|
+
"data-index": index
|
|
174
|
+
}, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", {
|
|
175
|
+
className: "tag-share-label"
|
|
176
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
177
|
+
text: item.label
|
|
178
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
179
|
+
className: "tag-share-value"
|
|
180
|
+
}, count(item.value), unit), /* @__PURE__ */ React.createElement("b", null, share(item.value, total))))));
|
|
181
|
+
}
|
|
182
|
+
return { Sparkline, Line, Share };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ../ta-protocol/esm/common/language.js
|
|
186
|
+
var TaLanguageUtil;
|
|
187
|
+
(function(TaLanguageUtil2) {
|
|
188
|
+
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
189
|
+
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
190
|
+
function of(tag) {
|
|
191
|
+
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
192
|
+
if (/^zh(\b|-)/.test(said)) {
|
|
193
|
+
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
194
|
+
}
|
|
195
|
+
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
196
|
+
}
|
|
197
|
+
TaLanguageUtil2.of = of;
|
|
198
|
+
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
199
|
+
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
200
|
+
}
|
|
201
|
+
TaLanguageUtil2.server = server;
|
|
202
|
+
function pick(language, words) {
|
|
203
|
+
return words[of(language)];
|
|
204
|
+
}
|
|
205
|
+
TaLanguageUtil2.pick = pick;
|
|
206
|
+
function say(words) {
|
|
207
|
+
return words[server()];
|
|
208
|
+
}
|
|
209
|
+
TaLanguageUtil2.say = say;
|
|
210
|
+
function chinese(language) {
|
|
211
|
+
return of(language).startsWith("zh");
|
|
212
|
+
}
|
|
213
|
+
TaLanguageUtil2.chinese = chinese;
|
|
214
|
+
function cjk(language) {
|
|
215
|
+
return of(language) !== "en-US";
|
|
216
|
+
}
|
|
217
|
+
TaLanguageUtil2.cjk = cjk;
|
|
218
|
+
function list(language, items) {
|
|
219
|
+
return items.join(cjk(language) ? "、" : ", ");
|
|
220
|
+
}
|
|
221
|
+
TaLanguageUtil2.list = list;
|
|
222
|
+
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
223
|
+
|
|
224
|
+
// web-src/i18n.ts
|
|
225
|
+
var EN = {
|
|
226
|
+
status: { done: "Done", partial: "Partly done", failed: "Failed", blocked: "Needs you", info: "" },
|
|
227
|
+
before: "Before",
|
|
228
|
+
after: "After",
|
|
229
|
+
recommended: "Recommended",
|
|
230
|
+
choose: "Choose",
|
|
231
|
+
chosen: "Chosen",
|
|
232
|
+
pick: "I choose: {label}",
|
|
233
|
+
several: "Choose any",
|
|
234
|
+
submit: "Send",
|
|
235
|
+
listJoin: ", ",
|
|
236
|
+
details: "Details",
|
|
237
|
+
hide: "Hide",
|
|
238
|
+
more: "{count} more",
|
|
239
|
+
files: "{count} files",
|
|
240
|
+
writing: "Drawing the summary…",
|
|
241
|
+
spokenChoices: "You can choose: {labels}.",
|
|
242
|
+
spokenRecommended: "I suggest {label}.",
|
|
243
|
+
spokenFailed: "{text}: failed.",
|
|
244
|
+
spokenJoin: ", "
|
|
245
|
+
};
|
|
246
|
+
var ZH = {
|
|
247
|
+
status: { done: "已完成", partial: "部分完成", failed: "失败", blocked: "需要你", info: "" },
|
|
248
|
+
before: "之前",
|
|
249
|
+
after: "之后",
|
|
250
|
+
recommended: "推荐",
|
|
251
|
+
choose: "选这个",
|
|
252
|
+
chosen: "已选",
|
|
253
|
+
pick: "我选:{label}",
|
|
254
|
+
several: "可多选",
|
|
255
|
+
submit: "发送",
|
|
256
|
+
listJoin: "、",
|
|
257
|
+
details: "详情",
|
|
258
|
+
hide: "收起",
|
|
259
|
+
more: "还有 {count} 项",
|
|
260
|
+
files: "{count} 个文件",
|
|
261
|
+
writing: "正在整理摘要…",
|
|
262
|
+
spokenChoices: "可以选:{labels}。",
|
|
263
|
+
spokenRecommended: "推荐{label}。",
|
|
264
|
+
spokenFailed: "{text}失败了。",
|
|
265
|
+
spokenJoin: "、"
|
|
266
|
+
};
|
|
267
|
+
var ZH_TW = {
|
|
268
|
+
status: { done: "已完成", partial: "部分完成", failed: "失敗", blocked: "需要你", info: "" },
|
|
269
|
+
before: "之前",
|
|
270
|
+
after: "之後",
|
|
271
|
+
recommended: "推薦",
|
|
272
|
+
choose: "選這個",
|
|
273
|
+
chosen: "已選",
|
|
274
|
+
pick: "我選:{label}",
|
|
275
|
+
several: "可多選",
|
|
276
|
+
submit: "送出",
|
|
277
|
+
listJoin: "、",
|
|
278
|
+
details: "詳情",
|
|
279
|
+
hide: "收起",
|
|
280
|
+
more: "還有 {count} 項",
|
|
281
|
+
files: "{count} 個檔案",
|
|
282
|
+
writing: "正在整理摘要…",
|
|
283
|
+
spokenChoices: "可以選:{labels}。",
|
|
284
|
+
spokenRecommended: "推薦{label}。",
|
|
285
|
+
spokenFailed: "{text}失敗了。",
|
|
286
|
+
spokenJoin: "、"
|
|
287
|
+
};
|
|
288
|
+
var JA = {
|
|
289
|
+
status: { done: "完了", partial: "部分完了", failed: "失敗", blocked: "要対応", info: "" },
|
|
290
|
+
before: "前",
|
|
291
|
+
after: "後",
|
|
292
|
+
recommended: "オススメ",
|
|
293
|
+
choose: "これを選ぶ",
|
|
294
|
+
chosen: "選択済み",
|
|
295
|
+
pick: "私が選んだ:{label}",
|
|
296
|
+
several: "複数選択可",
|
|
297
|
+
submit: "送信",
|
|
298
|
+
listJoin: "、",
|
|
299
|
+
details: "詳細",
|
|
300
|
+
hide: "隠す",
|
|
301
|
+
more: "ほか {count} 件",
|
|
302
|
+
files: "{count} 個のファイル",
|
|
303
|
+
writing: "サマリーを作成中…",
|
|
304
|
+
spokenChoices: "選択肢:{labels}。",
|
|
305
|
+
spokenRecommended: "オススメは{label}です。",
|
|
306
|
+
spokenFailed: "{text}は失敗しました。",
|
|
307
|
+
spokenJoin: "、"
|
|
308
|
+
};
|
|
309
|
+
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
310
|
+
var GlanceWords;
|
|
311
|
+
((GlanceWords) => {
|
|
312
|
+
function of(language) {
|
|
313
|
+
return TaLanguageUtil.pick(language, WORDS);
|
|
314
|
+
}
|
|
315
|
+
GlanceWords.of = of;
|
|
316
|
+
function picked(answer2, labels) {
|
|
317
|
+
const said = answer2.trim();
|
|
318
|
+
return labels.find((label) => said === label || said === format(EN.pick, { label }) || said === format(ZH.pick, { label }));
|
|
319
|
+
}
|
|
320
|
+
GlanceWords.picked = picked;
|
|
321
|
+
const PICKS = Object.values(WORDS).map((words) => words.pick.replace("{label}", ""));
|
|
322
|
+
function answer(words, picks) {
|
|
323
|
+
if (picks.length === 1) {
|
|
324
|
+
return format(words.pick, { label: picks[0].labels.join(words.listJoin) });
|
|
325
|
+
}
|
|
326
|
+
return [format(words.pick, { label: "" }).trim(), ...picks.map((pick) => `${pick.key} ${pick.labels.join(words.listJoin)}`)].join(`
|
|
327
|
+
`);
|
|
328
|
+
}
|
|
329
|
+
GlanceWords.answer = answer;
|
|
330
|
+
function chosen(answer2, labels, key) {
|
|
331
|
+
const lines = answer2.trim().split(`
|
|
332
|
+
`).map((line) => line.trim());
|
|
333
|
+
let said;
|
|
334
|
+
if (key !== undefined) {
|
|
335
|
+
const line = lines.find((each) => each.startsWith(key));
|
|
336
|
+
if (line === undefined) {
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
said = line.slice(key.length).trim();
|
|
340
|
+
} else {
|
|
341
|
+
said = lines.join(" ");
|
|
342
|
+
const prefix = PICKS.find((each) => each && said.startsWith(each));
|
|
343
|
+
said = (prefix ? said.slice(prefix.length) : said).trim();
|
|
344
|
+
}
|
|
345
|
+
const parts = said.split(/\s*(?:、|,\s|,)\s*/);
|
|
346
|
+
return labels.filter((label) => said === label || parts.includes(label));
|
|
347
|
+
}
|
|
348
|
+
GlanceWords.chosen = chosen;
|
|
349
|
+
function format(text, values) {
|
|
350
|
+
return text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
|
|
351
|
+
}
|
|
352
|
+
GlanceWords.format = format;
|
|
353
|
+
})(GlanceWords ||= {});
|
|
354
|
+
|
|
355
|
+
// web-src/card-options.tsx
|
|
356
|
+
function formKey(ask, index) {
|
|
357
|
+
return ask.question ? plain(ask.question) : `${index + 1}.`;
|
|
358
|
+
}
|
|
359
|
+
function glanceOptions(pi, { Reply, Answer, Text, Icon, has }) {
|
|
360
|
+
const FormOf = React.createContext(undefined);
|
|
361
|
+
function useForm(card, words, send, answer) {
|
|
362
|
+
const asks = React.useMemo(() => card?.blocks.filter((block) => block.type === "options") ?? [], [card]);
|
|
363
|
+
const [tapped, setTapped] = React.useState({});
|
|
364
|
+
const [sent, setSent] = React.useState(false);
|
|
365
|
+
if (!(asks.length > 1 || asks.some((ask) => ask.multi))) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const done = sent || answer !== undefined;
|
|
369
|
+
const picks = asks.map((ask, index) => {
|
|
370
|
+
const labels = ask.items.map((item) => item.label);
|
|
371
|
+
if (!sent && answer !== undefined) {
|
|
372
|
+
return GlanceWords.chosen(answer, labels, asks.length > 1 ? formKey(ask, index) : undefined);
|
|
373
|
+
}
|
|
374
|
+
const picked = tapped[index] ?? ask.items.filter((item) => item.recommended).map((item) => item.label);
|
|
375
|
+
return labels.filter((label) => picked.includes(label)).slice(0, ask.multi ? undefined : 1);
|
|
376
|
+
});
|
|
377
|
+
return {
|
|
378
|
+
asks,
|
|
379
|
+
picks,
|
|
380
|
+
done,
|
|
381
|
+
toggle(index, label) {
|
|
382
|
+
const now = picks[index];
|
|
383
|
+
const next = asks[index].multi ? now.includes(label) ? now.filter((each) => each !== label) : [...now, label] : [label];
|
|
384
|
+
setTapped({ ...tapped, [index]: next });
|
|
385
|
+
},
|
|
386
|
+
submit() {
|
|
387
|
+
if (!send || done || picks.some((each) => !each.length)) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
setSent(true);
|
|
391
|
+
const text = GlanceWords.answer(words, asks.map((ask, index) => ({ key: formKey(ask, index), labels: picks[index] })));
|
|
392
|
+
send(text).catch((error) => {
|
|
393
|
+
setSent(false);
|
|
394
|
+
pi.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function Options({ block, words, closed }) {
|
|
400
|
+
const [tapped, setChosen] = React.useState();
|
|
401
|
+
const send = React.useContext(Reply);
|
|
402
|
+
const form = React.useContext(FormOf);
|
|
403
|
+
const answer = React.useContext(Answer);
|
|
404
|
+
const ask = form ? form.asks.indexOf(block) : -1;
|
|
405
|
+
const inForm = !!form && ask >= 0;
|
|
406
|
+
const said = answer.text === undefined ? undefined : GlanceWords.picked(answer.text, block.items.map((item) => item.label));
|
|
407
|
+
const chosen = inForm ? form.picks[ask] : [tapped ?? said].filter((label) => label !== undefined);
|
|
408
|
+
const done = inForm ? form.done : chosen.length > 0 || answer.text !== undefined;
|
|
409
|
+
const pending = answer.known && closed && !done && (!inForm || ask === 0);
|
|
410
|
+
const choose = (label) => {
|
|
411
|
+
if (!send) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (inForm) {
|
|
415
|
+
form.toggle(ask, label);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
setChosen(label);
|
|
419
|
+
send(GlanceWords.format(words.pick, { label })).catch((error) => {
|
|
420
|
+
setChosen(undefined);
|
|
421
|
+
pi.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
425
|
+
className: "tag-options-block",
|
|
426
|
+
"data-pending": pending || undefined
|
|
427
|
+
}, (block.question || block.multi) && /* @__PURE__ */ React.createElement("div", {
|
|
428
|
+
className: "tag-question"
|
|
429
|
+
}, block.question && /* @__PURE__ */ React.createElement(Text, {
|
|
430
|
+
text: block.question
|
|
431
|
+
}), block.multi && /* @__PURE__ */ React.createElement("span", {
|
|
432
|
+
className: "tag-several"
|
|
433
|
+
}, words.several)), inForm ? /* @__PURE__ */ React.createElement("div", {
|
|
434
|
+
className: "tag-picks"
|
|
435
|
+
}, block.items.map((item, index) => {
|
|
436
|
+
const picked = chosen.includes(item.label);
|
|
437
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
438
|
+
key: index,
|
|
439
|
+
type: "button",
|
|
440
|
+
className: "tag-pick",
|
|
441
|
+
"aria-pressed": picked,
|
|
442
|
+
"data-multi": block.multi || undefined,
|
|
443
|
+
"data-other": done && !picked || undefined,
|
|
444
|
+
disabled: !closed || !send || done,
|
|
445
|
+
onClick: () => choose(item.label)
|
|
446
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
447
|
+
className: "tag-pick-mark"
|
|
448
|
+
}, picked && /* @__PURE__ */ React.createElement(Icon, {
|
|
449
|
+
name: "Check",
|
|
450
|
+
size: 11
|
|
451
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
452
|
+
className: "tag-option-main"
|
|
453
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
454
|
+
className: "tag-option-head"
|
|
455
|
+
}, has(item.icon) && /* @__PURE__ */ React.createElement("span", {
|
|
456
|
+
className: "tag-item-icon"
|
|
457
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
458
|
+
name: item.icon,
|
|
459
|
+
size: 14
|
|
460
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
461
|
+
className: "tag-option-label"
|
|
462
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
463
|
+
text: item.label
|
|
464
|
+
})), item.recommended && /* @__PURE__ */ React.createElement("span", {
|
|
465
|
+
className: "tag-badge"
|
|
466
|
+
}, words.recommended)), item.detail && /* @__PURE__ */ React.createElement("span", {
|
|
467
|
+
className: "tag-option-detail"
|
|
468
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
469
|
+
text: item.detail
|
|
470
|
+
}))));
|
|
471
|
+
})) : /* @__PURE__ */ React.createElement("div", {
|
|
472
|
+
className: "tag-options"
|
|
473
|
+
}, block.items.map((item, index) => {
|
|
474
|
+
const picked = chosen.includes(item.label);
|
|
475
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
476
|
+
key: index,
|
|
477
|
+
className: "tag-option",
|
|
478
|
+
"data-recommended": item.recommended || undefined,
|
|
479
|
+
"data-chosen": picked || undefined,
|
|
480
|
+
"data-other": done && !picked || undefined
|
|
481
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
482
|
+
className: "tag-option-main"
|
|
483
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
484
|
+
className: "tag-option-head"
|
|
485
|
+
}, has(item.icon) && /* @__PURE__ */ React.createElement("span", {
|
|
486
|
+
className: "tag-item-icon"
|
|
487
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
488
|
+
name: item.icon,
|
|
489
|
+
size: 14
|
|
490
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
491
|
+
className: "tag-option-label"
|
|
492
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
493
|
+
text: item.label
|
|
494
|
+
})), item.recommended && /* @__PURE__ */ React.createElement("span", {
|
|
495
|
+
className: "tag-badge"
|
|
496
|
+
}, words.recommended)), item.detail && /* @__PURE__ */ React.createElement("div", {
|
|
497
|
+
className: "tag-option-detail"
|
|
498
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
499
|
+
text: item.detail
|
|
500
|
+
})), (item.pros.length > 0 || item.cons.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
501
|
+
className: "tag-points"
|
|
502
|
+
}, item.pros.map((point, at) => /* @__PURE__ */ React.createElement("span", {
|
|
503
|
+
key: `p${at}`,
|
|
504
|
+
"data-tone": "good"
|
|
505
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
506
|
+
text: point
|
|
507
|
+
}))), item.cons.map((point, at) => /* @__PURE__ */ React.createElement("span", {
|
|
508
|
+
key: `c${at}`,
|
|
509
|
+
"data-tone": "bad"
|
|
510
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
511
|
+
text: point
|
|
512
|
+
}))))), /* @__PURE__ */ React.createElement("button", {
|
|
513
|
+
type: "button",
|
|
514
|
+
className: `ta-button tag-choose${item.recommended && !done && !inForm ? " ta-primary" : ""}`,
|
|
515
|
+
"aria-pressed": inForm ? picked : undefined,
|
|
516
|
+
disabled: !closed || !send || done,
|
|
517
|
+
onClick: () => choose(item.label)
|
|
518
|
+
}, picked && /* @__PURE__ */ React.createElement(Icon, {
|
|
519
|
+
name: "Check",
|
|
520
|
+
size: 13
|
|
521
|
+
}), /* @__PURE__ */ React.createElement("span", null, picked ? words.chosen : words.choose)));
|
|
522
|
+
})), inForm && ask === form.asks.length - 1 && !form.done && /* @__PURE__ */ React.createElement("div", {
|
|
523
|
+
className: "tag-submit"
|
|
524
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
525
|
+
type: "button",
|
|
526
|
+
className: "ta-button ta-primary",
|
|
527
|
+
disabled: !closed || !send || form.picks.some((each) => !each.length),
|
|
528
|
+
onClick: () => form.submit()
|
|
529
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
530
|
+
name: "Send",
|
|
531
|
+
size: 13
|
|
532
|
+
}), /* @__PURE__ */ React.createElement("span", null, words.submit))));
|
|
533
|
+
}
|
|
534
|
+
return { Options, FormOf, useForm };
|
|
535
|
+
}
|
|
536
|
+
|
|
1
537
|
// web-src/glance-json.ts
|
|
2
538
|
var GlanceJson;
|
|
3
539
|
((GlanceJson) => {
|
|
4
540
|
const TRIES = 40;
|
|
541
|
+
const CONTROLS = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
|
|
5
542
|
function parse(text, partial) {
|
|
6
543
|
const source = text.trim().replace(/,\s*([}\]])/g, "$1");
|
|
7
544
|
if (!source) {
|
|
@@ -64,6 +601,9 @@ var GlanceJson;
|
|
|
64
601
|
escaped = true;
|
|
65
602
|
} else if (char === '"') {
|
|
66
603
|
inString = false;
|
|
604
|
+
} else if (char < " ") {
|
|
605
|
+
out += CONTROLS[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
606
|
+
continue;
|
|
67
607
|
}
|
|
68
608
|
} else if (char === '"') {
|
|
69
609
|
inString = true;
|
|
@@ -83,15 +623,21 @@ var GlanceJson;
|
|
|
83
623
|
|
|
84
624
|
// web-src/glance-spec.ts
|
|
85
625
|
var ITEMS = 12;
|
|
626
|
+
var FOLDED = 40;
|
|
86
627
|
var POINTS = 24;
|
|
87
628
|
var SERIES = 4;
|
|
88
629
|
var BLOCKS = 8;
|
|
89
630
|
var TEXT = 400;
|
|
90
631
|
var MARKDOWN = 8000;
|
|
91
632
|
var STATUSES = ["done", "partial", "failed", "blocked", "info"];
|
|
633
|
+
var QUIET = ["done", "info"];
|
|
92
634
|
var TONES = ["good", "bad", "warn", "neutral"];
|
|
93
635
|
var STEPS = ["done", "doing", "todo", "failed", "skipped"];
|
|
94
|
-
var NOTES = ["risk", "
|
|
636
|
+
var NOTES = ["risk", "todo", "info"];
|
|
637
|
+
var CHECKS = 3;
|
|
638
|
+
function passed(list, least) {
|
|
639
|
+
return list.length >= least && list.every((item) => item.tone === "good");
|
|
640
|
+
}
|
|
95
641
|
function object(value) {
|
|
96
642
|
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
97
643
|
}
|
|
@@ -234,13 +780,19 @@ function isPath(value) {
|
|
|
234
780
|
}
|
|
235
781
|
var LABELS = { before: "Before", after: "After" };
|
|
236
782
|
function block(item, partial, labels) {
|
|
783
|
+
const made = blockOf(item, partial, labels);
|
|
784
|
+
const fold = object(item)?.fold;
|
|
785
|
+
const words = fold === true ? "" : text(fold, 40);
|
|
786
|
+
return made && words !== undefined ? { ...made, fold: words } : made;
|
|
787
|
+
}
|
|
788
|
+
function blockOf(item, partial, labels) {
|
|
237
789
|
const value = object(item);
|
|
238
790
|
const type = typeof value?.type === "string" ? value.type.trim().toLowerCase() : undefined;
|
|
239
791
|
const unit = text(value?.unit, 16);
|
|
240
792
|
switch (type) {
|
|
241
793
|
case "stats": {
|
|
242
794
|
const list = items(value?.items, stat).slice(0, 6);
|
|
243
|
-
return list.length ? { type, items: list } : undefined;
|
|
795
|
+
return list.length ? { type, items: list, ...passed(list, CHECKS) ? { checks: true } : {} } : undefined;
|
|
244
796
|
}
|
|
245
797
|
case "changes": {
|
|
246
798
|
const raw = Array.isArray(value?.items) ? value.items : [];
|
|
@@ -249,7 +801,7 @@ function block(item, partial, labels) {
|
|
|
249
801
|
const list2 = items(raw, point);
|
|
250
802
|
return list2.length ? { type: "notes", items: list2 } : undefined;
|
|
251
803
|
}
|
|
252
|
-
const list = items(value?.items, change);
|
|
804
|
+
const list = items(value?.items, change, FOLDED);
|
|
253
805
|
return list.length ? { type, items: list } : undefined;
|
|
254
806
|
}
|
|
255
807
|
case "steps": {
|
|
@@ -278,13 +830,13 @@ function block(item, partial, labels) {
|
|
|
278
830
|
return rows.length ? { type: "table", columns: ["", labels.before, labels.after], rows } : undefined;
|
|
279
831
|
}
|
|
280
832
|
case "bars": {
|
|
281
|
-
const list = items(value?.items, amount);
|
|
833
|
+
const list = items(value?.items, amount, FOLDED);
|
|
282
834
|
return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
|
|
283
835
|
}
|
|
284
836
|
case "line": {
|
|
285
|
-
const
|
|
286
|
-
const lines =
|
|
287
|
-
const labels2 =
|
|
837
|
+
const points2 = items(value?.items, amount, POINTS);
|
|
838
|
+
const lines = points2.length ? [{ values: points2.map((point2) => point2.value) }] : Array.isArray(value?.series) ? items(value.series, series, SERIES) : [series(value)].filter((line) => !!line);
|
|
839
|
+
const labels2 = points2.length ? points2.map((point2) => point2.label) : strings(value?.labels, POINTS);
|
|
288
840
|
const better = oneOf(value?.better, ["lower", "higher"]);
|
|
289
841
|
const drawn = lines.filter((line) => partial || line.values.length > 1);
|
|
290
842
|
return drawn.length ? { type, labels: labels2, series: drawn, ...unit ? { unit } : {}, ...better ? { better } : {} } : undefined;
|
|
@@ -302,17 +854,17 @@ function block(item, partial, labels) {
|
|
|
302
854
|
return mermaid ? { type, mermaid } : undefined;
|
|
303
855
|
}
|
|
304
856
|
case "table": {
|
|
305
|
-
const columns =
|
|
306
|
-
const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined);
|
|
857
|
+
const columns = items(value?.columns, (column) => text(column) ?? (typeof column === "string" ? "" : undefined), 6);
|
|
858
|
+
const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined, FOLDED);
|
|
307
859
|
return columns.length && rows.length ? { type, columns, rows } : undefined;
|
|
308
860
|
}
|
|
309
861
|
case "options": {
|
|
310
862
|
const list = items(value?.items, option).slice(0, 5);
|
|
311
863
|
const question = text(value?.question);
|
|
312
|
-
return list.length ? { type, items: list, ...question ? { question } : {} } : undefined;
|
|
864
|
+
return list.length ? { type, items: list, ...question ? { question } : {}, ...value?.multi === true ? { multi: true } : {} } : undefined;
|
|
313
865
|
}
|
|
314
866
|
case "notes": {
|
|
315
|
-
const list = items(value?.items, note);
|
|
867
|
+
const list = items(value?.items, note).sort((a, b) => NOTES.indexOf(a.tone) - NOTES.indexOf(b.tone));
|
|
316
868
|
return list.length ? { type, items: list } : undefined;
|
|
317
869
|
}
|
|
318
870
|
case "next": {
|
|
@@ -339,6 +891,13 @@ function loose(card) {
|
|
|
339
891
|
return out;
|
|
340
892
|
}
|
|
341
893
|
var LISTS = ["stats", "changes", "steps", "flow", "options", "notes", "next"];
|
|
894
|
+
var PLACE = { stats: -1, notes: 1, next: 2, details: 3 };
|
|
895
|
+
function place(block2) {
|
|
896
|
+
return block2.fold !== undefined ? 3 : PLACE[block2.type] ?? 0;
|
|
897
|
+
}
|
|
898
|
+
function placed(blocks) {
|
|
899
|
+
return blocks.map((block2, index) => ({ block: block2, index })).sort((a, b) => place(a.block) - place(b.block) || a.index - b.index).map((entry) => entry.block);
|
|
900
|
+
}
|
|
342
901
|
var GlanceSpec;
|
|
343
902
|
((GlanceSpec) => {
|
|
344
903
|
function read(value, partial = false, labels = LABELS) {
|
|
@@ -348,166 +907,20 @@ var GlanceSpec;
|
|
|
348
907
|
}
|
|
349
908
|
const status = oneOf(card.status, STATUSES);
|
|
350
909
|
const title = text(card.title);
|
|
351
|
-
const blocks = items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS);
|
|
910
|
+
const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS)).map((made) => made.type === "stats" && !made.checks && status && !QUIET.includes(status) && passed(made.items, 1) ? { ...made, checks: true } : made);
|
|
352
911
|
if (!blocks.length && !title) {
|
|
353
912
|
return;
|
|
354
|
-
}
|
|
355
|
-
return { blocks, ...status ? { status } : {}, ...title ? { title } : {} };
|
|
356
|
-
}
|
|
357
|
-
GlanceSpec.read = read;
|
|
358
|
-
})(GlanceSpec ||= {});
|
|
359
|
-
|
|
360
|
-
// web-src/glance-util.ts
|
|
361
|
-
function percent(before, after) {
|
|
362
|
-
if (!before) {
|
|
363
|
-
return "";
|
|
364
|
-
}
|
|
365
|
-
const change2 = Math.round((after - before) / Math.abs(before) * 100);
|
|
366
|
-
return `${change2 > 0 ? "+" : ""}${change2}%`;
|
|
367
|
-
}
|
|
368
|
-
function range(values) {
|
|
369
|
-
const low = Math.min(...values);
|
|
370
|
-
const high = Math.max(...values);
|
|
371
|
-
if (!values.length) {
|
|
372
|
-
return { low: 0, high: 1 };
|
|
373
|
-
}
|
|
374
|
-
if (low === high) {
|
|
375
|
-
return { low: low - 1, high: high + 1 };
|
|
376
|
-
}
|
|
377
|
-
const margin = (high - low) * 0.08;
|
|
378
|
-
return { low: low - margin, high: high + margin };
|
|
379
|
-
}
|
|
380
|
-
function points(values, count, { low, high }, width, height) {
|
|
381
|
-
const step2 = count > 1 ? width / (count - 1) : 0;
|
|
382
|
-
return values.map((value, index) => [count > 1 ? index * step2 : width / 2, height - (value - low) / (high - low) * height]);
|
|
383
|
-
}
|
|
384
|
-
function share(part, total) {
|
|
385
|
-
const value = total > 0 ? part / total * 100 : 0;
|
|
386
|
-
return value > 0 && value < 1 ? "<1%" : `${Math.round(value)}%`;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// ../ta-protocol/esm/common/language.js
|
|
390
|
-
var TaLanguageUtil;
|
|
391
|
-
(function(TaLanguageUtil2) {
|
|
392
|
-
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
393
|
-
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
394
|
-
function of(tag) {
|
|
395
|
-
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
396
|
-
if (/^zh(\b|-)/.test(said)) {
|
|
397
|
-
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
398
|
-
}
|
|
399
|
-
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
400
|
-
}
|
|
401
|
-
TaLanguageUtil2.of = of;
|
|
402
|
-
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
403
|
-
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
404
|
-
}
|
|
405
|
-
TaLanguageUtil2.server = server;
|
|
406
|
-
function pick(language, words) {
|
|
407
|
-
return words[of(language)];
|
|
408
|
-
}
|
|
409
|
-
TaLanguageUtil2.pick = pick;
|
|
410
|
-
function say(words) {
|
|
411
|
-
return words[server()];
|
|
412
|
-
}
|
|
413
|
-
TaLanguageUtil2.say = say;
|
|
414
|
-
function chinese(language) {
|
|
415
|
-
return of(language).startsWith("zh");
|
|
416
|
-
}
|
|
417
|
-
TaLanguageUtil2.chinese = chinese;
|
|
418
|
-
function cjk(language) {
|
|
419
|
-
return of(language) !== "en-US";
|
|
420
|
-
}
|
|
421
|
-
TaLanguageUtil2.cjk = cjk;
|
|
422
|
-
function list(language, items2) {
|
|
423
|
-
return items2.join(cjk(language) ? "、" : ", ");
|
|
424
|
-
}
|
|
425
|
-
TaLanguageUtil2.list = list;
|
|
426
|
-
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
427
|
-
|
|
428
|
-
// web-src/i18n.ts
|
|
429
|
-
var EN = {
|
|
430
|
-
status: { done: "Done", partial: "Partly done", failed: "Failed", blocked: "Needs you", info: "" },
|
|
431
|
-
before: "Before",
|
|
432
|
-
after: "After",
|
|
433
|
-
recommended: "Recommended",
|
|
434
|
-
choose: "Choose",
|
|
435
|
-
chosen: "Chosen",
|
|
436
|
-
pick: "I choose: {label}",
|
|
437
|
-
details: "Details",
|
|
438
|
-
hide: "Hide",
|
|
439
|
-
files: "{count} files",
|
|
440
|
-
writing: "Drawing the summary…"
|
|
441
|
-
};
|
|
442
|
-
var ZH = {
|
|
443
|
-
status: { done: "已完成", partial: "部分完成", failed: "失败", blocked: "需要你", info: "" },
|
|
444
|
-
before: "之前",
|
|
445
|
-
after: "之后",
|
|
446
|
-
recommended: "推荐",
|
|
447
|
-
choose: "选这个",
|
|
448
|
-
chosen: "已选",
|
|
449
|
-
pick: "我选:{label}",
|
|
450
|
-
details: "详情",
|
|
451
|
-
hide: "收起",
|
|
452
|
-
files: "{count} 个文件",
|
|
453
|
-
writing: "正在整理摘要…"
|
|
454
|
-
};
|
|
455
|
-
var ZH_TW = {
|
|
456
|
-
status: { done: "已完成", partial: "部分完成", failed: "失敗", blocked: "需要你", info: "" },
|
|
457
|
-
before: "之前",
|
|
458
|
-
after: "之後",
|
|
459
|
-
recommended: "推薦",
|
|
460
|
-
choose: "選這個",
|
|
461
|
-
chosen: "已選",
|
|
462
|
-
pick: "我選:{label}",
|
|
463
|
-
details: "詳情",
|
|
464
|
-
hide: "收起",
|
|
465
|
-
files: "{count} 個檔案",
|
|
466
|
-
writing: "正在整理摘要…"
|
|
467
|
-
};
|
|
468
|
-
var JA = {
|
|
469
|
-
status: { done: "完了", partial: "部分完了", failed: "失敗", blocked: "要対応", info: "" },
|
|
470
|
-
before: "前",
|
|
471
|
-
after: "後",
|
|
472
|
-
recommended: "オススメ",
|
|
473
|
-
choose: "これを選ぶ",
|
|
474
|
-
chosen: "選択済み",
|
|
475
|
-
pick: "私が選んだ:{label}",
|
|
476
|
-
details: "詳細",
|
|
477
|
-
hide: "隠す",
|
|
478
|
-
files: "{count} 個のファイル",
|
|
479
|
-
writing: "サマリーを作成中…"
|
|
480
|
-
};
|
|
481
|
-
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
482
|
-
var GlanceWords;
|
|
483
|
-
((GlanceWords) => {
|
|
484
|
-
function of(language) {
|
|
485
|
-
return TaLanguageUtil.pick(language, WORDS);
|
|
486
|
-
}
|
|
487
|
-
GlanceWords.of = of;
|
|
488
|
-
function picked(answer, labels) {
|
|
489
|
-
const said = answer.trim();
|
|
490
|
-
return labels.find((label) => said === label || said === format(EN.pick, { label }) || said === format(ZH.pick, { label }));
|
|
491
|
-
}
|
|
492
|
-
GlanceWords.picked = picked;
|
|
493
|
-
function format(text2, values) {
|
|
494
|
-
return text2.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
|
|
495
|
-
}
|
|
496
|
-
GlanceWords.format = format;
|
|
497
|
-
})(GlanceWords ||= {});
|
|
498
|
-
|
|
499
|
-
// web-src/react.ts
|
|
500
|
-
var React;
|
|
501
|
-
function bind(react) {
|
|
502
|
-
React = react;
|
|
503
|
-
}
|
|
913
|
+
}
|
|
914
|
+
return { blocks, ...status ? { status } : {}, ...title ? { title } : {} };
|
|
915
|
+
}
|
|
916
|
+
GlanceSpec.read = read;
|
|
917
|
+
})(GlanceSpec ||= {});
|
|
504
918
|
|
|
505
919
|
// web-src/card.tsx
|
|
506
920
|
var MARKS = /[*_`[\]$\\]/;
|
|
507
921
|
var SQUARES = 5;
|
|
508
922
|
var LINES = 20;
|
|
509
|
-
var
|
|
510
|
-
var HEIGHT = 100;
|
|
923
|
+
var SHOWN = { changes: 5, rows: 4, bars: 6 };
|
|
511
924
|
function fileName(path) {
|
|
512
925
|
return path.replace(/\/+$/, "").split("/").pop() || path;
|
|
513
926
|
}
|
|
@@ -515,9 +928,6 @@ function directory(path) {
|
|
|
515
928
|
const trimmed = path.replace(/\/+$/, "");
|
|
516
929
|
return trimmed.slice(0, Math.max(0, trimmed.lastIndexOf("/")));
|
|
517
930
|
}
|
|
518
|
-
function count(value) {
|
|
519
|
-
return Math.abs(value) >= 1000 ? value.toLocaleString() : String(Number(value.toFixed(2)));
|
|
520
|
-
}
|
|
521
931
|
function glanceCard(pi) {
|
|
522
932
|
const icons = pi.ui.icons;
|
|
523
933
|
const Markdown = pi.ui.Markdown;
|
|
@@ -530,6 +940,38 @@ function glanceCard(pi) {
|
|
|
530
940
|
text: text2
|
|
531
941
|
})) : text2;
|
|
532
942
|
}
|
|
943
|
+
function Clamp({ text: text2 }) {
|
|
944
|
+
const ref = React.useRef(null);
|
|
945
|
+
const [open, setOpen] = React.useState(false);
|
|
946
|
+
const [cut, setCut] = React.useState(false);
|
|
947
|
+
React.useLayoutEffect(() => {
|
|
948
|
+
const node = ref.current;
|
|
949
|
+
if (node && !open) {
|
|
950
|
+
setCut(node.scrollHeight > node.clientHeight + 1);
|
|
951
|
+
}
|
|
952
|
+
}, [text2, open]);
|
|
953
|
+
const folds = cut || open;
|
|
954
|
+
const toggle = (event) => {
|
|
955
|
+
if (!event.target.closest("a, button, input")) {
|
|
956
|
+
setOpen(!open);
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
const key = (event) => {
|
|
960
|
+
if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
|
|
961
|
+
event.preventDefault();
|
|
962
|
+
setOpen(!open);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
966
|
+
ref,
|
|
967
|
+
className: "tag-clamp",
|
|
968
|
+
"data-open": open || undefined,
|
|
969
|
+
"data-cut": folds || undefined,
|
|
970
|
+
...folds ? { role: "button", tabIndex: 0, "aria-expanded": open, onClick: toggle, onKeyDown: key } : {}
|
|
971
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
972
|
+
text: text2
|
|
973
|
+
}));
|
|
974
|
+
}
|
|
533
975
|
function Icon({ name, fallback, size = 14 }) {
|
|
534
976
|
const Found = name && icons[name] || fallback && icons[fallback];
|
|
535
977
|
return Found ? /* @__PURE__ */ React.createElement(Found, {
|
|
@@ -537,145 +979,62 @@ function glanceCard(pi) {
|
|
|
537
979
|
strokeWidth: 2
|
|
538
980
|
}) : null;
|
|
539
981
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const last = at[at.length - 1];
|
|
551
|
-
return /* @__PURE__ */ React.createElement("g", {
|
|
552
|
-
className: "tag-series",
|
|
553
|
-
"data-index": index
|
|
554
|
-
}, area && at.length > 1 && /* @__PURE__ */ React.createElement("polygon", {
|
|
555
|
-
className: "tag-series-area",
|
|
556
|
-
points: `0,${HEIGHT} ${line} ${last[0].toFixed(1)},${HEIGHT}`
|
|
557
|
-
}), /* @__PURE__ */ React.createElement("polyline", {
|
|
558
|
-
points: line,
|
|
559
|
-
fill: "none",
|
|
560
|
-
vectorEffect: "non-scaling-stroke"
|
|
561
|
-
}));
|
|
562
|
-
}
|
|
563
|
-
function Sparkline({ values }) {
|
|
564
|
-
return /* @__PURE__ */ React.createElement("svg", {
|
|
565
|
-
className: "tag-spark",
|
|
566
|
-
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
567
|
-
preserveAspectRatio: "none",
|
|
568
|
-
"aria-hidden": "true"
|
|
569
|
-
}, /* @__PURE__ */ React.createElement(Polyline, {
|
|
570
|
-
values,
|
|
571
|
-
count: values.length,
|
|
572
|
-
scale: range(values),
|
|
573
|
-
area: true,
|
|
574
|
-
index: 0
|
|
575
|
-
}));
|
|
576
|
-
}
|
|
577
|
-
function Line({ block: block2 }) {
|
|
578
|
-
const size = Math.max(block2.labels.length, ...block2.series.map((line) => line.values.length));
|
|
579
|
-
const scale = range(block2.series.flatMap((line) => line.values));
|
|
580
|
-
const unit = block2.unit ? ` ${block2.unit}` : "";
|
|
581
|
-
const marks = [...new Set(size >= 5 ? [0, Math.round((size - 1) / 2), size - 1] : [0, size - 1])].filter((index) => block2.labels[index] !== undefined);
|
|
582
|
-
const where = (index) => size > 1 ? index / (size - 1) * 100 : 50;
|
|
583
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
584
|
-
className: "tag-line"
|
|
585
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
586
|
-
className: "tag-section-head tag-legend"
|
|
587
|
-
}, block2.series.map((line, index) => {
|
|
588
|
-
const first = line.values[0];
|
|
589
|
-
const last = line.values[line.values.length - 1];
|
|
590
|
-
const change2 = line.values.length > 1 ? percent(first, last) : "";
|
|
591
|
-
const better = block2.better === "higher" ? last > first : last < first;
|
|
592
|
-
const tone = !block2.better || last === first ? "neutral" : better ? "good" : "bad";
|
|
593
|
-
return /* @__PURE__ */ React.createElement("span", {
|
|
594
|
-
key: index,
|
|
595
|
-
className: "tag-line-key",
|
|
596
|
-
"data-index": index
|
|
597
|
-
}, /* @__PURE__ */ React.createElement("i", null), line.label && /* @__PURE__ */ React.createElement(Text, {
|
|
598
|
-
text: line.label
|
|
599
|
-
}), /* @__PURE__ */ React.createElement("b", null, count(last), unit), change2 && /* @__PURE__ */ React.createElement("span", {
|
|
600
|
-
className: "tag-delta",
|
|
601
|
-
"data-tone": tone
|
|
602
|
-
}, change2));
|
|
603
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
604
|
-
className: "tag-plot"
|
|
605
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
606
|
-
className: "tag-plot-area"
|
|
607
|
-
}, /* @__PURE__ */ React.createElement("svg", {
|
|
608
|
-
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
609
|
-
preserveAspectRatio: "none",
|
|
610
|
-
"aria-hidden": "true"
|
|
611
|
-
}, [0, HEIGHT / 2, HEIGHT].map((y) => /* @__PURE__ */ React.createElement("line", {
|
|
612
|
-
key: y,
|
|
613
|
-
className: "tag-grid",
|
|
614
|
-
x1: 0,
|
|
615
|
-
x2: WIDTH,
|
|
616
|
-
y1: y,
|
|
617
|
-
y2: y,
|
|
618
|
-
vectorEffect: "non-scaling-stroke"
|
|
619
|
-
})), block2.series.map((line, index) => /* @__PURE__ */ React.createElement(Polyline, {
|
|
620
|
-
key: index,
|
|
621
|
-
values: line.values,
|
|
622
|
-
count: size,
|
|
623
|
-
scale,
|
|
624
|
-
area: index === 0 && block2.series.length === 1,
|
|
625
|
-
index
|
|
626
|
-
}))), block2.series.map((line, index) => {
|
|
627
|
-
const [x, y] = points(line.values, size, scale, WIDTH, HEIGHT)[line.values.length - 1];
|
|
628
|
-
return /* @__PURE__ */ React.createElement("i", {
|
|
629
|
-
key: index,
|
|
630
|
-
className: "tag-plot-dot",
|
|
631
|
-
"data-index": index,
|
|
632
|
-
style: { left: `${x / WIDTH * 100}%`, top: `${y / HEIGHT * 100}%` }
|
|
633
|
-
});
|
|
634
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
635
|
-
className: "tag-plot-axis",
|
|
636
|
-
"aria-hidden": "true"
|
|
637
|
-
}, /* @__PURE__ */ React.createElement("span", null, count(Math.max(...block2.series.flatMap((line) => line.values)))), /* @__PURE__ */ React.createElement("span", null, count(Math.min(...block2.series.flatMap((line) => line.values))))), marks.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
638
|
-
className: "tag-plot-labels"
|
|
639
|
-
}, marks.map((index) => /* @__PURE__ */ React.createElement("span", {
|
|
640
|
-
key: index,
|
|
641
|
-
"data-at": index === 0 ? "start" : index === size - 1 ? "end" : "middle",
|
|
642
|
-
style: { left: `${where(index)}%` }
|
|
643
|
-
}, block2.labels[index])))));
|
|
982
|
+
function Toggle({ open, label, opened, words, onToggle }) {
|
|
983
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
984
|
+
type: "button",
|
|
985
|
+
className: "tag-details-toggle",
|
|
986
|
+
"aria-expanded": open,
|
|
987
|
+
onClick: onToggle
|
|
988
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
989
|
+
name: "ChevronRight",
|
|
990
|
+
size: 14
|
|
991
|
+
}), /* @__PURE__ */ React.createElement("span", null, open ? opened ?? words.hide : label));
|
|
644
992
|
}
|
|
645
|
-
function
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
className: "tag-share-key",
|
|
662
|
-
"data-index": index
|
|
663
|
-
}, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", {
|
|
664
|
-
className: "tag-share-label"
|
|
665
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
666
|
-
text: item.label
|
|
667
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
668
|
-
className: "tag-share-value"
|
|
669
|
-
}, count(item.value), unit), /* @__PURE__ */ React.createElement("b", null, share(item.value, total))))));
|
|
993
|
+
function useMore(count2, shown, words) {
|
|
994
|
+
const [open, setOpen] = React.useState(false);
|
|
995
|
+
if (count2 <= shown + 1) {
|
|
996
|
+
return { limit: count2, toggle: null };
|
|
997
|
+
}
|
|
998
|
+
return {
|
|
999
|
+
limit: open ? count2 : shown,
|
|
1000
|
+
toggle: /* @__PURE__ */ React.createElement("div", {
|
|
1001
|
+
className: "tag-more"
|
|
1002
|
+
}, /* @__PURE__ */ React.createElement(Toggle, {
|
|
1003
|
+
open,
|
|
1004
|
+
label: GlanceWords.format(words.more, { count: count2 - shown }),
|
|
1005
|
+
words,
|
|
1006
|
+
onToggle: () => setOpen(!open)
|
|
1007
|
+
}))
|
|
1008
|
+
};
|
|
670
1009
|
}
|
|
1010
|
+
const has = (name) => !!name && !!icons[name];
|
|
1011
|
+
const { Sparkline, Line, Share } = glanceCharts({ Text });
|
|
671
1012
|
function Stats({ block: block2 }) {
|
|
1013
|
+
if (block2.checks) {
|
|
1014
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1015
|
+
className: "tag-checks"
|
|
1016
|
+
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("span", {
|
|
1017
|
+
key: index,
|
|
1018
|
+
className: "tag-check"
|
|
1019
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
1020
|
+
name: has(item.icon) ? item.icon : "Check",
|
|
1021
|
+
size: 12
|
|
1022
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
1023
|
+
className: "tag-check-label"
|
|
1024
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1025
|
+
text: item.label
|
|
1026
|
+
})), /* @__PURE__ */ React.createElement("b", null, /* @__PURE__ */ React.createElement(Text, {
|
|
1027
|
+
text: item.value
|
|
1028
|
+
})))));
|
|
1029
|
+
}
|
|
672
1030
|
return /* @__PURE__ */ React.createElement("div", {
|
|
673
1031
|
className: "tag-stats",
|
|
674
1032
|
"data-count": block2.items.length
|
|
675
1033
|
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
676
1034
|
key: index,
|
|
677
1035
|
className: "tag-stat",
|
|
678
|
-
"data-tone": item.tone
|
|
1036
|
+
"data-tone": item.tone,
|
|
1037
|
+
"data-words": wordy(item.value) || undefined
|
|
679
1038
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
680
1039
|
className: "tag-stat-value"
|
|
681
1040
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
@@ -718,6 +1077,7 @@ function glanceCard(pi) {
|
|
|
718
1077
|
const add = block2.items.reduce((sum, item) => sum + (item.add ?? 0), 0);
|
|
719
1078
|
const del = block2.items.reduce((sum, item) => sum + (item.del ?? 0), 0);
|
|
720
1079
|
const largest = Math.max(LINES, ...block2.items.map((item) => (item.add ?? 0) + (item.del ?? 0)));
|
|
1080
|
+
const more = useMore(block2.items.length, SHOWN.changes, words);
|
|
721
1081
|
return /* @__PURE__ */ React.createElement("div", {
|
|
722
1082
|
className: "tag-changes"
|
|
723
1083
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -726,7 +1086,7 @@ function glanceCard(pi) {
|
|
|
726
1086
|
className: "tag-add"
|
|
727
1087
|
}, "+", add), del > 0 && /* @__PURE__ */ React.createElement("span", {
|
|
728
1088
|
className: "tag-del"
|
|
729
|
-
}, "−", del)), block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
1089
|
+
}, "−", del)), block2.items.slice(0, more.limit).map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
730
1090
|
key: index,
|
|
731
1091
|
className: "tag-change"
|
|
732
1092
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -745,7 +1105,7 @@ function glanceCard(pi) {
|
|
|
745
1105
|
title: item.path
|
|
746
1106
|
}, /* @__PURE__ */ React.createElement("bdi", null, directory(item.path)))), item.note && /* @__PURE__ */ React.createElement("span", {
|
|
747
1107
|
className: "tag-change-note"
|
|
748
|
-
}, /* @__PURE__ */ React.createElement(
|
|
1108
|
+
}, /* @__PURE__ */ React.createElement(Clamp, {
|
|
749
1109
|
text: item.note
|
|
750
1110
|
}))), /* @__PURE__ */ React.createElement("span", {
|
|
751
1111
|
className: "tag-change-count"
|
|
@@ -756,7 +1116,7 @@ function glanceCard(pi) {
|
|
|
756
1116
|
}, "−", item.del) : null, /* @__PURE__ */ React.createElement(Squares, {
|
|
757
1117
|
change: item,
|
|
758
1118
|
largest
|
|
759
|
-
})))));
|
|
1119
|
+
})))), more.toggle);
|
|
760
1120
|
}
|
|
761
1121
|
const STEP_ICON = { done: "Check", failed: "X", skipped: "Minus", doing: undefined, todo: undefined };
|
|
762
1122
|
function Steps({ block: block2 }) {
|
|
@@ -773,7 +1133,7 @@ function glanceCard(pi) {
|
|
|
773
1133
|
size: 11
|
|
774
1134
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
775
1135
|
className: "tag-step-text"
|
|
776
|
-
}, /* @__PURE__ */ React.createElement(
|
|
1136
|
+
}, /* @__PURE__ */ React.createElement(Clamp, {
|
|
777
1137
|
text: item.text
|
|
778
1138
|
})))));
|
|
779
1139
|
}
|
|
@@ -819,12 +1179,13 @@ function glanceCard(pi) {
|
|
|
819
1179
|
})));
|
|
820
1180
|
}));
|
|
821
1181
|
}
|
|
822
|
-
function Bars({ block: block2 }) {
|
|
1182
|
+
function Bars({ block: block2, words }) {
|
|
823
1183
|
const largest = Math.max(...block2.items.map((item) => Math.abs(item.value)), 0) || 1;
|
|
824
1184
|
const unit = block2.unit ? ` ${block2.unit}` : "";
|
|
825
|
-
|
|
1185
|
+
const more = useMore(block2.items.length, SHOWN.bars, words);
|
|
1186
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
|
|
826
1187
|
className: "tag-bars"
|
|
827
|
-
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
1188
|
+
}, block2.items.slice(0, more.limit).map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
828
1189
|
key: index,
|
|
829
1190
|
className: "tag-bar"
|
|
830
1191
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -837,7 +1198,7 @@ function glanceCard(pi) {
|
|
|
837
1198
|
style: { width: `${Math.abs(item.value) / largest * 100}%` }
|
|
838
1199
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
839
1200
|
className: "tag-bar-value"
|
|
840
|
-
}, count(item.value), unit))));
|
|
1201
|
+
}, count(item.value), unit)))), more.toggle);
|
|
841
1202
|
}
|
|
842
1203
|
function Flow({ block: block2 }) {
|
|
843
1204
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -862,99 +1223,27 @@ function glanceCard(pi) {
|
|
|
862
1223
|
text: item.text
|
|
863
1224
|
})))));
|
|
864
1225
|
}
|
|
865
|
-
function Table({ block: block2 }) {
|
|
866
|
-
|
|
1226
|
+
function Table({ block: block2, words }) {
|
|
1227
|
+
const more = useMore(block2.rows.length, SHOWN.rows, words);
|
|
1228
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
|
|
867
1229
|
className: "ta-table tag-table"
|
|
868
|
-
}, /* @__PURE__ */ React.createElement("table",
|
|
1230
|
+
}, /* @__PURE__ */ React.createElement("table", {
|
|
1231
|
+
"data-columns": block2.columns.length
|
|
1232
|
+
}, /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", null, block2.columns.map((column, index) => /* @__PURE__ */ React.createElement("th", {
|
|
869
1233
|
key: index
|
|
870
1234
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
871
1235
|
text: column
|
|
872
|
-
}))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.map((row, index) => /* @__PURE__ */ React.createElement("tr", {
|
|
1236
|
+
}))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.slice(0, more.limit).map((row, index) => /* @__PURE__ */ React.createElement("tr", {
|
|
873
1237
|
key: index
|
|
874
1238
|
}, row.map((cell, column) => /* @__PURE__ */ React.createElement("td", {
|
|
875
|
-
key: column
|
|
876
|
-
|
|
1239
|
+
key: column,
|
|
1240
|
+
"data-label": plain(block2.columns[column] ?? "") || undefined
|
|
1241
|
+
}, /* @__PURE__ */ React.createElement(Clamp, {
|
|
877
1242
|
text: cell
|
|
878
|
-
}))))))));
|
|
879
|
-
}
|
|
880
|
-
function Options({ block: block2, words, closed }) {
|
|
881
|
-
const [tapped, setChosen] = React.useState();
|
|
882
|
-
const send = React.useContext(Reply);
|
|
883
|
-
const answer = React.useContext(Answer);
|
|
884
|
-
const said = answer.text === undefined ? undefined : GlanceWords.picked(answer.text, block2.items.map((item) => item.label));
|
|
885
|
-
const chosen = tapped ?? said;
|
|
886
|
-
const done = chosen !== undefined || answer.text !== undefined;
|
|
887
|
-
const pending = answer.known && closed && !done;
|
|
888
|
-
const choose = (label) => {
|
|
889
|
-
if (!send) {
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
setChosen(label);
|
|
893
|
-
send(GlanceWords.format(words.pick, { label })).catch((error) => {
|
|
894
|
-
setChosen(undefined);
|
|
895
|
-
pi.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
896
|
-
});
|
|
897
|
-
};
|
|
898
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
899
|
-
className: "tag-options-block",
|
|
900
|
-
"data-pending": pending || undefined
|
|
901
|
-
}, block2.question && /* @__PURE__ */ React.createElement("div", {
|
|
902
|
-
className: "tag-question"
|
|
903
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
904
|
-
text: block2.question
|
|
905
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
906
|
-
className: "tag-options"
|
|
907
|
-
}, block2.items.map((item, index) => {
|
|
908
|
-
const picked = chosen === item.label;
|
|
909
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
910
|
-
key: index,
|
|
911
|
-
className: "tag-option",
|
|
912
|
-
"data-recommended": item.recommended || undefined,
|
|
913
|
-
"data-chosen": picked || undefined,
|
|
914
|
-
"data-other": done && !picked || undefined
|
|
915
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
916
|
-
className: "tag-option-main"
|
|
917
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
918
|
-
className: "tag-option-head"
|
|
919
|
-
}, has(item.icon) && /* @__PURE__ */ React.createElement("span", {
|
|
920
|
-
className: "tag-item-icon"
|
|
921
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
922
|
-
name: item.icon,
|
|
923
|
-
size: 14
|
|
924
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
925
|
-
className: "tag-option-label"
|
|
926
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
927
|
-
text: item.label
|
|
928
|
-
})), item.recommended && /* @__PURE__ */ React.createElement("span", {
|
|
929
|
-
className: "tag-badge"
|
|
930
|
-
}, words.recommended)), item.detail && /* @__PURE__ */ React.createElement("div", {
|
|
931
|
-
className: "tag-option-detail"
|
|
932
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
933
|
-
text: item.detail
|
|
934
|
-
})), (item.pros.length > 0 || item.cons.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
935
|
-
className: "tag-points"
|
|
936
|
-
}, item.pros.map((point2, at) => /* @__PURE__ */ React.createElement("span", {
|
|
937
|
-
key: `p${at}`,
|
|
938
|
-
"data-tone": "good"
|
|
939
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
940
|
-
text: point2
|
|
941
|
-
}))), item.cons.map((point2, at) => /* @__PURE__ */ React.createElement("span", {
|
|
942
|
-
key: `c${at}`,
|
|
943
|
-
"data-tone": "bad"
|
|
944
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
945
|
-
text: point2
|
|
946
|
-
}))))), /* @__PURE__ */ React.createElement("button", {
|
|
947
|
-
type: "button",
|
|
948
|
-
className: `ta-button tag-choose${item.recommended && !done ? " ta-primary" : ""}`,
|
|
949
|
-
disabled: !closed || !send || done,
|
|
950
|
-
onClick: () => choose(item.label)
|
|
951
|
-
}, picked && /* @__PURE__ */ React.createElement(Icon, {
|
|
952
|
-
name: "Check",
|
|
953
|
-
size: 13
|
|
954
|
-
}), /* @__PURE__ */ React.createElement("span", null, picked ? words.chosen : words.choose)));
|
|
955
|
-
})));
|
|
1243
|
+
})))))))), more.toggle);
|
|
956
1244
|
}
|
|
957
|
-
const
|
|
1245
|
+
const { Options, FormOf, useForm } = glanceOptions(pi, { Reply, Answer, Text, Icon, has });
|
|
1246
|
+
const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "CircleArrowRight" };
|
|
958
1247
|
function Notes({ block: block2 }) {
|
|
959
1248
|
return /* @__PURE__ */ React.createElement("ul", {
|
|
960
1249
|
className: "tag-notes"
|
|
@@ -967,7 +1256,7 @@ function glanceCard(pi) {
|
|
|
967
1256
|
name: item.icon,
|
|
968
1257
|
fallback: NOTE_ICON[item.tone],
|
|
969
1258
|
size: 14
|
|
970
|
-
})), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(
|
|
1259
|
+
})), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(Clamp, {
|
|
971
1260
|
text: item.text
|
|
972
1261
|
})))));
|
|
973
1262
|
}
|
|
@@ -1027,7 +1316,8 @@ function glanceCard(pi) {
|
|
|
1027
1316
|
});
|
|
1028
1317
|
case "bars":
|
|
1029
1318
|
return /* @__PURE__ */ React.createElement(Bars, {
|
|
1030
|
-
block: block2
|
|
1319
|
+
block: block2,
|
|
1320
|
+
words
|
|
1031
1321
|
});
|
|
1032
1322
|
case "line":
|
|
1033
1323
|
return /* @__PURE__ */ React.createElement(Line, {
|
|
@@ -1049,7 +1339,8 @@ ${block2.mermaid}
|
|
|
1049
1339
|
}) : null;
|
|
1050
1340
|
case "table":
|
|
1051
1341
|
return /* @__PURE__ */ React.createElement(Table, {
|
|
1052
|
-
block: block2
|
|
1342
|
+
block: block2,
|
|
1343
|
+
words
|
|
1053
1344
|
});
|
|
1054
1345
|
case "options":
|
|
1055
1346
|
return /* @__PURE__ */ React.createElement(Options, {
|
|
@@ -1073,8 +1364,26 @@ ${block2.mermaid}
|
|
|
1073
1364
|
});
|
|
1074
1365
|
}
|
|
1075
1366
|
}
|
|
1367
|
+
function Folded({ block: block2, words, closed }) {
|
|
1368
|
+
const [open, setOpen] = React.useState(false);
|
|
1369
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1370
|
+
className: "tag-details"
|
|
1371
|
+
}, /* @__PURE__ */ React.createElement(Toggle, {
|
|
1372
|
+
open,
|
|
1373
|
+
label: block2.fold || words.details,
|
|
1374
|
+
opened: block2.fold || words.details,
|
|
1375
|
+
words,
|
|
1376
|
+
onToggle: () => setOpen(!open)
|
|
1377
|
+
}), open && /* @__PURE__ */ React.createElement("div", {
|
|
1378
|
+
className: "tag-folded-body"
|
|
1379
|
+
}, /* @__PURE__ */ React.createElement(Part, {
|
|
1380
|
+
block: block2,
|
|
1381
|
+
words,
|
|
1382
|
+
closed
|
|
1383
|
+
})));
|
|
1384
|
+
}
|
|
1076
1385
|
function Head({ card, words }) {
|
|
1077
|
-
const status = card.status && words.status[card.status];
|
|
1386
|
+
const status = card.status && showsStatus(card) ? words.status[card.status] : undefined;
|
|
1078
1387
|
if (!status && !card.title) {
|
|
1079
1388
|
return null;
|
|
1080
1389
|
}
|
|
@@ -1095,24 +1404,30 @@ ${block2.mermaid}
|
|
|
1095
1404
|
const known = "answer" in props;
|
|
1096
1405
|
const answer = React.useMemo(() => ({ known, text: props.answer }), [known, props.answer]);
|
|
1097
1406
|
const words = GlanceWords.of(pi.ui.language);
|
|
1407
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
1098
1408
|
const card = React.useMemo(() => GlanceSpec.read(GlanceJson.parse(code, !closed), !closed, words), [code, closed, words]);
|
|
1409
|
+
const form = useForm(card, words, send, props.answer);
|
|
1099
1410
|
if (!card) {
|
|
1100
1411
|
return closed ? /* @__PURE__ */ React.createElement(Markdown, {
|
|
1101
1412
|
text: `\`\`\`json
|
|
1102
1413
|
${code}
|
|
1103
1414
|
\`\`\``
|
|
1104
1415
|
}) : /* @__PURE__ */ React.createElement("div", {
|
|
1105
|
-
className: "tag-card
|
|
1106
|
-
}, /* @__PURE__ */ React.createElement(
|
|
1107
|
-
|
|
1108
|
-
|
|
1416
|
+
className: "tag-card"
|
|
1417
|
+
}, /* @__PURE__ */ React.createElement(Loading, {
|
|
1418
|
+
compact: true,
|
|
1419
|
+
label: words.writing
|
|
1420
|
+
}));
|
|
1109
1421
|
}
|
|
1110
1422
|
return /* @__PURE__ */ React.createElement(Reply.Provider, {
|
|
1111
1423
|
value: send
|
|
1112
1424
|
}, /* @__PURE__ */ React.createElement(Answer.Provider, {
|
|
1113
1425
|
value: answer
|
|
1426
|
+
}, /* @__PURE__ */ React.createElement(FormOf.Provider, {
|
|
1427
|
+
value: form
|
|
1114
1428
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
1115
1429
|
className: "tag-card",
|
|
1430
|
+
"data-status": card.status,
|
|
1116
1431
|
"data-streaming": !closed || undefined
|
|
1117
1432
|
}, /* @__PURE__ */ React.createElement(Head, {
|
|
1118
1433
|
card,
|
|
@@ -1120,12 +1435,17 @@ ${code}
|
|
|
1120
1435
|
}), card.blocks.map((block2, index) => /* @__PURE__ */ React.createElement("div", {
|
|
1121
1436
|
key: index,
|
|
1122
1437
|
className: "tag-part",
|
|
1123
|
-
"data-type": block2.type
|
|
1124
|
-
|
|
1438
|
+
"data-type": block2.type,
|
|
1439
|
+
"data-fold": block2.fold !== undefined || undefined
|
|
1440
|
+
}, block2.fold !== undefined ? /* @__PURE__ */ React.createElement(Folded, {
|
|
1441
|
+
block: block2,
|
|
1442
|
+
words,
|
|
1443
|
+
closed
|
|
1444
|
+
}) : /* @__PURE__ */ React.createElement(Part, {
|
|
1125
1445
|
block: block2,
|
|
1126
1446
|
words,
|
|
1127
1447
|
closed
|
|
1128
|
-
}))))));
|
|
1448
|
+
})))))));
|
|
1129
1449
|
};
|
|
1130
1450
|
}
|
|
1131
1451
|
|
|
@@ -1133,6 +1453,40 @@ ${code}
|
|
|
1133
1453
|
var LANGUAGE = "ta-glance";
|
|
1134
1454
|
var ALIASES = ["glance", "glance-choice"];
|
|
1135
1455
|
|
|
1456
|
+
// web-src/glance-speech.ts
|
|
1457
|
+
var GlanceSpeech;
|
|
1458
|
+
((GlanceSpeech) => {
|
|
1459
|
+
function of(card, words) {
|
|
1460
|
+
const said = [];
|
|
1461
|
+
for (const block2 of card.blocks) {
|
|
1462
|
+
if (block2.type === "options" && block2.items.length) {
|
|
1463
|
+
if (block2.question) {
|
|
1464
|
+
said.push(sentence(block2.question));
|
|
1465
|
+
}
|
|
1466
|
+
said.push(GlanceWords.format(words.spokenChoices, { labels: block2.items.map((item) => item.label).join(words.spokenJoin) }));
|
|
1467
|
+
const suggested = block2.items.find((item) => item.recommended);
|
|
1468
|
+
if (suggested) {
|
|
1469
|
+
said.push(GlanceWords.format(words.spokenRecommended, { label: suggested.label }));
|
|
1470
|
+
}
|
|
1471
|
+
} else if (block2.type === "steps") {
|
|
1472
|
+
for (const step2 of block2.items.filter((item) => item.status === "failed")) {
|
|
1473
|
+
said.push(GlanceWords.format(words.spokenFailed, { text: step2.text }));
|
|
1474
|
+
}
|
|
1475
|
+
} else if (block2.type === "notes") {
|
|
1476
|
+
for (const note2 of block2.items.filter((item) => item.tone !== "info")) {
|
|
1477
|
+
said.push(sentence(note2.text));
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
return said.length ? said.join(" ") : undefined;
|
|
1482
|
+
}
|
|
1483
|
+
GlanceSpeech.of = of;
|
|
1484
|
+
function sentence(text2) {
|
|
1485
|
+
const trimmed = text2.trim();
|
|
1486
|
+
return /[.!?。!?::]$/.test(trimmed) ? trimmed : /[\u3000-\u9fff]/.test(trimmed) ? `${trimmed}。` : `${trimmed}.`;
|
|
1487
|
+
}
|
|
1488
|
+
})(GlanceSpeech ||= {});
|
|
1489
|
+
|
|
1136
1490
|
// web-src/style.ts
|
|
1137
1491
|
var STYLE = `
|
|
1138
1492
|
/*
|
|
@@ -1175,7 +1529,6 @@ var STYLE = `
|
|
|
1175
1529
|
.tag-card button { font-family: inherit; }
|
|
1176
1530
|
.tag-part { padding: var(--tag-y) var(--tag-x); min-width: 0; }
|
|
1177
1531
|
.tag-card[data-streaming] > .tag-part:last-child { animation: ta-in 200ms var(--ta-ease, ease) both; }
|
|
1178
|
-
.tag-writing { display: flex; align-items: center; gap: 8px; padding: var(--tag-y) var(--tag-x); color: var(--ta-muted); font-size: var(--tag-small); }
|
|
1179
1532
|
.tag-inline .ta-markdown, .tag-inline .ta-markdown > p { display: inline; margin: 0; }
|
|
1180
1533
|
.tag-inline .ta-markdown :not(pre) > code { padding: 0 4px; font-size: 0.92em; }
|
|
1181
1534
|
.tag-num { font-variant-numeric: tabular-nums; }
|
|
@@ -1184,7 +1537,7 @@ var STYLE = `
|
|
|
1184
1537
|
.tag-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: var(--tag-y) var(--tag-x) 0; }
|
|
1185
1538
|
.tag-card > .tag-head + .tag-part { border-top: 0; padding-top: 8px; }
|
|
1186
1539
|
/* A table or a diagram reaches the edges: under the head it keeps the hairline, a gap above it */
|
|
1187
|
-
.tag-card > .tag-head + .tag-part:is([data-type='table'], [data-type='diagram']) { margin-top: var(--tag-y); padding-top: 0; border-top: 1px solid var(--tag-line); }
|
|
1540
|
+
.tag-card > .tag-head + .tag-part:is([data-type='table'], [data-type='diagram']):not([data-fold]) { margin-top: var(--tag-y); padding-top: 0; border-top: 1px solid var(--tag-line); }
|
|
1188
1541
|
.tag-title { flex: 1 1 14em; min-width: 0; font-weight: 600; font-size: calc(14px * var(--tag-s)); line-height: 1.45; color: var(--ta-text); }
|
|
1189
1542
|
.tag-status { --tag-tone: var(--ta-muted); flex: none; display: inline-flex; align-items: center; gap: 6px; height: calc(22px * var(--tag-s)); padding: 0 9px; border-radius: 999px; font-size: var(--tag-small); font-weight: 600; line-height: 1; white-space: nowrap; color: var(--tag-tone); background: color-mix(in srgb, var(--tag-tone) 12%, transparent); }
|
|
1190
1543
|
.tag-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
@@ -1193,6 +1546,8 @@ var STYLE = `
|
|
|
1193
1546
|
/* Needs you: the blue of what waits for the user, as the ? of the list of chats. */
|
|
1194
1547
|
.tag-status[data-status='blocked'] { --tag-tone: var(--ta-blue); }
|
|
1195
1548
|
.tag-status[data-status='failed'] { --tag-tone: var(--ta-red); }
|
|
1549
|
+
/* Done without a title has no row of its own: a green edge at the top of the card says it */
|
|
1550
|
+
.tag-card[data-status='done']:not(:has(> .tag-head))::before { content: ''; position: absolute; z-index: 1; inset: 0 0 auto; height: 2px; background: var(--ta-green); pointer-events: none; }
|
|
1196
1551
|
|
|
1197
1552
|
/* What a part is about, in small muted type above it */
|
|
1198
1553
|
.tag-section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
|
|
@@ -1215,8 +1570,15 @@ var STYLE = `
|
|
|
1215
1570
|
.tag-stat { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--ta-raised); }
|
|
1216
1571
|
.tag-stat-value { font-size: calc(20px * var(--tag-s)); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ta-text); }
|
|
1217
1572
|
@container tag-card (max-width: 400px) { .tag-stat-value { font-size: calc(18px * var(--tag-s)); } }
|
|
1573
|
+
/* A value in words (Included) is not a number to read from afar: body size, on the line of the numbers beside it */
|
|
1574
|
+
.tag-stat[data-words] > .tag-stat-value { font-size: calc(15px * var(--tag-s)); line-height: calc(25px * var(--tag-s)); letter-spacing: 0; }
|
|
1575
|
+
@container tag-card (max-width: 400px) { .tag-stat[data-words] > .tag-stat-value { font-size: calc(14px * var(--tag-s)); line-height: calc(22.5px * var(--tag-s)); } }
|
|
1218
1576
|
/* Its icon, name and change wrap as wholes, so that a narrow box does not break the name */
|
|
1219
1577
|
.tag-stat-label { display: flex; flex-wrap: wrap; align-items: center; margin-top: 2px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
|
|
1578
|
+
/* Without a change, the name wraps beside its dot or icon, which stay on its first line, rather than under them */
|
|
1579
|
+
.tag-stat-label:not(:has(> .tag-delta)) { flex-wrap: nowrap; align-items: flex-start; }
|
|
1580
|
+
.tag-stat-label:not(:has(> .tag-delta)) > .tag-tone-dot { flex: none; margin-top: calc((1.4em - 6px) / 2); }
|
|
1581
|
+
.tag-stat-label:not(:has(> .tag-delta)) > .tag-item-icon { margin-top: calc((1.4em - 12px * var(--tag-s)) / 2); }
|
|
1220
1582
|
/* The icon an item names: before its label, in the color of its tone where it has one */
|
|
1221
1583
|
.tag-item-icon { flex: none; display: inline-flex; color: var(--ta-secondary); }
|
|
1222
1584
|
.tag-item-icon svg { width: calc(var(--tag-icon, 13px) * var(--tag-s)); height: calc(var(--tag-icon, 13px) * var(--tag-s)); }
|
|
@@ -1370,6 +1732,23 @@ var STYLE = `
|
|
|
1370
1732
|
.tag-card .tag-table th:first-child, .tag-card .tag-table td:first-child { padding-left: var(--tag-x); }
|
|
1371
1733
|
.tag-card .tag-table th:last-child, .tag-card .tag-table td:last-child { padding-right: var(--tag-x); }
|
|
1372
1734
|
.tag-card .tag-table th { font-size: var(--tag-small); color: var(--ta-secondary); }
|
|
1735
|
+
/* Two columns: the names keep to what they hold, close to their values; the values take the rest and wrap */
|
|
1736
|
+
.tag-card .tag-table [data-columns='2'] th:last-child { width: 100%; }
|
|
1737
|
+
.tag-card .tag-table td:last-child:not(:first-child) { min-width: 8em; white-space: normal; }
|
|
1738
|
+
/* More: every column but the names wraps, the table sharing the width out by what each holds */
|
|
1739
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) td:not(:first-child) { min-width: 7em; white-space: normal; }
|
|
1740
|
+
/* More, in a narrow card: a row is a block, its name on top, each value under the name of its column; no table to scroll sideways */
|
|
1741
|
+
@container tag-card (max-width: 520px) {
|
|
1742
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) { display: block; }
|
|
1743
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) thead { display: none; }
|
|
1744
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) :is(tbody, tr) { display: block; }
|
|
1745
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) tr { padding: var(--tag-y) var(--tag-x); border-bottom: 1px solid var(--tag-line); }
|
|
1746
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) tr:last-child { border-bottom: 0; }
|
|
1747
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) td:nth-child(n) { display: block; min-width: 0; padding: 0; border: 0; white-space: normal; }
|
|
1748
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) td:first-child { font-weight: 600; }
|
|
1749
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) td + td { margin-top: 6px; color: var(--ta-body); }
|
|
1750
|
+
.tag-card .tag-table table:not([data-columns='1'], [data-columns='2']) td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; margin-bottom: 1px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
|
|
1751
|
+
}
|
|
1373
1752
|
.tag-card .ta-mermaid { margin: 0; border: 0; border-radius: 0; background: transparent; }
|
|
1374
1753
|
.tag-card .ta-mermaid .ta-code-bar { padding-left: var(--tag-x); padding-right: calc(var(--tag-x) - 4px); }
|
|
1375
1754
|
.tag-card .ta-markdown:has(> .ta-mermaid) { margin: 0; }
|
|
@@ -1395,12 +1774,43 @@ var STYLE = `
|
|
|
1395
1774
|
.tag-points span[data-tone='good']::before { content: '+'; color: var(--ta-green); }
|
|
1396
1775
|
.tag-points span[data-tone='bad']::before { content: '−'; color: var(--ta-red); }
|
|
1397
1776
|
.tag-choose { flex: none; display: inline-flex; align-items: center; gap: 4px; }
|
|
1777
|
+
/*
|
|
1778
|
+
* Choices of a form (several questions, or one of several answers): plain rows with a mark, as a list of settings,
|
|
1779
|
+
* not a box and a button each; picked is a filled mark, nothing else changes. One button under the last question.
|
|
1780
|
+
*/
|
|
1781
|
+
.tag-question:has(.tag-several) { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
|
|
1782
|
+
.tag-several { font-weight: 400; font-size: var(--tag-small); color: var(--ta-muted); }
|
|
1783
|
+
.tag-picks { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--tag-x) + 4px); }
|
|
1784
|
+
.tag-pick { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 7px calc(var(--tag-x) - 4px); border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background 120ms, opacity 0.2s; }
|
|
1785
|
+
.tag-pick:hover:not(:disabled) { background: var(--ta-hover); }
|
|
1786
|
+
.tag-pick:disabled { cursor: default; }
|
|
1787
|
+
.tag-pick[data-other] { opacity: 0.5; }
|
|
1788
|
+
.tag-pick .tag-option-label { font-weight: 500; }
|
|
1789
|
+
.tag-pick-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: calc(16px * var(--tag-s)); height: calc(16px * var(--tag-s)); margin-top: calc((var(--tag-lh) - 16px * var(--tag-s)) / 2); border: 1.5px solid var(--ta-border); border-radius: 50%; color: var(--ta-card); transition: background 120ms, border-color 120ms; }
|
|
1790
|
+
.tag-pick[data-multi] .tag-pick-mark { border-radius: 4px; }
|
|
1791
|
+
.tag-pick[aria-pressed='true'] .tag-pick-mark { border-color: var(--ta-green); background: var(--ta-green); }
|
|
1792
|
+
.tag-pick:not([data-multi])[aria-pressed='true'] .tag-pick-mark > svg { display: none; }
|
|
1793
|
+
.tag-pick:not([data-multi])[aria-pressed='true'] .tag-pick-mark::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ta-card); }
|
|
1794
|
+
.tag-submit { display: flex; justify-content: flex-end; margin-top: 8px; }
|
|
1795
|
+
.tag-submit > .ta-button { min-width: 76px; }
|
|
1398
1796
|
@container tag-card (max-width: 400px) {
|
|
1399
1797
|
.tag-option { flex-direction: column; align-items: stretch; gap: 10px; }
|
|
1400
1798
|
.tag-choose { width: 100%; }
|
|
1401
1799
|
}
|
|
1402
1800
|
|
|
1403
1801
|
/* Risks, notes, what to do */
|
|
1802
|
+
/*
|
|
1803
|
+
* A text of a row: two lines at most, a tap shows the rest. Rows are a glance; what takes more goes in details.
|
|
1804
|
+
*/
|
|
1805
|
+
.tag-clamp:not([data-open]) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
|
|
1806
|
+
.tag-clamp[data-cut] { cursor: pointer; }
|
|
1807
|
+
.tag-clamp[data-open] { display: block; }
|
|
1808
|
+
/* Checks that all passed: one line of them, a green tick, the name muted and the number beside it */
|
|
1809
|
+
.tag-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--tag-small); line-height: 1.5; }
|
|
1810
|
+
.tag-check { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
|
|
1811
|
+
.tag-check svg { flex: none; width: calc(12px * var(--tag-s)); height: calc(12px * var(--tag-s)); color: var(--ta-green); stroke-width: 2.5; }
|
|
1812
|
+
.tag-check-label { color: var(--ta-muted); }
|
|
1813
|
+
.tag-check > b { font-weight: 600; color: var(--ta-text); font-variant-numeric: tabular-nums; }
|
|
1404
1814
|
.tag-notes li { display: flex; gap: 8px; }
|
|
1405
1815
|
.tag-notes li > span:last-child { flex: 1; min-width: 0; }
|
|
1406
1816
|
.tag-note-mark { display: inline-grid; place-items: center; color: var(--ta-muted); }
|
|
@@ -1415,8 +1825,14 @@ var STYLE = `
|
|
|
1415
1825
|
.tag-chip:disabled { opacity: 0.5; cursor: default; }
|
|
1416
1826
|
.tag-part[data-type='next'] { padding-top: calc(var(--tag-y) - 2px); padding-bottom: calc(var(--tag-y) - 2px); }
|
|
1417
1827
|
|
|
1418
|
-
/* Details, folded */
|
|
1419
|
-
.tag-part[data-type='details'] { padding
|
|
1828
|
+
/* Details, folded; a block the model folded, under its words; the rest of a long list */
|
|
1829
|
+
.tag-part[data-type='details'], .tag-card > .tag-part[data-fold] { padding: 8px var(--tag-x); }
|
|
1830
|
+
.tag-folded-body { margin-top: 6px; padding-bottom: 4px; animation: ta-in 180ms var(--ta-ease, ease); }
|
|
1831
|
+
/* A table or a diagram opened in a fold still reaches the edges of the card */
|
|
1832
|
+
.tag-folded-body > :is(div, .ta-markdown):has(> .tag-table, > .ta-mermaid) { margin: 0 calc(-1 * var(--tag-x)) -12px; }
|
|
1833
|
+
.tag-folded-body .tag-table { border-top: 1px solid var(--tag-line); }
|
|
1834
|
+
.tag-more { margin-top: 4px; }
|
|
1835
|
+
.tag-table + .tag-more { padding: 4px var(--tag-x) 6px; border-top: 1px solid var(--tag-line); margin-top: 0; }
|
|
1420
1836
|
.tag-details-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: calc(24px * var(--tag-s)); margin-left: -4px; padding: 0 6px 0 4px; border: 0; border-radius: 6px; background: none; color: var(--ta-muted); font-size: var(--tag-small); cursor: pointer; transition: color 120ms, background 120ms; }
|
|
1421
1837
|
.tag-details-toggle svg { width: calc(14px * var(--tag-s)); height: calc(14px * var(--tag-s)); transition: transform 150ms var(--ta-ease, ease); }
|
|
1422
1838
|
.tag-details-toggle[aria-expanded='true'] svg { transform: rotate(90deg); }
|
|
@@ -1430,7 +1846,8 @@ var STYLE = `
|
|
|
1430
1846
|
|
|
1431
1847
|
/* Touch: what is tapped is a finger high */
|
|
1432
1848
|
[data-touch] .tag-chip { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
|
|
1433
|
-
[data-touch] .tag-choose { height: 36px; }
|
|
1849
|
+
[data-touch] .tag-choose, [data-touch] .tag-submit > .ta-button { height: 36px; }
|
|
1850
|
+
[data-touch] .tag-pick { padding-top: 9px; padding-bottom: 9px; }
|
|
1434
1851
|
[data-touch] .tag-details-toggle { min-height: 32px; }
|
|
1435
1852
|
`;
|
|
1436
1853
|
function injectStyle() {
|
|
@@ -1451,8 +1868,13 @@ function activate(pi) {
|
|
|
1451
1868
|
}
|
|
1452
1869
|
const removeStyle = injectStyle();
|
|
1453
1870
|
const card = glanceCard(pi);
|
|
1871
|
+
const spoken = (code) => {
|
|
1872
|
+
const words = GlanceWords.of(pi.ui.language);
|
|
1873
|
+
const glance = GlanceSpec.read(GlanceJson.parse(code, false), false, words);
|
|
1874
|
+
return glance && GlanceSpeech.of(glance, words);
|
|
1875
|
+
};
|
|
1454
1876
|
for (const language of [LANGUAGE, ...ALIASES]) {
|
|
1455
|
-
pi.registerCodeRenderer(language, card);
|
|
1877
|
+
pi.registerCodeRenderer(language, card, { spoken });
|
|
1456
1878
|
}
|
|
1457
1879
|
return removeStyle;
|
|
1458
1880
|
}
|