@celljs/ta-glance 4.17.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 +18 -12
- package/package.json +3 -3
- package/web/index.js +717 -445
package/web/index.js
CHANGED
|
@@ -1,3 +1,539 @@
|
|
|
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) => {
|
|
@@ -94,9 +630,14 @@ var BLOCKS = 8;
|
|
|
94
630
|
var TEXT = 400;
|
|
95
631
|
var MARKDOWN = 8000;
|
|
96
632
|
var STATUSES = ["done", "partial", "failed", "blocked", "info"];
|
|
633
|
+
var QUIET = ["done", "info"];
|
|
97
634
|
var TONES = ["good", "bad", "warn", "neutral"];
|
|
98
635
|
var STEPS = ["done", "doing", "todo", "failed", "skipped"];
|
|
99
|
-
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
|
+
}
|
|
100
641
|
function object(value) {
|
|
101
642
|
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
102
643
|
}
|
|
@@ -251,7 +792,7 @@ function blockOf(item, partial, labels) {
|
|
|
251
792
|
switch (type) {
|
|
252
793
|
case "stats": {
|
|
253
794
|
const list = items(value?.items, stat).slice(0, 6);
|
|
254
|
-
return list.length ? { type, items: list } : undefined;
|
|
795
|
+
return list.length ? { type, items: list, ...passed(list, CHECKS) ? { checks: true } : {} } : undefined;
|
|
255
796
|
}
|
|
256
797
|
case "changes": {
|
|
257
798
|
const raw = Array.isArray(value?.items) ? value.items : [];
|
|
@@ -293,9 +834,9 @@ function blockOf(item, partial, labels) {
|
|
|
293
834
|
return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
|
|
294
835
|
}
|
|
295
836
|
case "line": {
|
|
296
|
-
const
|
|
297
|
-
const lines =
|
|
298
|
-
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);
|
|
299
840
|
const better = oneOf(value?.better, ["lower", "higher"]);
|
|
300
841
|
const drawn = lines.filter((line) => partial || line.values.length > 1);
|
|
301
842
|
return drawn.length ? { type, labels: labels2, series: drawn, ...unit ? { unit } : {}, ...better ? { better } : {} } : undefined;
|
|
@@ -320,233 +861,66 @@ function blockOf(item, partial, labels) {
|
|
|
320
861
|
case "options": {
|
|
321
862
|
const list = items(value?.items, option).slice(0, 5);
|
|
322
863
|
const question = text(value?.question);
|
|
323
|
-
return list.length ? { type, items: list, ...question ? { question } : {} } : undefined;
|
|
864
|
+
return list.length ? { type, items: list, ...question ? { question } : {}, ...value?.multi === true ? { multi: true } : {} } : undefined;
|
|
324
865
|
}
|
|
325
866
|
case "notes": {
|
|
326
|
-
const list = items(value?.items, note);
|
|
867
|
+
const list = items(value?.items, note).sort((a, b) => NOTES.indexOf(a.tone) - NOTES.indexOf(b.tone));
|
|
327
868
|
return list.length ? { type, items: list } : undefined;
|
|
328
869
|
}
|
|
329
870
|
case "next": {
|
|
330
871
|
const list = items(value?.items, listItem).slice(0, 3);
|
|
331
|
-
return list.length ? { type, items: list } : undefined;
|
|
332
|
-
}
|
|
333
|
-
case "details": {
|
|
334
|
-
const markdown = text(value?.markdown, MARKDOWN);
|
|
335
|
-
const title = text(value?.title);
|
|
336
|
-
return markdown ? { type, markdown, ...title ? { title } : {} } : undefined;
|
|
337
|
-
}
|
|
338
|
-
default:
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
function loose(card) {
|
|
343
|
-
const out = [];
|
|
344
|
-
for (const [key, entries] of Object.entries(card)) {
|
|
345
|
-
const type = key === "files" ? "changes" : key;
|
|
346
|
-
if (Array.isArray(entries) && LISTS.includes(type)) {
|
|
347
|
-
out.push({ type, items: entries, ...type === "options" ? { question: card.question } : {} });
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return out;
|
|
351
|
-
}
|
|
352
|
-
var LISTS = ["stats", "changes", "steps", "flow", "options", "notes", "next"];
|
|
353
|
-
var PLACE = { stats: -1, notes: 1, next: 2, details: 3 };
|
|
354
|
-
function place(block2) {
|
|
355
|
-
return block2.fold !== undefined ? 3 : PLACE[block2.type] ?? 0;
|
|
356
|
-
}
|
|
357
|
-
function placed(blocks) {
|
|
358
|
-
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);
|
|
359
|
-
}
|
|
360
|
-
var GlanceSpec;
|
|
361
|
-
((GlanceSpec) => {
|
|
362
|
-
function read(value, partial = false, labels = LABELS) {
|
|
363
|
-
const card = object(value);
|
|
364
|
-
if (!card) {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
const status = oneOf(card.status, STATUSES);
|
|
368
|
-
const title = text(card.title);
|
|
369
|
-
const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS));
|
|
370
|
-
if (!blocks.length && !title) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
return { blocks, ...status ? { status } : {}, ...title ? { title } : {} };
|
|
374
|
-
}
|
|
375
|
-
GlanceSpec.read = read;
|
|
376
|
-
})(GlanceSpec ||= {});
|
|
377
|
-
|
|
378
|
-
// web-src/glance-util.ts
|
|
379
|
-
function percent(before, after) {
|
|
380
|
-
if (!before) {
|
|
381
|
-
return "";
|
|
382
|
-
}
|
|
383
|
-
const change2 = Math.round((after - before) / Math.abs(before) * 100);
|
|
384
|
-
return `${change2 > 0 ? "+" : ""}${change2}%`;
|
|
385
|
-
}
|
|
386
|
-
function range(values) {
|
|
387
|
-
const low = Math.min(...values);
|
|
388
|
-
const high = Math.max(...values);
|
|
389
|
-
if (!values.length) {
|
|
390
|
-
return { low: 0, high: 1 };
|
|
391
|
-
}
|
|
392
|
-
if (low === high) {
|
|
393
|
-
return { low: low - 1, high: high + 1 };
|
|
394
|
-
}
|
|
395
|
-
const margin = (high - low) * 0.08;
|
|
396
|
-
return { low: low - margin, high: high + margin };
|
|
397
|
-
}
|
|
398
|
-
function points(values, count, { low, high }, width, height) {
|
|
399
|
-
const step2 = count > 1 ? width / (count - 1) : 0;
|
|
400
|
-
return values.map((value, index) => [count > 1 ? index * step2 : width / 2, height - (value - low) / (high - low) * height]);
|
|
401
|
-
}
|
|
402
|
-
function share(part, total) {
|
|
403
|
-
const value = total > 0 ? part / total * 100 : 0;
|
|
404
|
-
return value > 0 && value < 1 ? "<1%" : `${Math.round(value)}%`;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// ../ta-protocol/esm/common/language.js
|
|
408
|
-
var TaLanguageUtil;
|
|
409
|
-
(function(TaLanguageUtil2) {
|
|
410
|
-
TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
|
|
411
|
-
TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
|
|
412
|
-
function of(tag) {
|
|
413
|
-
const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
|
|
414
|
-
if (/^zh(\b|-)/.test(said)) {
|
|
415
|
-
return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
|
|
416
|
-
}
|
|
417
|
-
return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
|
|
418
|
-
}
|
|
419
|
-
TaLanguageUtil2.of = of;
|
|
420
|
-
function server(env = typeof process === "undefined" ? {} : process.env) {
|
|
421
|
-
return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
|
|
422
|
-
}
|
|
423
|
-
TaLanguageUtil2.server = server;
|
|
424
|
-
function pick(language, words) {
|
|
425
|
-
return words[of(language)];
|
|
426
|
-
}
|
|
427
|
-
TaLanguageUtil2.pick = pick;
|
|
428
|
-
function say(words) {
|
|
429
|
-
return words[server()];
|
|
430
|
-
}
|
|
431
|
-
TaLanguageUtil2.say = say;
|
|
432
|
-
function chinese(language) {
|
|
433
|
-
return of(language).startsWith("zh");
|
|
434
|
-
}
|
|
435
|
-
TaLanguageUtil2.chinese = chinese;
|
|
436
|
-
function cjk(language) {
|
|
437
|
-
return of(language) !== "en-US";
|
|
438
|
-
}
|
|
439
|
-
TaLanguageUtil2.cjk = cjk;
|
|
440
|
-
function list(language, items2) {
|
|
441
|
-
return items2.join(cjk(language) ? "、" : ", ");
|
|
442
|
-
}
|
|
443
|
-
TaLanguageUtil2.list = list;
|
|
444
|
-
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
445
|
-
|
|
446
|
-
// web-src/i18n.ts
|
|
447
|
-
var EN = {
|
|
448
|
-
status: { done: "Done", partial: "Partly done", failed: "Failed", blocked: "Needs you", info: "" },
|
|
449
|
-
before: "Before",
|
|
450
|
-
after: "After",
|
|
451
|
-
recommended: "Recommended",
|
|
452
|
-
choose: "Choose",
|
|
453
|
-
chosen: "Chosen",
|
|
454
|
-
pick: "I choose: {label}",
|
|
455
|
-
details: "Details",
|
|
456
|
-
hide: "Hide",
|
|
457
|
-
more: "{count} more",
|
|
458
|
-
files: "{count} files",
|
|
459
|
-
writing: "Drawing the summary…",
|
|
460
|
-
spokenChoices: "You can choose: {labels}.",
|
|
461
|
-
spokenRecommended: "I suggest {label}.",
|
|
462
|
-
spokenFailed: "{text}: failed.",
|
|
463
|
-
spokenJoin: ", "
|
|
464
|
-
};
|
|
465
|
-
var ZH = {
|
|
466
|
-
status: { done: "已完成", partial: "部分完成", failed: "失败", blocked: "需要你", info: "" },
|
|
467
|
-
before: "之前",
|
|
468
|
-
after: "之后",
|
|
469
|
-
recommended: "推荐",
|
|
470
|
-
choose: "选这个",
|
|
471
|
-
chosen: "已选",
|
|
472
|
-
pick: "我选:{label}",
|
|
473
|
-
details: "详情",
|
|
474
|
-
hide: "收起",
|
|
475
|
-
more: "还有 {count} 项",
|
|
476
|
-
files: "{count} 个文件",
|
|
477
|
-
writing: "正在整理摘要…",
|
|
478
|
-
spokenChoices: "可以选:{labels}。",
|
|
479
|
-
spokenRecommended: "推荐{label}。",
|
|
480
|
-
spokenFailed: "{text}失败了。",
|
|
481
|
-
spokenJoin: "、"
|
|
482
|
-
};
|
|
483
|
-
var ZH_TW = {
|
|
484
|
-
status: { done: "已完成", partial: "部分完成", failed: "失敗", blocked: "需要你", info: "" },
|
|
485
|
-
before: "之前",
|
|
486
|
-
after: "之後",
|
|
487
|
-
recommended: "推薦",
|
|
488
|
-
choose: "選這個",
|
|
489
|
-
chosen: "已選",
|
|
490
|
-
pick: "我選:{label}",
|
|
491
|
-
details: "詳情",
|
|
492
|
-
hide: "收起",
|
|
493
|
-
more: "還有 {count} 項",
|
|
494
|
-
files: "{count} 個檔案",
|
|
495
|
-
writing: "正在整理摘要…",
|
|
496
|
-
spokenChoices: "可以選:{labels}。",
|
|
497
|
-
spokenRecommended: "推薦{label}。",
|
|
498
|
-
spokenFailed: "{text}失敗了。",
|
|
499
|
-
spokenJoin: "、"
|
|
500
|
-
};
|
|
501
|
-
var JA = {
|
|
502
|
-
status: { done: "完了", partial: "部分完了", failed: "失敗", blocked: "要対応", info: "" },
|
|
503
|
-
before: "前",
|
|
504
|
-
after: "後",
|
|
505
|
-
recommended: "オススメ",
|
|
506
|
-
choose: "これを選ぶ",
|
|
507
|
-
chosen: "選択済み",
|
|
508
|
-
pick: "私が選んだ:{label}",
|
|
509
|
-
details: "詳細",
|
|
510
|
-
hide: "隠す",
|
|
511
|
-
more: "ほか {count} 件",
|
|
512
|
-
files: "{count} 個のファイル",
|
|
513
|
-
writing: "サマリーを作成中…",
|
|
514
|
-
spokenChoices: "選択肢:{labels}。",
|
|
515
|
-
spokenRecommended: "オススメは{label}です。",
|
|
516
|
-
spokenFailed: "{text}は失敗しました。",
|
|
517
|
-
spokenJoin: "、"
|
|
518
|
-
};
|
|
519
|
-
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
520
|
-
var GlanceWords;
|
|
521
|
-
((GlanceWords) => {
|
|
522
|
-
function of(language) {
|
|
523
|
-
return TaLanguageUtil.pick(language, WORDS);
|
|
524
|
-
}
|
|
525
|
-
GlanceWords.of = of;
|
|
526
|
-
function picked(answer, labels) {
|
|
527
|
-
const said = answer.trim();
|
|
528
|
-
return labels.find((label) => said === label || said === format(EN.pick, { label }) || said === format(ZH.pick, { label }));
|
|
872
|
+
return list.length ? { type, items: list } : undefined;
|
|
873
|
+
}
|
|
874
|
+
case "details": {
|
|
875
|
+
const markdown = text(value?.markdown, MARKDOWN);
|
|
876
|
+
const title = text(value?.title);
|
|
877
|
+
return markdown ? { type, markdown, ...title ? { title } : {} } : undefined;
|
|
878
|
+
}
|
|
879
|
+
default:
|
|
880
|
+
return;
|
|
529
881
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
882
|
+
}
|
|
883
|
+
function loose(card) {
|
|
884
|
+
const out = [];
|
|
885
|
+
for (const [key, entries] of Object.entries(card)) {
|
|
886
|
+
const type = key === "files" ? "changes" : key;
|
|
887
|
+
if (Array.isArray(entries) && LISTS.includes(type)) {
|
|
888
|
+
out.push({ type, items: entries, ...type === "options" ? { question: card.question } : {} });
|
|
889
|
+
}
|
|
533
890
|
}
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
891
|
+
return out;
|
|
892
|
+
}
|
|
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);
|
|
541
900
|
}
|
|
901
|
+
var GlanceSpec;
|
|
902
|
+
((GlanceSpec) => {
|
|
903
|
+
function read(value, partial = false, labels = LABELS) {
|
|
904
|
+
const card = object(value);
|
|
905
|
+
if (!card) {
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
const status = oneOf(card.status, STATUSES);
|
|
909
|
+
const title = text(card.title);
|
|
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);
|
|
911
|
+
if (!blocks.length && !title) {
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
return { blocks, ...status ? { status } : {}, ...title ? { title } : {} };
|
|
915
|
+
}
|
|
916
|
+
GlanceSpec.read = read;
|
|
917
|
+
})(GlanceSpec ||= {});
|
|
542
918
|
|
|
543
919
|
// web-src/card.tsx
|
|
544
920
|
var MARKS = /[*_`[\]$\\]/;
|
|
545
921
|
var SQUARES = 5;
|
|
546
922
|
var LINES = 20;
|
|
547
|
-
var SHOWN = { changes: 5, rows:
|
|
548
|
-
var WIDTH = 300;
|
|
549
|
-
var HEIGHT = 100;
|
|
923
|
+
var SHOWN = { changes: 5, rows: 4, bars: 6 };
|
|
550
924
|
function fileName(path) {
|
|
551
925
|
return path.replace(/\/+$/, "").split("/").pop() || path;
|
|
552
926
|
}
|
|
@@ -554,9 +928,6 @@ function directory(path) {
|
|
|
554
928
|
const trimmed = path.replace(/\/+$/, "");
|
|
555
929
|
return trimmed.slice(0, Math.max(0, trimmed.lastIndexOf("/")));
|
|
556
930
|
}
|
|
557
|
-
function count(value) {
|
|
558
|
-
return Math.abs(value) >= 1000 ? value.toLocaleString() : String(Number(value.toFixed(2)));
|
|
559
|
-
}
|
|
560
931
|
function glanceCard(pi) {
|
|
561
932
|
const icons = pi.ui.icons;
|
|
562
933
|
const Markdown = pi.ui.Markdown;
|
|
@@ -569,6 +940,38 @@ function glanceCard(pi) {
|
|
|
569
940
|
text: text2
|
|
570
941
|
})) : text2;
|
|
571
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
|
+
}
|
|
572
975
|
function Icon({ name, fallback, size = 14 }) {
|
|
573
976
|
const Found = name && icons[name] || fallback && icons[fallback];
|
|
574
977
|
return Found ? /* @__PURE__ */ React.createElement(Found, {
|
|
@@ -605,137 +1008,25 @@ function glanceCard(pi) {
|
|
|
605
1008
|
};
|
|
606
1009
|
}
|
|
607
1010
|
const has = (name) => !!name && !!icons[name];
|
|
608
|
-
|
|
609
|
-
values,
|
|
610
|
-
count: count2,
|
|
611
|
-
scale,
|
|
612
|
-
area,
|
|
613
|
-
index
|
|
614
|
-
}) {
|
|
615
|
-
const at = points(values, count2, scale, WIDTH, HEIGHT);
|
|
616
|
-
const line = at.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
|
|
617
|
-
const last = at[at.length - 1];
|
|
618
|
-
return /* @__PURE__ */ React.createElement("g", {
|
|
619
|
-
className: "tag-series",
|
|
620
|
-
"data-index": index
|
|
621
|
-
}, area && at.length > 1 && /* @__PURE__ */ React.createElement("polygon", {
|
|
622
|
-
className: "tag-series-area",
|
|
623
|
-
points: `0,${HEIGHT} ${line} ${last[0].toFixed(1)},${HEIGHT}`
|
|
624
|
-
}), /* @__PURE__ */ React.createElement("polyline", {
|
|
625
|
-
points: line,
|
|
626
|
-
fill: "none",
|
|
627
|
-
vectorEffect: "non-scaling-stroke"
|
|
628
|
-
}));
|
|
629
|
-
}
|
|
630
|
-
function Sparkline({ values }) {
|
|
631
|
-
return /* @__PURE__ */ React.createElement("svg", {
|
|
632
|
-
className: "tag-spark",
|
|
633
|
-
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
634
|
-
preserveAspectRatio: "none",
|
|
635
|
-
"aria-hidden": "true"
|
|
636
|
-
}, /* @__PURE__ */ React.createElement(Polyline, {
|
|
637
|
-
values,
|
|
638
|
-
count: values.length,
|
|
639
|
-
scale: range(values),
|
|
640
|
-
area: true,
|
|
641
|
-
index: 0
|
|
642
|
-
}));
|
|
643
|
-
}
|
|
644
|
-
function Line({ block: block2 }) {
|
|
645
|
-
const size = Math.max(block2.labels.length, ...block2.series.map((line) => line.values.length));
|
|
646
|
-
const scale = range(block2.series.flatMap((line) => line.values));
|
|
647
|
-
const unit = block2.unit ? ` ${block2.unit}` : "";
|
|
648
|
-
const marks = [...new Set(size >= 5 ? [0, Math.round((size - 1) / 2), size - 1] : [0, size - 1])].filter((index) => block2.labels[index] !== undefined);
|
|
649
|
-
const where = (index) => size > 1 ? index / (size - 1) * 100 : 50;
|
|
650
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
651
|
-
className: "tag-line"
|
|
652
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
653
|
-
className: "tag-section-head tag-legend"
|
|
654
|
-
}, block2.series.map((line, index) => {
|
|
655
|
-
const first = line.values[0];
|
|
656
|
-
const last = line.values[line.values.length - 1];
|
|
657
|
-
const change2 = line.values.length > 1 ? percent(first, last) : "";
|
|
658
|
-
const better = block2.better === "higher" ? last > first : last < first;
|
|
659
|
-
const tone = !block2.better || last === first ? "neutral" : better ? "good" : "bad";
|
|
660
|
-
return /* @__PURE__ */ React.createElement("span", {
|
|
661
|
-
key: index,
|
|
662
|
-
className: "tag-line-key",
|
|
663
|
-
"data-index": index
|
|
664
|
-
}, /* @__PURE__ */ React.createElement("i", null), line.label && /* @__PURE__ */ React.createElement(Text, {
|
|
665
|
-
text: line.label
|
|
666
|
-
}), /* @__PURE__ */ React.createElement("b", null, count(last), unit), change2 && /* @__PURE__ */ React.createElement("span", {
|
|
667
|
-
className: "tag-delta",
|
|
668
|
-
"data-tone": tone
|
|
669
|
-
}, change2));
|
|
670
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
671
|
-
className: "tag-plot"
|
|
672
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
673
|
-
className: "tag-plot-area"
|
|
674
|
-
}, /* @__PURE__ */ React.createElement("svg", {
|
|
675
|
-
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
676
|
-
preserveAspectRatio: "none",
|
|
677
|
-
"aria-hidden": "true"
|
|
678
|
-
}, [0, HEIGHT / 2, HEIGHT].map((y) => /* @__PURE__ */ React.createElement("line", {
|
|
679
|
-
key: y,
|
|
680
|
-
className: "tag-grid",
|
|
681
|
-
x1: 0,
|
|
682
|
-
x2: WIDTH,
|
|
683
|
-
y1: y,
|
|
684
|
-
y2: y,
|
|
685
|
-
vectorEffect: "non-scaling-stroke"
|
|
686
|
-
})), block2.series.map((line, index) => /* @__PURE__ */ React.createElement(Polyline, {
|
|
687
|
-
key: index,
|
|
688
|
-
values: line.values,
|
|
689
|
-
count: size,
|
|
690
|
-
scale,
|
|
691
|
-
area: index === 0 && block2.series.length === 1,
|
|
692
|
-
index
|
|
693
|
-
}))), block2.series.map((line, index) => {
|
|
694
|
-
const [x, y] = points(line.values, size, scale, WIDTH, HEIGHT)[line.values.length - 1];
|
|
695
|
-
return /* @__PURE__ */ React.createElement("i", {
|
|
696
|
-
key: index,
|
|
697
|
-
className: "tag-plot-dot",
|
|
698
|
-
"data-index": index,
|
|
699
|
-
style: { left: `${x / WIDTH * 100}%`, top: `${y / HEIGHT * 100}%` }
|
|
700
|
-
});
|
|
701
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
702
|
-
className: "tag-plot-axis",
|
|
703
|
-
"aria-hidden": "true"
|
|
704
|
-
}, /* @__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", {
|
|
705
|
-
className: "tag-plot-labels"
|
|
706
|
-
}, marks.map((index) => /* @__PURE__ */ React.createElement("span", {
|
|
707
|
-
key: index,
|
|
708
|
-
"data-at": index === 0 ? "start" : index === size - 1 ? "end" : "middle",
|
|
709
|
-
style: { left: `${where(index)}%` }
|
|
710
|
-
}, block2.labels[index])))));
|
|
711
|
-
}
|
|
712
|
-
function Share({ block: block2 }) {
|
|
713
|
-
const total = block2.items.reduce((sum, item) => sum + item.value, 0);
|
|
714
|
-
const unit = block2.unit ? ` ${block2.unit}` : "";
|
|
715
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
716
|
-
className: "tag-share"
|
|
717
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
718
|
-
className: "tag-share-bar",
|
|
719
|
-
"aria-hidden": "true"
|
|
720
|
-
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("i", {
|
|
721
|
-
key: index,
|
|
722
|
-
"data-index": index,
|
|
723
|
-
style: { flexGrow: item.value }
|
|
724
|
-
}))), /* @__PURE__ */ React.createElement("div", {
|
|
725
|
-
className: "tag-share-keys"
|
|
726
|
-
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
727
|
-
key: index,
|
|
728
|
-
className: "tag-share-key",
|
|
729
|
-
"data-index": index
|
|
730
|
-
}, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", {
|
|
731
|
-
className: "tag-share-label"
|
|
732
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
733
|
-
text: item.label
|
|
734
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
735
|
-
className: "tag-share-value"
|
|
736
|
-
}, count(item.value), unit), /* @__PURE__ */ React.createElement("b", null, share(item.value, total))))));
|
|
737
|
-
}
|
|
1011
|
+
const { Sparkline, Line, Share } = glanceCharts({ Text });
|
|
738
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
|
+
}
|
|
739
1030
|
return /* @__PURE__ */ React.createElement("div", {
|
|
740
1031
|
className: "tag-stats",
|
|
741
1032
|
"data-count": block2.items.length
|
|
@@ -743,7 +1034,7 @@ function glanceCard(pi) {
|
|
|
743
1034
|
key: index,
|
|
744
1035
|
className: "tag-stat",
|
|
745
1036
|
"data-tone": item.tone,
|
|
746
|
-
"data-words":
|
|
1037
|
+
"data-words": wordy(item.value) || undefined
|
|
747
1038
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
748
1039
|
className: "tag-stat-value"
|
|
749
1040
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
@@ -814,7 +1105,7 @@ function glanceCard(pi) {
|
|
|
814
1105
|
title: item.path
|
|
815
1106
|
}, /* @__PURE__ */ React.createElement("bdi", null, directory(item.path)))), item.note && /* @__PURE__ */ React.createElement("span", {
|
|
816
1107
|
className: "tag-change-note"
|
|
817
|
-
}, /* @__PURE__ */ React.createElement(
|
|
1108
|
+
}, /* @__PURE__ */ React.createElement(Clamp, {
|
|
818
1109
|
text: item.note
|
|
819
1110
|
}))), /* @__PURE__ */ React.createElement("span", {
|
|
820
1111
|
className: "tag-change-count"
|
|
@@ -842,7 +1133,7 @@ function glanceCard(pi) {
|
|
|
842
1133
|
size: 11
|
|
843
1134
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
844
1135
|
className: "tag-step-text"
|
|
845
|
-
}, /* @__PURE__ */ React.createElement(
|
|
1136
|
+
}, /* @__PURE__ */ React.createElement(Clamp, {
|
|
846
1137
|
text: item.text
|
|
847
1138
|
})))));
|
|
848
1139
|
}
|
|
@@ -936,95 +1227,22 @@ function glanceCard(pi) {
|
|
|
936
1227
|
const more = useMore(block2.rows.length, SHOWN.rows, words);
|
|
937
1228
|
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
|
|
938
1229
|
className: "ta-table tag-table"
|
|
939
|
-
}, /* @__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", {
|
|
940
1233
|
key: index
|
|
941
1234
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
942
1235
|
text: column
|
|
943
1236
|
}))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.slice(0, more.limit).map((row, index) => /* @__PURE__ */ React.createElement("tr", {
|
|
944
1237
|
key: index
|
|
945
1238
|
}, row.map((cell, column) => /* @__PURE__ */ React.createElement("td", {
|
|
946
|
-
key: column
|
|
947
|
-
|
|
1239
|
+
key: column,
|
|
1240
|
+
"data-label": plain(block2.columns[column] ?? "") || undefined
|
|
1241
|
+
}, /* @__PURE__ */ React.createElement(Clamp, {
|
|
948
1242
|
text: cell
|
|
949
1243
|
})))))))), more.toggle);
|
|
950
1244
|
}
|
|
951
|
-
|
|
952
|
-
const [tapped, setChosen] = React.useState();
|
|
953
|
-
const send = React.useContext(Reply);
|
|
954
|
-
const answer = React.useContext(Answer);
|
|
955
|
-
const said = answer.text === undefined ? undefined : GlanceWords.picked(answer.text, block2.items.map((item) => item.label));
|
|
956
|
-
const chosen = tapped ?? said;
|
|
957
|
-
const done = chosen !== undefined || answer.text !== undefined;
|
|
958
|
-
const pending = answer.known && closed && !done;
|
|
959
|
-
const choose = (label) => {
|
|
960
|
-
if (!send) {
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
setChosen(label);
|
|
964
|
-
send(GlanceWords.format(words.pick, { label })).catch((error) => {
|
|
965
|
-
setChosen(undefined);
|
|
966
|
-
pi.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
967
|
-
});
|
|
968
|
-
};
|
|
969
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
970
|
-
className: "tag-options-block",
|
|
971
|
-
"data-pending": pending || undefined
|
|
972
|
-
}, block2.question && /* @__PURE__ */ React.createElement("div", {
|
|
973
|
-
className: "tag-question"
|
|
974
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
975
|
-
text: block2.question
|
|
976
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
977
|
-
className: "tag-options"
|
|
978
|
-
}, block2.items.map((item, index) => {
|
|
979
|
-
const picked = chosen === item.label;
|
|
980
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
981
|
-
key: index,
|
|
982
|
-
className: "tag-option",
|
|
983
|
-
"data-recommended": item.recommended || undefined,
|
|
984
|
-
"data-chosen": picked || undefined,
|
|
985
|
-
"data-other": done && !picked || undefined
|
|
986
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
987
|
-
className: "tag-option-main"
|
|
988
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
989
|
-
className: "tag-option-head"
|
|
990
|
-
}, has(item.icon) && /* @__PURE__ */ React.createElement("span", {
|
|
991
|
-
className: "tag-item-icon"
|
|
992
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
993
|
-
name: item.icon,
|
|
994
|
-
size: 14
|
|
995
|
-
})), /* @__PURE__ */ React.createElement("span", {
|
|
996
|
-
className: "tag-option-label"
|
|
997
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
998
|
-
text: item.label
|
|
999
|
-
})), item.recommended && /* @__PURE__ */ React.createElement("span", {
|
|
1000
|
-
className: "tag-badge"
|
|
1001
|
-
}, words.recommended)), item.detail && /* @__PURE__ */ React.createElement("div", {
|
|
1002
|
-
className: "tag-option-detail"
|
|
1003
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1004
|
-
text: item.detail
|
|
1005
|
-
})), (item.pros.length > 0 || item.cons.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
1006
|
-
className: "tag-points"
|
|
1007
|
-
}, item.pros.map((point2, at) => /* @__PURE__ */ React.createElement("span", {
|
|
1008
|
-
key: `p${at}`,
|
|
1009
|
-
"data-tone": "good"
|
|
1010
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1011
|
-
text: point2
|
|
1012
|
-
}))), item.cons.map((point2, at) => /* @__PURE__ */ React.createElement("span", {
|
|
1013
|
-
key: `c${at}`,
|
|
1014
|
-
"data-tone": "bad"
|
|
1015
|
-
}, /* @__PURE__ */ React.createElement(Text, {
|
|
1016
|
-
text: point2
|
|
1017
|
-
}))))), /* @__PURE__ */ React.createElement("button", {
|
|
1018
|
-
type: "button",
|
|
1019
|
-
className: `ta-button tag-choose${item.recommended && !done ? " ta-primary" : ""}`,
|
|
1020
|
-
disabled: !closed || !send || done,
|
|
1021
|
-
onClick: () => choose(item.label)
|
|
1022
|
-
}, picked && /* @__PURE__ */ React.createElement(Icon, {
|
|
1023
|
-
name: "Check",
|
|
1024
|
-
size: 13
|
|
1025
|
-
}), /* @__PURE__ */ React.createElement("span", null, picked ? words.chosen : words.choose)));
|
|
1026
|
-
})));
|
|
1027
|
-
}
|
|
1245
|
+
const { Options, FormOf, useForm } = glanceOptions(pi, { Reply, Answer, Text, Icon, has });
|
|
1028
1246
|
const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "CircleArrowRight" };
|
|
1029
1247
|
function Notes({ block: block2 }) {
|
|
1030
1248
|
return /* @__PURE__ */ React.createElement("ul", {
|
|
@@ -1038,7 +1256,7 @@ function glanceCard(pi) {
|
|
|
1038
1256
|
name: item.icon,
|
|
1039
1257
|
fallback: NOTE_ICON[item.tone],
|
|
1040
1258
|
size: 14
|
|
1041
|
-
})), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(
|
|
1259
|
+
})), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(Clamp, {
|
|
1042
1260
|
text: item.text
|
|
1043
1261
|
})))));
|
|
1044
1262
|
}
|
|
@@ -1165,7 +1383,7 @@ ${block2.mermaid}
|
|
|
1165
1383
|
})));
|
|
1166
1384
|
}
|
|
1167
1385
|
function Head({ card, words }) {
|
|
1168
|
-
const status = card.status && (card
|
|
1386
|
+
const status = card.status && showsStatus(card) ? words.status[card.status] : undefined;
|
|
1169
1387
|
if (!status && !card.title) {
|
|
1170
1388
|
return null;
|
|
1171
1389
|
}
|
|
@@ -1186,22 +1404,27 @@ ${block2.mermaid}
|
|
|
1186
1404
|
const known = "answer" in props;
|
|
1187
1405
|
const answer = React.useMemo(() => ({ known, text: props.answer }), [known, props.answer]);
|
|
1188
1406
|
const words = GlanceWords.of(pi.ui.language);
|
|
1407
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
1189
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);
|
|
1190
1410
|
if (!card) {
|
|
1191
1411
|
return closed ? /* @__PURE__ */ React.createElement(Markdown, {
|
|
1192
1412
|
text: `\`\`\`json
|
|
1193
1413
|
${code}
|
|
1194
1414
|
\`\`\``
|
|
1195
1415
|
}) : /* @__PURE__ */ React.createElement("div", {
|
|
1196
|
-
className: "tag-card
|
|
1197
|
-
}, /* @__PURE__ */ React.createElement(
|
|
1198
|
-
|
|
1199
|
-
|
|
1416
|
+
className: "tag-card"
|
|
1417
|
+
}, /* @__PURE__ */ React.createElement(Loading, {
|
|
1418
|
+
compact: true,
|
|
1419
|
+
label: words.writing
|
|
1420
|
+
}));
|
|
1200
1421
|
}
|
|
1201
1422
|
return /* @__PURE__ */ React.createElement(Reply.Provider, {
|
|
1202
1423
|
value: send
|
|
1203
1424
|
}, /* @__PURE__ */ React.createElement(Answer.Provider, {
|
|
1204
1425
|
value: answer
|
|
1426
|
+
}, /* @__PURE__ */ React.createElement(FormOf.Provider, {
|
|
1427
|
+
value: form
|
|
1205
1428
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
1206
1429
|
className: "tag-card",
|
|
1207
1430
|
"data-status": card.status,
|
|
@@ -1222,7 +1445,7 @@ ${code}
|
|
|
1222
1445
|
block: block2,
|
|
1223
1446
|
words,
|
|
1224
1447
|
closed
|
|
1225
|
-
}))))));
|
|
1448
|
+
})))))));
|
|
1226
1449
|
};
|
|
1227
1450
|
}
|
|
1228
1451
|
|
|
@@ -1306,7 +1529,6 @@ var STYLE = `
|
|
|
1306
1529
|
.tag-card button { font-family: inherit; }
|
|
1307
1530
|
.tag-part { padding: var(--tag-y) var(--tag-x); min-width: 0; }
|
|
1308
1531
|
.tag-card[data-streaming] > .tag-part:last-child { animation: ta-in 200ms var(--ta-ease, ease) both; }
|
|
1309
|
-
.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); }
|
|
1310
1532
|
.tag-inline .ta-markdown, .tag-inline .ta-markdown > p { display: inline; margin: 0; }
|
|
1311
1533
|
.tag-inline .ta-markdown :not(pre) > code { padding: 0 4px; font-size: 0.92em; }
|
|
1312
1534
|
.tag-num { font-variant-numeric: tabular-nums; }
|
|
@@ -1353,6 +1575,10 @@ var STYLE = `
|
|
|
1353
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)); } }
|
|
1354
1576
|
/* Its icon, name and change wrap as wholes, so that a narrow box does not break the name */
|
|
1355
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); }
|
|
1356
1582
|
/* The icon an item names: before its label, in the color of its tone where it has one */
|
|
1357
1583
|
.tag-item-icon { flex: none; display: inline-flex; color: var(--ta-secondary); }
|
|
1358
1584
|
.tag-item-icon svg { width: calc(var(--tag-icon, 13px) * var(--tag-s)); height: calc(var(--tag-icon, 13px) * var(--tag-s)); }
|
|
@@ -1506,9 +1732,23 @@ var STYLE = `
|
|
|
1506
1732
|
.tag-card .tag-table th:first-child, .tag-card .tag-table td:first-child { padding-left: var(--tag-x); }
|
|
1507
1733
|
.tag-card .tag-table th:last-child, .tag-card .tag-table td:last-child { padding-right: var(--tag-x); }
|
|
1508
1734
|
.tag-card .tag-table th { font-size: var(--tag-small); color: var(--ta-secondary); }
|
|
1509
|
-
/*
|
|
1510
|
-
.tag-card .tag-table th:last-child
|
|
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%; }
|
|
1511
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
|
+
}
|
|
1512
1752
|
.tag-card .ta-mermaid { margin: 0; border: 0; border-radius: 0; background: transparent; }
|
|
1513
1753
|
.tag-card .ta-mermaid .ta-code-bar { padding-left: var(--tag-x); padding-right: calc(var(--tag-x) - 4px); }
|
|
1514
1754
|
.tag-card .ta-markdown:has(> .ta-mermaid) { margin: 0; }
|
|
@@ -1534,12 +1774,43 @@ var STYLE = `
|
|
|
1534
1774
|
.tag-points span[data-tone='good']::before { content: '+'; color: var(--ta-green); }
|
|
1535
1775
|
.tag-points span[data-tone='bad']::before { content: '−'; color: var(--ta-red); }
|
|
1536
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; }
|
|
1537
1796
|
@container tag-card (max-width: 400px) {
|
|
1538
1797
|
.tag-option { flex-direction: column; align-items: stretch; gap: 10px; }
|
|
1539
1798
|
.tag-choose { width: 100%; }
|
|
1540
1799
|
}
|
|
1541
1800
|
|
|
1542
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; }
|
|
1543
1814
|
.tag-notes li { display: flex; gap: 8px; }
|
|
1544
1815
|
.tag-notes li > span:last-child { flex: 1; min-width: 0; }
|
|
1545
1816
|
.tag-note-mark { display: inline-grid; place-items: center; color: var(--ta-muted); }
|
|
@@ -1575,7 +1846,8 @@ var STYLE = `
|
|
|
1575
1846
|
|
|
1576
1847
|
/* Touch: what is tapped is a finger high */
|
|
1577
1848
|
[data-touch] .tag-chip { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
|
|
1578
|
-
[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; }
|
|
1579
1851
|
[data-touch] .tag-details-toggle { min-height: 32px; }
|
|
1580
1852
|
`;
|
|
1581
1853
|
function injectStyle() {
|