egatari 0.6.11 → 0.6.12-rc.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/bin/egatari.mjs +4 -3
- package/components.lock.json +30 -15
- package/components2.lock.json +201 -1
- package/fonts/@fontsource/fraunces/400.css +29 -0
- package/fonts/@fontsource/fraunces/700.css +29 -0
- package/fonts/@fontsource/fraunces/LICENSE +93 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-400-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-700-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-ext-400-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-ext-700-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-vietnamese-400-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-vietnamese-700-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/package.json +6 -0
- package/kit/check-messages.mjs +18 -7
- package/kit/check.mjs +12 -4
- package/kit/core/article-render.mjs +5 -5
- package/kit/core/build-core.mjs +25 -9
- package/kit/core/check-parity.mjs +1 -1
- package/kit/core/check-rules.mjs +2 -2
- package/kit/core/check-source.mjs +3 -0
- package/kit/core/colab-core.mjs +1 -1
- package/kit/core/kicker.mjs +42 -0
- package/kit/core/layout-scan.mjs +19 -7
- package/kit/core/llm-pack-data.mjs +8 -8
- package/kit/core/llm-pack.mjs +2 -2
- package/kit/core/theme-shapes.mjs +3 -1
- package/kit/core/themes-list.mjs +2 -0
- package/kit/instruction-version.json +1 -1
- package/kit/layouts.css +8 -0
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/package.json +2 -1
- package/themes/asagi/theme.json +1 -1
- package/themes/asagi/tokens.css +6 -0
- package/themes/bengara/theme.json +13 -0
- package/themes/bengara/tokens.css +66 -0
- package/themes/business/theme.json +1 -1
- package/themes/business/tokens.css +6 -0
- package/themes/default/theme.json +1 -1
- package/themes/default/tokens.css +9 -0
- package/themes/kogecha/theme.json +1 -1
- package/themes/kogecha/tokens.css +6 -0
- package/themes/kokugo/theme.json +1 -1
- package/themes/kokugo/tokens.css +6 -0
- package/themes/murasaki/theme.json +1 -1
- package/themes/murasaki/tokens.css +6 -0
- package/themes/sumi/theme.json +1 -1
- package/themes/sumi/tokens.css +8 -0
- package/themes/tokiwa/theme.json +1 -1
- package/themes/tokiwa/tokens.css +6 -0
- package/themes.lock.json +90 -24
- package/vendor/components/CATALOG.md +11 -11
- package/vendor/components/sha256/04626b77b3c683fd4c8e549339eca153615e021eb0e649c31291deb2dab30667/README.en.md +38 -0
- package/vendor/components/sha256/04626b77b3c683fd4c8e549339eca153615e021eb0e649c31291deb2dab30667/index.js +289 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/chords.json +89 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/extras.json +192 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/ties.json +360 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/index.js +508 -0
- package/vendor/components/sha256/0dc2a0945e7a4004278fcc9b8f02223bbb87f6269bffe3dd3ebeb3a78ce23d34/index.js +404 -0
- package/vendor/components/sha256/0e2e45b024bb2f37e82c83a4d9cd9f9c16b5dc4924dde81735c268a3d49f9d7f/index.js +97 -0
- package/vendor/components/sha256/0ef62e33d330f8e31ccb1f480b5e3b349769a142cc2737a9e6583d5eff9f56ca/index.js +919 -0
- package/vendor/components/sha256/1b33a252d51091e2d8cdea176f10268f128640bed3aa46da88d7de31ced59b44/README.en.md +48 -0
- package/vendor/components/sha256/1b33a252d51091e2d8cdea176f10268f128640bed3aa46da88d7de31ced59b44/index.js +384 -0
- package/vendor/components/sha256/1b767b6cf1855156872f87981a7c99f0161013499d6c4b21785624435db92078/README.en.md +34 -0
- package/vendor/components/sha256/1b767b6cf1855156872f87981a7c99f0161013499d6c4b21785624435db92078/index.js +244 -0
- package/vendor/components/sha256/3ace61e46a4555eab46ca8053db2fb76a874d4d5409bc5891cc449f43ef7e0bd/README.en.md +44 -0
- package/vendor/components/sha256/3ace61e46a4555eab46ca8053db2fb76a874d4d5409bc5891cc449f43ef7e0bd/index.js +304 -0
- package/vendor/components/sha256/4079077e03343995edc5e34b8bda0cf200dc6d854a52486fe0a6a4ceaf0d4b6f/README.en.md +44 -0
- package/vendor/components/sha256/4079077e03343995edc5e34b8bda0cf200dc6d854a52486fe0a6a4ceaf0d4b6f/index.js +203 -0
- package/vendor/components/sha256/40aaaaf988e7c32460ffaf5f18b5690ee28fd1fe7e879d8434d58283992bc554/README.en.md +37 -0
- package/vendor/components/sha256/40aaaaf988e7c32460ffaf5f18b5690ee28fd1fe7e879d8434d58283992bc554/index.js +438 -0
- package/vendor/components/sha256/442be174439d106ef462c19d598c407e86d5de3fcd4700ed54ae4147c4b9969c/README.en.md +24 -0
- package/vendor/components/sha256/442be174439d106ef462c19d598c407e86d5de3fcd4700ed54ae4147c4b9969c/index.js +103 -0
- package/vendor/components/sha256/48a776e7683e1aba8cad5aa4067914c017681efaa74f175066e0ab081bf3d013/index.js +351 -0
- package/vendor/components/sha256/4a9331635c2dd28e4b46108eaffe49c6d29cf626ecb900ac6e9029552be0cf49/index.js +607 -0
- package/vendor/components/sha256/5458baef7a30298cf4b0029331f13233d162403e686f9c20085dd2104cad7141/README.en.md +23 -0
- package/vendor/components/sha256/5458baef7a30298cf4b0029331f13233d162403e686f9c20085dd2104cad7141/index.js +120 -0
- package/vendor/components/sha256/586063d3a4e24e2995923811b2b9466bde86dbaafb3bcf103546d3f28159205a/index.js +812 -0
- package/vendor/components/sha256/5acc5f87e29f1170bc35dbee08087d0d03c1023969c6c1b1367a0f559d60e5ee/index.js +198 -0
- package/vendor/components/sha256/5c032594230fe688f661b6ccf27070c84f8c0e38611186280fb9c56d89ac3319/README.en.md +32 -0
- package/vendor/components/sha256/5c032594230fe688f661b6ccf27070c84f8c0e38611186280fb9c56d89ac3319/index.js +222 -0
- package/vendor/components/sha256/603de10f0ee50d07ec610e21b45b9db78d69376b4dfd2baba78595c1002e27ec/README.en.md +50 -0
- package/vendor/components/sha256/603de10f0ee50d07ec610e21b45b9db78d69376b4dfd2baba78595c1002e27ec/index.js +171 -0
- package/vendor/components/sha256/609e45a826d07a54cbbcbf4ce2ad6b5474dca1d0be394eb9fad895db4a73422f/README.en.md +51 -0
- package/vendor/components/sha256/609e45a826d07a54cbbcbf4ce2ad6b5474dca1d0be394eb9fad895db4a73422f/index.js +228 -0
- package/vendor/components/sha256/6364043cb31bbd86aacb7432af1a8affef8cae5c6efdbe13fbebd116fd51b91f/index.js +233 -0
- package/vendor/components/sha256/6f9f7283226d3534aa1cb4a47ba258204aa286ead01b25cdbde14119260bc702/README.en.md +66 -0
- package/vendor/components/sha256/6f9f7283226d3534aa1cb4a47ba258204aa286ead01b25cdbde14119260bc702/index.js +920 -0
- package/vendor/components/sha256/72edfd6678b22be0bb3e32b0d8cb0dfee403767e1eacac354d278d7318d03826/README.en.md +35 -0
- package/vendor/components/sha256/72edfd6678b22be0bb3e32b0d8cb0dfee403767e1eacac354d278d7318d03826/index.js +179 -0
- package/vendor/components/sha256/7482c50bea5ef7d72dc5d4afaddb8c4e725b5a83fa0c6175f9a9c556f23a4e10/LICENSE-tabler.txt +21 -0
- package/vendor/components/sha256/7482c50bea5ef7d72dc5d4afaddb8c4e725b5a83fa0c6175f9a9c556f23a4e10/index.js +4868 -0
- package/vendor/components/sha256/7482c50bea5ef7d72dc5d4afaddb8c4e725b5a83fa0c6175f9a9c556f23a4e10/names.txt +4808 -0
- package/vendor/components/sha256/7cb8948c550b66bf4b34a62e7b61385aaa79896e09d82ccb1846c0ac499ad352/README.en.md +40 -0
- package/vendor/components/sha256/7cb8948c550b66bf4b34a62e7b61385aaa79896e09d82ccb1846c0ac499ad352/index.js +348 -0
- package/vendor/components/sha256/87cc60da38d209cda449dd7c24171e287ac8184c5036ca04548ef9e2015c2d9e/README.en.md +42 -0
- package/vendor/components/sha256/87cc60da38d209cda449dd7c24171e287ac8184c5036ca04548ef9e2015c2d9e/index.js +268 -0
- package/vendor/components/sha256/8cb367c71c002c689defddc6f075be911d5485421715119b5515181e962a2401/index.js +121 -0
- package/vendor/components/sha256/97bfd6e79c7278c55153bf4c2330da0432cf0ee312baa11650e07cdd7912831d/index.js +354 -0
- package/vendor/components/sha256/a426e6a3f8f4593403ba63ecc4a3f1f41064f4016fd9fb8d51e7876bf8c6f573/README.en.md +40 -0
- package/vendor/components/sha256/a426e6a3f8f4593403ba63ecc4a3f1f41064f4016fd9fb8d51e7876bf8c6f573/index.js +348 -0
- package/vendor/components/sha256/c108119117042cacc65a35ec73fcab95a2a92b2a2797129f66e326783f8db178/index.js +465 -0
- package/vendor/components/sha256/c3fad2047cec6a2bd8a5b907f752e2addeeea2f373fd8115914552dcee0b2f6f/README.en.md +23 -0
- package/vendor/components/sha256/c3fad2047cec6a2bd8a5b907f752e2addeeea2f373fd8115914552dcee0b2f6f/index.js +289 -0
- package/vendor/components/sha256/c59f1ac3132fdf6f56e8880c866570cd7443f09eb8802b6e7af32675ad358edf/README.en.md +31 -0
- package/vendor/components/sha256/c59f1ac3132fdf6f56e8880c866570cd7443f09eb8802b6e7af32675ad358edf/index.js +236 -0
- package/vendor/components/sha256/d3a75f67160490db1831aaa8ac58ebc5f7ffb6a6fd21e2bdeaa6fe979bfaff7f/README.en.md +42 -0
- package/vendor/components/sha256/d3a75f67160490db1831aaa8ac58ebc5f7ffb6a6fd21e2bdeaa6fe979bfaff7f/index.js +488 -0
- package/vendor/components/sha256/d998b5db828427505e39cdae67676dc6480c791d6037152dec222ae81cdbba1f/index.js +484 -0
- package/vendor/components/sha256/ea17602aaecca64b672b3bc827965ff378cb460250177f7b66f73081a48d4e81/index.js +278 -0
- package/vendor/components/sha256/f9cef6dd9580a4f19aa09d47f736ab2391f5f585b20b16a62bd781398cb6b8ac/README.en.md +22 -0
- package/vendor/components/sha256/f9cef6dd9580a4f19aa09d47f736ab2391f5f585b20b16a62bd781398cb6b8ac/index.js +145 -0
- package/vendor/components-2/manifest-2.8.0.json +2199 -0
- package/vendor/themes/asagi/1.2.0/theme.json +14 -0
- package/vendor/themes/asagi/1.2.0/tokens.css +30 -0
- package/vendor/themes/business/1.2.0/theme.json +5 -0
- package/vendor/themes/business/1.2.0/tokens.css +41 -0
- package/vendor/themes/default/1.4.0/theme.json +4 -0
- package/vendor/themes/default/1.4.0/tokens.css +86 -0
- package/vendor/themes/kogecha/1.2.0/theme.json +10 -0
- package/vendor/themes/kogecha/1.2.0/tokens.css +29 -0
- package/vendor/themes/kokugo/1.2.0/theme.json +5 -0
- package/vendor/themes/kokugo/1.2.0/tokens.css +25 -0
- package/vendor/themes/murasaki/1.2.0/theme.json +10 -0
- package/vendor/themes/murasaki/1.2.0/tokens.css +25 -0
- package/vendor/themes/sumi/1.2.0/theme.json +10 -0
- package/vendor/themes/sumi/1.2.0/tokens.css +49 -0
- package/vendor/themes/tokiwa/1.2.0/theme.json +10 -0
- package/vendor/themes/tokiwa/1.2.0/tokens.css +27 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: KPI cards by step; count-up, change arrow, note
|
|
3
|
+
steps: largest card step (default 1 card = 1 step)
|
|
4
|
+
props:
|
|
5
|
+
cols: cards per row (0 = count, ≤ 4)
|
|
6
|
+
digits: decimals (card wins)
|
|
7
|
+
per-step: cards per step (0 = all)
|
|
8
|
+
dur: count seconds
|
|
9
|
+
stagger: card offset (s)
|
|
10
|
+
count: count up
|
|
11
|
+
size: number px (0 = auto)
|
|
12
|
+
example: {"cards": [{"label": "Drafting time", "value": 62, "unit": "%", "prefix": "−", "delta": {"dir": "down", "text": "8 pt vs last", "good": true}}]}
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
Child JSON: `{"cards": [{"label", "value", "digits", "unit", "prefix", "from", "tone", "delta", "note", "step", "at"}, …]}`.
|
|
16
|
+
|
|
17
|
+
- `label`: above. `value` (`digits`, commas). `unit`: after. `prefix`: before (`+`, `~`). Negative `value` has its own −: no `prefix` `−` (−−12); `prefix: "−"` only with a positive decrease
|
|
18
|
+
- `from`: count start (default 0; may count down)
|
|
19
|
+
- `tone`: number, top band (`term`, `emph`, `accent2`, `series-1..4`)
|
|
20
|
+
- `delta`: `{"dir": "up" | "down", "text": "+4", "good": true}`: ▲/▼ + text; good (default `up`) `--term`, bad `--emph`
|
|
21
|
+
- `note`: bottom line
|
|
22
|
+
<!-- llm: omit -->
|
|
23
|
+
- Count-up eases out; depends on (k, t) only (t = Infinity = final). `count="false"`: no counting
|
|
24
|
+
<!-- llm: end -->
|
|
25
|
+
- `variant`: `count` (default), `rise`, `flip`, `underline`; `count="false"` → `rise`
|
|
26
|
+
- `cues(k)`: start times of 2nd+ cards in a step (for `{cue}`)
|
|
27
|
+
|
|
28
|
+
The demo is `demo.html`. All numbers are fictional.
|
|
29
|
+
|
|
30
|
+
<!-- llm: omit -->
|
|
31
|
+
Notes
|
|
32
|
+
|
|
33
|
+
- `rise`: final value grows in; `flip`: digits flip from the right. Cards wrap past `cols`
|
|
34
|
+
- Number and unit width estimated from characters and centred; the right edge stays put while counting; may be off by a few characters
|
|
35
|
+
<!-- llm: end -->
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// m-kpi:大きな数字の札(KPI)を段階ごとに出す。数字は 0(か from)から数え上げ、下に増減の矢印と一言
|
|
2
|
+
// <m-kpi style="height:300px"><script type="application/json">
|
|
3
|
+
// {"cards": [{"label": "作成時間", "value": 62, "unit": "%", "prefix": "−", "delta": {"dir": "down", "text": "前の版から 8 pt", "good": true}, "note": "1 本あたり"}]}
|
|
4
|
+
// (JSON の終わり)</m-kpi>
|
|
5
|
+
// 段階:既定は札 1 枚 = 1 段階(per-step で n 枚ずつ、札の step で直接、at で段階の中の開始秒)
|
|
6
|
+
// 数え上げは (k, t) だけで決まる(初めに速く、終わりにゆっくり。t = Infinity なら最後の値)。count="false" で数えずに出す
|
|
7
|
+
// 札の幅は cols(既定は札の数、4 まで)で決める。数字と単位の幅は字数から見積もって中央にそろえる(字の読み込みを待たない)
|
|
8
|
+
// 見せ方(docs/conventions.md §1):count(数え上げ、既定)・rise(最後の値のまま少し小さい大きさから戻る)・flip(右の桁から 1 桁ずつ
|
|
9
|
+
// めくれて止まる)・underline(出たあと数字の下に線を引く)。段階の数・長さ・合図・最後の中身はどれも同じ
|
|
10
|
+
// 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・lerp・clamp・variant・previewOpacity を使い、プレイヤーのグローバルは使わない
|
|
11
|
+
egatariParts.define({name: "kpi", version: "2.0.3", requires: {base: "1.2.0"}, element: "m-kpi"}, function(deps){
|
|
12
|
+
"use strict";
|
|
13
|
+
var base = deps.base;
|
|
14
|
+
return class extends base.MotionElement {
|
|
15
|
+
static partName = "kpi"; // the registry name (define meta name), for report prefixes
|
|
16
|
+
static variants = ["count", "rise", "flip", "underline"];
|
|
17
|
+
// データの形(kit/shape.js)
|
|
18
|
+
static shape = {
|
|
19
|
+
schema: {type: "object", additionalProperties: false, required: ["cards"], properties: {
|
|
20
|
+
cards: {type: "array", minItems: 1, items: {type: "object", required: ["value"], properties: {
|
|
21
|
+
label: {type: "string"}, value: {type: "number"}, digits: {type: "integer"}, unit: {type: "string"}, prefix: {type: "string"}, from: {type: "number"}, tone: {type: "string"},
|
|
22
|
+
delta: {type: "object", properties: {dir: {enum: ["up", "down"]}, text: {type: "string"}, good: {type: "boolean"}}}, note: {type: "string"}, step: {type: "integer"}, at: {type: "number"}}}}}},
|
|
23
|
+
example: {cards: [{label: "作成時間", value: 62, unit: "%", prefix: "−", delta: {dir: "down", text: "前の版から 8 pt", good: true}}]},
|
|
24
|
+
};
|
|
25
|
+
static props = {
|
|
26
|
+
cols: {type: "number", default: 0, doc: "1 行の札の数(0 = 札の数、4 まで)"},
|
|
27
|
+
digits: {type: "number", default: 0, doc: "数字の小数桁(札の digits が優先)"},
|
|
28
|
+
"per-step": {type: "number", default: 1, doc: "1 ステップに出す札の数(0 = 全部をステップ 1 で)"},
|
|
29
|
+
dur: {type: "number", default: 1.2, doc: "数え上げの秒数"},
|
|
30
|
+
stagger: {type: "number", default: 0.3, doc: "同じステップの札の出だしのずれ(秒)"},
|
|
31
|
+
count: {type: "bool", default: true, doc: "数字を数え上げる"},
|
|
32
|
+
size: {type: "number", default: 0, doc: "数字の字の大きさ(px。0 = 札の高さから)"},
|
|
33
|
+
};
|
|
34
|
+
get steps(){
|
|
35
|
+
if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
|
|
36
|
+
var m = 0;
|
|
37
|
+
this.plan().forEach(function(o){ m = Math.max(m, o.step); });
|
|
38
|
+
return m;
|
|
39
|
+
}
|
|
40
|
+
plan(){
|
|
41
|
+
if (this._plan) return this._plan;
|
|
42
|
+
var P = this.props, per = P["per-step"], seen = {};
|
|
43
|
+
return (this._plan = ((this.data || {}).cards || []).map(function(c, i){
|
|
44
|
+
var step = c.step !== undefined ? c.step : per > 0 ? Math.floor(i / per) + 1 : 1;
|
|
45
|
+
var j = seen[step] = (seen[step] || 0) + 1;
|
|
46
|
+
return {c: c, step: step, at: c.at !== undefined ? c.at : +((j - 1) * P.stagger).toFixed(3)};
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
mount(ctx){
|
|
50
|
+
var P = this.props, D = base, self = this, pl = this.plan();
|
|
51
|
+
var vr = this.variant = base.variant(this);
|
|
52
|
+
// count="false"(数えない)が見せ方より強い:数える見せ方なら rise にする
|
|
53
|
+
if (!P.count && (vr === "count" || vr === "flip")){
|
|
54
|
+
console.info('[kpi] count="false", so the variant "' + vr + '" is shown as "rise"');
|
|
55
|
+
vr = this.variant = "rise";
|
|
56
|
+
}
|
|
57
|
+
this.style.display = "block"; this.style.position = "relative";
|
|
58
|
+
var W = this.clientWidth, H = this.clientHeight;
|
|
59
|
+
var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
|
|
60
|
+
// 読み上げ:最後の形(札ごとの名前・最後の値・増減・一言)を 1 文で。作者の aria-label があればそれを使う(上書きしない)
|
|
61
|
+
if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
|
|
62
|
+
this.setAttribute("role", "img");
|
|
63
|
+
if (!this._aria){
|
|
64
|
+
var ja = /^ja\b/i.test(ctx.lang || "ja");
|
|
65
|
+
this.setAttribute("aria-label", pl.map(function(o){
|
|
66
|
+
var c = o.c, dg = c.digits !== undefined ? c.digits : P.digits;
|
|
67
|
+
var more = [c.delta ? (c.delta.dir === "down" ? "↓ " : "↑ ") + (c.delta.text || "") : "", c.note || ""].filter(function(x){ return x.trim(); });
|
|
68
|
+
return (c.label ? c.label + " " : "") + (c.prefix || "") + self.fmt(c.value, dg) + (c.unit || "") + (more.length ? (ja ? "(" + more.join("、") + ")" : " (" + more.join(", ") + ")") : "");
|
|
69
|
+
}).join(ja ? "、" : "; "));
|
|
70
|
+
}
|
|
71
|
+
var n = pl.length || 1, cols = P.cols || Math.min(4, n), rows = Math.ceil(n / cols), gap = 28;
|
|
72
|
+
var cw = (W - gap * (cols - 1)) / cols, ch = (H - gap * (rows - 1)) / rows;
|
|
73
|
+
var size = P.size || Math.max(48, Math.min(84, ch * 0.3, cw * 0.24));
|
|
74
|
+
// 字の幅(base の textWidth:テーマの字で測った幅。mk:mtext で書く字で、*_^ は数えない)
|
|
75
|
+
var est = function(s, sz, mk){ return D.textWidth(s, sz, {font: self, mark: !!mk}); };
|
|
76
|
+
this.cards = pl.map(function(o, i){
|
|
77
|
+
var c = o.c, x = (i % cols) * (cw + gap), y = Math.floor(i / cols) * (ch + gap), cx = x + cw / 2;
|
|
78
|
+
var col = "var(--" + (/^(term|emph|accent2|series-[1-4])$/.test(c.tone || "") ? c.tone : "term") + ")";
|
|
79
|
+
var g = D.el("g", {opacity: 0}, svg);
|
|
80
|
+
D.el("rect", {x: x, y: y, width: cw, height: ch, rx: 12, fill: "var(--term-tint)"}, g);
|
|
81
|
+
D.el("rect", {x: x, y: y, width: cw, height: 7, rx: 3, fill: col}, g);
|
|
82
|
+
// 行の位置:名前・数字・増減・一言を札の高さに配る
|
|
83
|
+
var hasD = !!c.delta, hasN = !!c.note;
|
|
84
|
+
var yl = y + 26 + 26, yn = y + ch * (hasD || hasN ? 0.5 : 0.6) + size * 0.36;
|
|
85
|
+
D.mtext(g, cx, yl, c.label || "", {"text-anchor": "middle", "font-size": 26, "font-weight": 700});
|
|
86
|
+
var dg = c.digits !== undefined ? c.digits : P.digits, usz = Math.round(size * 0.46);
|
|
87
|
+
var finalS = (c.prefix || "") + self.fmt(c.value, dg);
|
|
88
|
+
var nw = est(finalS, size), uw = c.unit ? est(c.unit, usz) + 6 : 0, xr = cx - (nw + uw) / 2 + nw;
|
|
89
|
+
var gn = D.el("g", {}, g); // 数字と単位(rise はこれを拡大する)
|
|
90
|
+
var num = D.el("text", {x: xr.toFixed(1), y: yn.toFixed(1), "text-anchor": "end", "font-size": size, "font-weight": 700, fill: col, style: "font-variant-numeric:tabular-nums"}, gn);
|
|
91
|
+
if (c.unit){ var u = D.el("text", {x: (xr + 6).toFixed(1), y: yn.toFixed(1), "font-size": usz, "font-weight": 700, fill: col}, gn); u.textContent = c.unit; }
|
|
92
|
+
// flip:字ごとの tspan(桁だけがめくれる。y でなく dy で前の字との差を書く:y を書くと字の塊が分かれて右寄せが崩れる)
|
|
93
|
+
var digits = null;
|
|
94
|
+
if (vr === "flip"){
|
|
95
|
+
digits = [...finalS].map(function(ch){
|
|
96
|
+
var ts = D.el("tspan", {}, num); ts.textContent = ch;
|
|
97
|
+
return {ts: ts, d: /[0-9]/.test(ch) ? +ch : null};
|
|
98
|
+
});
|
|
99
|
+
var nd = digits.filter(function(o){ return o.d !== null; }).length, j = 0;
|
|
100
|
+
for (var q = digits.length - 1; q >= 0; q--) if (digits[q].d !== null) digits[q].j = j++, digits[q].n = nd;
|
|
101
|
+
}
|
|
102
|
+
var line = vr === "underline" ? D.el("line", {x1: (xr - nw).toFixed(1), x2: (xr - nw).toFixed(1), y1: (yn + size * 0.14).toFixed(1), y2: (yn + size * 0.14).toFixed(1), stroke: "var(--term)", "stroke-width": 5, "stroke-linecap": "round"}, g) : null;
|
|
103
|
+
var gd = null;
|
|
104
|
+
if (hasD){
|
|
105
|
+
// 増減:▲ / ▼ と一言。良い向き(good、既定は up)なら --term、悪い向きなら --emph
|
|
106
|
+
var up = c.delta.dir !== "down", good = c.delta.good !== undefined ? !!c.delta.good : up;
|
|
107
|
+
var dc = good ? "var(--term)" : "var(--emph)", yd = yn + Math.max(44, size * 0.62), tw = est(c.delta.text || "", 24, true) + 30;
|
|
108
|
+
gd = D.el("g", {opacity: 0}, g);
|
|
109
|
+
var tx = cx - tw / 2;
|
|
110
|
+
D.el("path", {d: up ? "M0,-9L9,7L-9,7Z" : "M0,9L9,-7L-9,-7Z", fill: dc, transform: "translate(" + (tx + 9).toFixed(1) + " " + (yd - 8).toFixed(1) + ")"}, gd);
|
|
111
|
+
D.mtext(gd, tx + 30, yd, c.delta.text || "", {"font-size": 24, fill: dc, "font-weight": 700});
|
|
112
|
+
}
|
|
113
|
+
var note = hasN ? D.mtext(g, cx, y + ch - 22, c.note, {"text-anchor": "middle", "font-size": 24, fill: "var(--muted)"}) : null;
|
|
114
|
+
return {o: o, g: g, gn: gn, num: num, gd: gd, dg: dg, from: c.from || 0, cx: cx, cy: y + ch / 2, xn: xr - nw / 2 + uw / 2, yn: yn, size: size, digits: digits, line: line, lx: xr - nw, lw: nw + uw};
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
fmt(v, dg){
|
|
118
|
+
var s = Math.abs(v).toFixed(dg).split("."), i = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
119
|
+
return (v < 0 ? "−" : "") + i + (s[1] ? "." + s[1] : "");
|
|
120
|
+
}
|
|
121
|
+
duration(k){
|
|
122
|
+
var P = this.props, d = 0;
|
|
123
|
+
this.plan().forEach(function(o){ if (o.step === k) d = Math.max(d, o.at + (P.count ? P.dur : 0.45) + (o.c.delta ? 0.4 : 0)); });
|
|
124
|
+
return d;
|
|
125
|
+
}
|
|
126
|
+
cues(k){
|
|
127
|
+
var c = [];
|
|
128
|
+
this.plan().forEach(function(o){ if (o.step === k && o.at > 0) c.push(o.at); });
|
|
129
|
+
return c.length ? c.sort(function(a, b){ return a - b; }) : null;
|
|
130
|
+
}
|
|
131
|
+
render(k, t, ctx){
|
|
132
|
+
var P = this.props, D = base, self = this;
|
|
133
|
+
// 先の段階を薄く見せる表示(授業の表示):後の段階の札を最後の値で、テーマの --preview-opacity の濃さに(動かさない)
|
|
134
|
+
var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
|
|
135
|
+
this.cards.forEach(function(o){
|
|
136
|
+
var s = o.o.step, at = o.o.at, ahead = preview && s > k;
|
|
137
|
+
var tt = s < k || ahead ? Infinity : s > k ? -1 : t; // この札の段階の中の時刻(-1 = まだ)
|
|
138
|
+
var e = tt < 0 ? 0 : D.prog(tt, at, 0.45);
|
|
139
|
+
o.g.setAttribute("opacity", ahead ? PV.toFixed(3) : e.toFixed(3));
|
|
140
|
+
o.g.setAttribute("transform", "translate(0 " + ((1 - e) * 14).toFixed(2) + ")");
|
|
141
|
+
var vr = self.variant, span = P.count ? P.dur : 0.45;
|
|
142
|
+
if (vr === "count"){
|
|
143
|
+
// 数え上げ:ease-out(初めに速く)。t = Infinity なら最後の値
|
|
144
|
+
var c = tt < 0 ? 0 : tt === Infinity || !P.count ? 1 : D.clamp((tt - at) / P.dur);
|
|
145
|
+
var q = 1 - Math.pow(1 - c, 3), v = D.lerp(o.from, o.o.c.value, q);
|
|
146
|
+
o.num.textContent = (o.o.c.prefix || "") + self.fmt(c >= 1 ? o.o.c.value : v, o.dg);
|
|
147
|
+
} else if (vr === "rise"){
|
|
148
|
+
// 最後の値のまま、0.85 倍から元の大きさへ(札が現れるのと同じ 0.45 秒)
|
|
149
|
+
var s = 0.85 + 0.15 * (tt < 0 ? 0 : D.prog(tt, at, 0.45)), cx = o.xn, cy = o.yn - o.size * 0.35;
|
|
150
|
+
o.num.textContent = (o.o.c.prefix || "") + self.fmt(o.o.c.value, o.dg);
|
|
151
|
+
o.gn.setAttribute("transform", s >= 1 ? "" : "translate(" + cx.toFixed(1) + " " + cy.toFixed(1) + ") scale(" + s.toFixed(4) + ") translate(" + (-cx).toFixed(1) + " " + (-cy).toFixed(1) + ")");
|
|
152
|
+
} else if (vr === "flip"){
|
|
153
|
+
// 札が出たあと(0.45 秒)、右の桁から 1 桁ずつ 0 → 最後の数字へめくれて、上から定位置に止まる(段階の長さの中で終わる)
|
|
154
|
+
var t0 = at + 0.45, len = Math.max(0.1, span - 0.45), prev = 0;
|
|
155
|
+
o.digits.forEach(function(d){
|
|
156
|
+
var off = 0;
|
|
157
|
+
if (d.d !== null){
|
|
158
|
+
var w = len / (d.n + 1), st = t0 + d.j * w, e = tt < 0 ? 0 : tt === Infinity ? 1 : D.clamp((tt - st) / (2 * w));
|
|
159
|
+
var shown = e >= 1 ? d.d : Math.min(d.d, Math.floor(e * (d.d + 1))), frac = (e * (d.d + 1)) % 1;
|
|
160
|
+
d.ts.textContent = String(shown);
|
|
161
|
+
// めくれる桁は上から少し(字の 0.12)下りて止まる
|
|
162
|
+
off = e > 0 && e < 1 ? -(1 - D.prog(frac, 0, 1)) * o.size * 0.12 : 0;
|
|
163
|
+
}
|
|
164
|
+
d.ts.setAttribute("dy", (off - prev).toFixed(1));
|
|
165
|
+
prev = off;
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
// underline:最後の値で出て、数字の下に左から右へ線を引く
|
|
169
|
+
o.num.textContent = (o.o.c.prefix || "") + self.fmt(o.o.c.value, o.dg);
|
|
170
|
+
// 線は段階の長さの中で引き終える(count="false" なら段階は 0.45 秒なので、後半の半分で引く)
|
|
171
|
+
var u0 = Math.min(0.45, span * 0.5), u = tt < 0 ? 0 : D.prog(tt, at + u0, span - u0);
|
|
172
|
+
o.line.setAttribute("x2", (o.lx + o.lw * u).toFixed(1));
|
|
173
|
+
o.line.setAttribute("opacity", u > 0 ? 1 : 0);
|
|
174
|
+
}
|
|
175
|
+
if (o.gd) o.gd.setAttribute("opacity", (tt < 0 ? 0 : D.prog(tt, at + (P.count ? P.dur : 0.45) * 0.85, 0.4)).toFixed(3));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2026 Paweł Kuna
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|