@cardenelabs/cdl 0.58.0 → 0.59.1
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/CHANGELOG.md +43 -1
- package/dist/index.cjs +457 -237
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +458 -238
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +413 -193
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +414 -194
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/kinds/row-align.ts +30 -0
- package/src/lang.ts +224 -0
- package/src/render/interactive-panel.tsx +202 -126
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardenelabs/cdl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.1",
|
|
4
4
|
"description": "CDL (Chainome Diagram Language). Mermaid-like declarative DSL that compiles to animated SVG diagrams. Built for blockchain / Solidity flows, generic enough for sequence / flow / state / ER / topology diagrams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "cardene777",
|
package/src/kinds/row-align.ts
CHANGED
|
@@ -133,6 +133,36 @@ export function displayWidth(text: string): number {
|
|
|
133
133
|
return w;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* 字を先頭から半角の桁数 (`displayWidth`) で `桁` に収まるだけ取り、取った字と残りに割る (#851)。
|
|
138
|
+
*
|
|
139
|
+
* 2 桁の字が境目をまたぐ時は、その字を残りの側に回す (取った側が `桁` を越えない)。
|
|
140
|
+
*/
|
|
141
|
+
export function 桁で割る(text: string, 桁: number): [string, string] {
|
|
142
|
+
let w = 0;
|
|
143
|
+
let 取った = "";
|
|
144
|
+
for (const ch of text) {
|
|
145
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
146
|
+
const 字の桁 = code >= 0x20 && code <= 0x7e ? 1 : 2;
|
|
147
|
+
if (w + 字の桁 > 桁) break;
|
|
148
|
+
w += 字の桁;
|
|
149
|
+
取った += ch;
|
|
150
|
+
}
|
|
151
|
+
return [取った, text.slice(取った.length)];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 字が半角の桁数で `上限` を越える時、「上限 - 1」 桁に収まるだけの字に `…` を付けて返す (#851)。
|
|
156
|
+
*
|
|
157
|
+
* 読み出しは字数で省いていた。 上限の字数は英字の幅で決めてあり、和文は 1 字が英字のおよそ 2 倍の幅なので
|
|
158
|
+
* 上限の字数に届く前に枠からはみ出していた。 上限を半角の桁数と読み替えれば、ASCII だけの字は変更前の
|
|
159
|
+
* `length > 上限 ? slice(0, 上限 - 1) + "…"` と同じ所で省き、和文は半分の字数で省く。
|
|
160
|
+
*/
|
|
161
|
+
export function 桁で省く(text: string, 上限: number): string {
|
|
162
|
+
if (displayWidth(text) <= 上限) return text;
|
|
163
|
+
return `${桁で割る(text, 上限 - 1)[0]}…`;
|
|
164
|
+
}
|
|
165
|
+
|
|
136
166
|
/**
|
|
137
167
|
* rows[] から最低限必要な node width を算出。
|
|
138
168
|
* 左 padding + 左列 max 幅 + col gap + 右列 max 幅 + 右 padding。
|
package/src/lang.ts
CHANGED
|
@@ -100,6 +100,148 @@ const en = {
|
|
|
100
100
|
"apiGateway.orders": "/orders",
|
|
101
101
|
/** `shape-api-gateway` の 3 行目の宛先 */
|
|
102
102
|
"apiGateway.session": "/session",
|
|
103
|
+
|
|
104
|
+
// 読み出し (`readout.*`) と入力欄の固定の字 (#849)。
|
|
105
|
+
// `{名前}` は描く時に値を差し込む位置 (`字を差し込む`)。 語順が言語で変わるので、位置ごと辞書に持つ
|
|
106
|
+
|
|
107
|
+
/** 配列を描く読み出しで、値が空の時の字 */
|
|
108
|
+
"readout.empty": "empty",
|
|
109
|
+
/** `sparkline` で点がまだ無い時の字 */
|
|
110
|
+
"readout.sparkline.waiting": "waiting",
|
|
111
|
+
/** 時の流れの入力欄の速さ */
|
|
112
|
+
"input.timeline.speed": "{speed}x",
|
|
113
|
+
/** 時の流れの入力欄の経過と長さ (秒) */
|
|
114
|
+
"input.timeline.time": "{t}s / {d}s",
|
|
115
|
+
/** `sequence-timeline` の点の見出し */
|
|
116
|
+
"readout.sequenceTimeline.title": "{name}: t={t}",
|
|
117
|
+
/** `bubble-chart` の泡の見出し */
|
|
118
|
+
"readout.bubbleChart.title": "({x}, {y}) r={r}",
|
|
119
|
+
/** `calendar-heatmap` の升目の見出し (`i` は 0 から) */
|
|
120
|
+
"readout.calendarHeatmap.title": "day {i}: {v}",
|
|
121
|
+
/** `candlestick` の足の見出し (始値 / 高値 / 安値 / 終値) */
|
|
122
|
+
"readout.candlestick.title": "O:{o} H:{h} L:{l} C:{c}",
|
|
123
|
+
/** `slope` の左の目盛 */
|
|
124
|
+
"readout.slope.before": "before",
|
|
125
|
+
/** `slope` の右の目盛 */
|
|
126
|
+
"readout.slope.after": "after",
|
|
127
|
+
/** `bullet-chart` の実績の見出し */
|
|
128
|
+
"readout.bulletChart.actual": "actual: {v}",
|
|
129
|
+
/** `bullet-chart` の目標の見出し */
|
|
130
|
+
"readout.bulletChart.target": "target: {v}",
|
|
131
|
+
/** `rating` の塗った星の見出し */
|
|
132
|
+
"readout.rating.full": "full",
|
|
133
|
+
/** `rating` の半分塗った星の見出し */
|
|
134
|
+
"readout.rating.half": "half",
|
|
135
|
+
/** `rating` の塗っていない星の見出し */
|
|
136
|
+
"readout.rating.empty": "empty",
|
|
137
|
+
/** `price-tag` の割引額 */
|
|
138
|
+
"readout.priceTag.save": "You save {amount}",
|
|
139
|
+
/** `confidence-meter` の低い帯の名前 */
|
|
140
|
+
"readout.confidence.low": "low",
|
|
141
|
+
/** `confidence-meter` の中ほどの帯の名前 */
|
|
142
|
+
"readout.confidence.mid": "mid",
|
|
143
|
+
/** `confidence-meter` の高い帯の名前 */
|
|
144
|
+
"readout.confidence.high": "high",
|
|
145
|
+
/** 並べきれなかった件数 (`user-stack` / `kanban-board` / `user-presence`) */
|
|
146
|
+
"readout.more": "+{n} more",
|
|
147
|
+
/** `video-card` の再生数 */
|
|
148
|
+
"readout.videoCard.views": "{v} views",
|
|
149
|
+
/** `attendance-grid` の角の見出し */
|
|
150
|
+
"readout.attendance.corner": "day",
|
|
151
|
+
/** `calendar-month` の曜日 (日曜) */
|
|
152
|
+
"readout.weekday.0": "Sun",
|
|
153
|
+
/** `calendar-month` の曜日 (月曜) */
|
|
154
|
+
"readout.weekday.1": "Mon",
|
|
155
|
+
/** `calendar-month` の曜日 (火曜) */
|
|
156
|
+
"readout.weekday.2": "Tue",
|
|
157
|
+
/** `calendar-month` の曜日 (水曜) */
|
|
158
|
+
"readout.weekday.3": "Wed",
|
|
159
|
+
/** `calendar-month` の曜日 (木曜) */
|
|
160
|
+
"readout.weekday.4": "Thu",
|
|
161
|
+
/** `calendar-month` の曜日 (金曜) */
|
|
162
|
+
"readout.weekday.5": "Fri",
|
|
163
|
+
/** `calendar-month` の曜日 (土曜) */
|
|
164
|
+
"readout.weekday.6": "Sat",
|
|
165
|
+
/** `rating-thumb` の賛成の割合と票数 */
|
|
166
|
+
"readout.ratingThumb.summary": "{pct}% up · {total} votes",
|
|
167
|
+
/** `kpi-trend-tile` の前の期間の値 */
|
|
168
|
+
"readout.kpiTrend.prev": "prev {v}",
|
|
169
|
+
/** `quick-poll-emoji` の票の合計 */
|
|
170
|
+
"readout.poll.total": "total {n}",
|
|
171
|
+
/** `thread-summary` の参加者の数 */
|
|
172
|
+
"readout.thread.participants": "{n} participants",
|
|
173
|
+
/** `thread-summary` の最後に書いた人 */
|
|
174
|
+
"readout.thread.last": "last: {name}",
|
|
175
|
+
/** `read-receipt` の送信した段 */
|
|
176
|
+
"readout.readReceipt.sent": "sent",
|
|
177
|
+
/** `read-receipt` の相手に届いた段 */
|
|
178
|
+
"readout.readReceipt.delivered": "delivered",
|
|
179
|
+
/** `read-receipt` の読まれた段 */
|
|
180
|
+
"readout.readReceipt.read": "read",
|
|
181
|
+
/** `password-strength` の段階 0 */
|
|
182
|
+
"readout.password.0": "too weak",
|
|
183
|
+
/** `password-strength` の段階 1 */
|
|
184
|
+
"readout.password.1": "weak",
|
|
185
|
+
/** `password-strength` の段階 2 */
|
|
186
|
+
"readout.password.2": "fair",
|
|
187
|
+
/** `password-strength` の段階 3 */
|
|
188
|
+
"readout.password.3": "good",
|
|
189
|
+
/** `password-strength` の段階 4 */
|
|
190
|
+
"readout.password.4": "strong",
|
|
191
|
+
/** `file-dropzone` で取り込んだ後の字 */
|
|
192
|
+
"readout.dropzone.uploaded": "uploaded",
|
|
193
|
+
/** `file-dropzone` の空の時の 1 行目 */
|
|
194
|
+
"readout.dropzone.drop": "⬆ Drop file here",
|
|
195
|
+
/** `file-dropzone` の空の時の 2 行目 */
|
|
196
|
+
"readout.dropzone.browse": "or click to browse",
|
|
197
|
+
/** `log-stream` の重さ 0 (調べるための詳細) */
|
|
198
|
+
"readout.log.0": "DBG",
|
|
199
|
+
/** `log-stream` の重さ 1 (知らせ) */
|
|
200
|
+
"readout.log.1": "INF",
|
|
201
|
+
/** `log-stream` の重さ 2 (警告) */
|
|
202
|
+
"readout.log.2": "WRN",
|
|
203
|
+
/** `log-stream` の重さ 3 (異常) */
|
|
204
|
+
"readout.log.3": "ERR",
|
|
205
|
+
/** `cart-summary` の点数 */
|
|
206
|
+
"readout.cart.items": "Items",
|
|
207
|
+
/** `cart-summary` の小計 */
|
|
208
|
+
"readout.cart.subtotal": "Subtotal",
|
|
209
|
+
/** `cart-summary` の送料 */
|
|
210
|
+
"readout.cart.shipping": "Shipping",
|
|
211
|
+
/** `cart-summary` の合計 */
|
|
212
|
+
"readout.cart.total": "Total",
|
|
213
|
+
/** `pricing-tier` で名前が空の時の名前 */
|
|
214
|
+
"readout.pricing.plan": "Plan",
|
|
215
|
+
/** `pricing-tier` の価格の後ろ */
|
|
216
|
+
"readout.pricing.perMonth": "per month",
|
|
217
|
+
/** `pricing-tier` の押す札 */
|
|
218
|
+
"readout.pricing.get": "Get {name}",
|
|
219
|
+
/** `coupon-code` で番号が空の時の字 */
|
|
220
|
+
"readout.coupon.placeholder": "ENTER CODE",
|
|
221
|
+
/** `coupon-code` の割引の割合 */
|
|
222
|
+
"readout.coupon.off": "-{pct}% off",
|
|
223
|
+
/** `coupon-code` の押す札 */
|
|
224
|
+
"readout.coupon.apply": "Apply",
|
|
225
|
+
/** `article-preview` の書いた人 */
|
|
226
|
+
"readout.article.by": "by {author}",
|
|
227
|
+
/** `priority-badge` の高い優先度の表示 (値は `high` / `2` で読む) */
|
|
228
|
+
"readout.priority.high": "HIGH",
|
|
229
|
+
/** `priority-badge` の中ほどの優先度の表示 */
|
|
230
|
+
"readout.priority.med": "MED",
|
|
231
|
+
/** `priority-badge` の低い優先度の表示 (値は `low` / `0` で読む) */
|
|
232
|
+
"readout.priority.low": "LOW",
|
|
233
|
+
/** `kanban-board` の列の見出し (値は `todo` で読む) */
|
|
234
|
+
"readout.kanban.todo": "Todo",
|
|
235
|
+
/** `kanban-board` の列の見出し (値は `inprogress` で読む) */
|
|
236
|
+
"readout.kanban.inprogress": "In Progress",
|
|
237
|
+
/** `kanban-board` の列の見出し (値は `done` で読む) */
|
|
238
|
+
"readout.kanban.done": "Done",
|
|
239
|
+
/** `traffic-light` の赤の灯の見出し (値は `red` で読む) */
|
|
240
|
+
"readout.trafficLight.red": "red",
|
|
241
|
+
/** `traffic-light` の黄の灯の見出し (値は `yellow` / `amber` で読む) */
|
|
242
|
+
"readout.trafficLight.yellow": "yellow",
|
|
243
|
+
/** `traffic-light` の緑の灯の見出し (値は `green` で読む) */
|
|
244
|
+
"readout.trafficLight.green": "green",
|
|
103
245
|
} as const;
|
|
104
246
|
|
|
105
247
|
/** 辞書の鍵 */
|
|
@@ -146,6 +288,76 @@ const ja: Record<CdlTextKey, string> = {
|
|
|
146
288
|
"apiGateway.users": "/利用者",
|
|
147
289
|
"apiGateway.orders": "/注文",
|
|
148
290
|
"apiGateway.session": "/接続",
|
|
291
|
+
|
|
292
|
+
"readout.empty": "なし",
|
|
293
|
+
"readout.sparkline.waiting": "待機中",
|
|
294
|
+
"input.timeline.speed": "{speed}倍",
|
|
295
|
+
"input.timeline.time": "{t}秒 / {d}秒",
|
|
296
|
+
"readout.sequenceTimeline.title": "{name}: 時刻 {t}",
|
|
297
|
+
"readout.bubbleChart.title": "({x}, {y}) 半径 {r}",
|
|
298
|
+
"readout.calendarHeatmap.title": "{i} 日目: {v}",
|
|
299
|
+
"readout.candlestick.title": "始 {o} 高 {h} 安 {l} 終 {c}",
|
|
300
|
+
"readout.slope.before": "前",
|
|
301
|
+
"readout.slope.after": "後",
|
|
302
|
+
"readout.bulletChart.actual": "実績: {v}",
|
|
303
|
+
"readout.bulletChart.target": "目標: {v}",
|
|
304
|
+
"readout.rating.full": "満",
|
|
305
|
+
"readout.rating.half": "半分",
|
|
306
|
+
"readout.rating.empty": "空",
|
|
307
|
+
"readout.priceTag.save": "{amount} お得",
|
|
308
|
+
"readout.confidence.low": "低",
|
|
309
|
+
"readout.confidence.mid": "中",
|
|
310
|
+
"readout.confidence.high": "高",
|
|
311
|
+
"readout.more": "ほか {n}",
|
|
312
|
+
"readout.videoCard.views": "{v} 回視聴",
|
|
313
|
+
"readout.attendance.corner": "日",
|
|
314
|
+
"readout.weekday.0": "日",
|
|
315
|
+
"readout.weekday.1": "月",
|
|
316
|
+
"readout.weekday.2": "火",
|
|
317
|
+
"readout.weekday.3": "水",
|
|
318
|
+
"readout.weekday.4": "木",
|
|
319
|
+
"readout.weekday.5": "金",
|
|
320
|
+
"readout.weekday.6": "土",
|
|
321
|
+
"readout.ratingThumb.summary": "賛成 {pct}% · {total} 票",
|
|
322
|
+
"readout.kpiTrend.prev": "前回 {v}",
|
|
323
|
+
"readout.poll.total": "合計 {n}",
|
|
324
|
+
"readout.thread.participants": "{n} 人",
|
|
325
|
+
"readout.thread.last": "最後: {name}",
|
|
326
|
+
"readout.readReceipt.sent": "送信済み",
|
|
327
|
+
"readout.readReceipt.delivered": "配信済み",
|
|
328
|
+
"readout.readReceipt.read": "既読",
|
|
329
|
+
"readout.password.0": "弱すぎる",
|
|
330
|
+
"readout.password.1": "弱い",
|
|
331
|
+
"readout.password.2": "普通",
|
|
332
|
+
"readout.password.3": "良い",
|
|
333
|
+
"readout.password.4": "強い",
|
|
334
|
+
"readout.dropzone.uploaded": "取り込み済み",
|
|
335
|
+
"readout.dropzone.drop": "⬆ ここにファイルを置く",
|
|
336
|
+
"readout.dropzone.browse": "または押して選ぶ",
|
|
337
|
+
"readout.log.0": "詳細",
|
|
338
|
+
"readout.log.1": "情報",
|
|
339
|
+
"readout.log.2": "警告",
|
|
340
|
+
"readout.log.3": "異常",
|
|
341
|
+
"readout.cart.items": "点数",
|
|
342
|
+
"readout.cart.subtotal": "小計",
|
|
343
|
+
"readout.cart.shipping": "送料",
|
|
344
|
+
"readout.cart.total": "合計",
|
|
345
|
+
"readout.pricing.plan": "プラン",
|
|
346
|
+
"readout.pricing.perMonth": "月額",
|
|
347
|
+
"readout.pricing.get": "{name}を選ぶ",
|
|
348
|
+
"readout.coupon.placeholder": "コードを入力",
|
|
349
|
+
"readout.coupon.off": "-{pct}% 引き",
|
|
350
|
+
"readout.coupon.apply": "適用",
|
|
351
|
+
"readout.article.by": "文: {author}",
|
|
352
|
+
"readout.priority.high": "高",
|
|
353
|
+
"readout.priority.med": "中",
|
|
354
|
+
"readout.priority.low": "低",
|
|
355
|
+
"readout.kanban.todo": "未着手",
|
|
356
|
+
"readout.kanban.inprogress": "進行中",
|
|
357
|
+
"readout.kanban.done": "完了",
|
|
358
|
+
"readout.trafficLight.red": "赤",
|
|
359
|
+
"readout.trafficLight.yellow": "黄",
|
|
360
|
+
"readout.trafficLight.green": "緑",
|
|
149
361
|
};
|
|
150
362
|
|
|
151
363
|
/** 言語ごとの辞書。 検査が鍵の一致を実行時にも確かめるため公開する */
|
|
@@ -166,3 +378,15 @@ export function 字引きを作る(lang: CdlLang | undefined): (key: CdlTextKey)
|
|
|
166
378
|
const 言語 = lang ?? "en";
|
|
167
379
|
return (key) => CDL_TEXT[言語][key];
|
|
168
380
|
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* 辞書の字の `{名前}` に値を差し込む (#849)。
|
|
384
|
+
*
|
|
385
|
+
* **差し込む位置を辞書に持たせる**。 `+3 more` と `ほか 3` のように、値の前後に来る語が言語で
|
|
386
|
+
* 変わるため、字を前後に分けて持つと語順を表せない。
|
|
387
|
+
*
|
|
388
|
+
* 渡されなかった名前は `{名前}` のまま残す (黙って空にすると、差し込み忘れが画面で見えなくなる)。
|
|
389
|
+
*/
|
|
390
|
+
export function 字を差し込む(template: string, values: Readonly<Record<string, string | number>>): string {
|
|
391
|
+
return template.replace(/\{(\w+)\}/g, (whole, name: string) => (name in values ? String(values[name]) : whole));
|
|
392
|
+
}
|