@pie-element/venn-classification 0.1.1-next.6 → 0.1.1-next.8
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/author.js +2 -0
- package/dist/author/index.d.ts +8 -0
- package/dist/author/index.js +3828 -888
- package/dist/author/index.js.map +1 -1
- package/dist/browser/VennClassification-BgmjHIWB.js +3616 -0
- package/dist/browser/VennClassification-BgmjHIWB.js.map +1 -0
- package/dist/browser/author/index.js +2509 -2403
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +2 -2
- package/dist/browser/controller-CmzKcNfc.js +1774 -0
- package/dist/browser/controller-CmzKcNfc.js.map +1 -0
- package/dist/browser/delivery/index.js +86 -28
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/controller/index.d.ts +21 -7
- package/dist/controller/index.js +2394 -49
- package/dist/controller/index.js.map +1 -1
- package/dist/controller/region.d.ts +2 -2
- package/dist/delivery/dnd.d.ts +9 -0
- package/dist/delivery/index.d.ts +2 -20
- package/dist/delivery/index.js +3746 -830
- package/dist/delivery/index.js.map +1 -1
- package/dist/delivery/layout.d.ts +104 -34
- package/dist/delivery/tile-accessible-name.d.ts +13 -1
- package/dist/i18n.d.ts +9 -0
- package/dist/index.iife.js +14 -17
- package/dist/index.js +2 -6804
- package/dist/runtime-support.js +5 -5
- package/dist/runtime-support.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/package.json +3 -4
- package/dist/browser/VennClassification-DCPzzIcj.js +0 -3386
- package/dist/browser/VennClassification-DCPzzIcj.js.map +0 -1
- package/dist/browser/controller-DGuLVZuv.js +0 -249
- package/dist/browser/controller-DGuLVZuv.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,30 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 2-set Venn layout + hit-testing helpers.
|
|
3
3
|
*
|
|
4
|
-
* Geometry lives in SVG viewBox coordinates
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Geometry lives in SVG viewBox coordinates. At the base size one unit is one
|
|
5
|
+
* CSS px when the diagram renders at `DIAGRAM_MAX_WIDTH_PX`; the delivery
|
|
6
|
+
* component scales everything, placed tiles included, with the rendered width.
|
|
7
|
+
* The layout returns per-region descriptors: label, `hitRect` (a rectangle
|
|
8
|
+
* inside the region, used for the 120×120 drop-target minimum from the PRD and
|
|
9
|
+
* to anchor the region's accessible element), `pointInRegion` for pointer
|
|
10
|
+
* hit-testing, and `slots` for placing tiles on a grid fitted to the region's
|
|
11
|
+
* shape.
|
|
9
12
|
*
|
|
10
13
|
* The diagram rectangle IS the universal set: circles live in the upper
|
|
11
14
|
* portion, and the "outside" region is everything inside the rect that
|
|
12
|
-
* doesn't fall inside a circle. Outside-region tiles land in the bottom
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* doesn't fall inside a circle. Outside-region tiles land in the bottom strip
|
|
16
|
+
* (below the circles, still inside the rect). `pointInRegion` for outside is
|
|
17
|
+
* the broader "inside rect, not in any circle" check, so the learner can drop
|
|
18
|
+
* anywhere around the circles naturally.
|
|
19
|
+
*
|
|
20
|
+
* Every slot keeps its whole tile cell, plus `REGION_MARGIN`, inside its
|
|
21
|
+
* region, and no two cells of one region overlap. A region holds a fixed number
|
|
22
|
+
* of cells for a given geometry; `fitGeometry2Set` grows the geometry until each
|
|
23
|
+
* region holds the tiles placed in it.
|
|
19
24
|
*/
|
|
20
25
|
import type { Region, VennCircle, VennModel } from '../types.js';
|
|
21
26
|
import { enumerateRegions, getRegionLabel, regionKey } from '../controller/region.js';
|
|
27
|
+
/** A placed tile's grid cell, in viewBox units. */
|
|
28
|
+
export interface TileCell {
|
|
29
|
+
w: number;
|
|
30
|
+
h: number;
|
|
31
|
+
}
|
|
32
|
+
/** Cell of a text (or math) tile: two lines of label. */
|
|
33
|
+
export declare const TEXT_TILE_CELL: TileCell;
|
|
34
|
+
/** Cell of a tile with an image and a one-line caption. */
|
|
35
|
+
export declare const IMAGE_TILE_CELL: TileCell;
|
|
36
|
+
/** Space between neighbouring cells. */
|
|
37
|
+
export declare const TILE_GAP = 8;
|
|
38
|
+
/** Clearance between a cell and its region's edge; the circle stroke is 2 wide. */
|
|
39
|
+
export declare const REGION_MARGIN = 6;
|
|
40
|
+
/** CSS max width of the diagram. */
|
|
41
|
+
export declare const DIAGRAM_MAX_WIDTH_PX = 720;
|
|
42
|
+
/** Share of the viewport height the diagram may take, so the tray stays in view. */
|
|
43
|
+
export declare const DIAGRAM_MAX_VIEWPORT_HEIGHT = 0.6;
|
|
44
|
+
/** The PRD's minimum tile hit target, in CSS px. */
|
|
45
|
+
export declare const MIN_TILE_PX = 44;
|
|
46
|
+
/**
|
|
47
|
+
* Placed tiles shrink with the diagram down to this factor of their cell,
|
|
48
|
+
* which keeps the cell's shorter side at `MIN_TILE_PX`. A diagram rendered at
|
|
49
|
+
* less than this factor of its viewBox width draws its tiles larger than their
|
|
50
|
+
* cells.
|
|
51
|
+
*/
|
|
52
|
+
export declare function minTileScale(cell: TileCell): number;
|
|
22
53
|
export interface DiagramGeometry {
|
|
23
54
|
width: number;
|
|
24
55
|
height: number;
|
|
56
|
+
/**
|
|
57
|
+
* Size of the diagram chrome (labels, strokes, margins) relative to the base
|
|
58
|
+
* geometry. Tile cells do not grow with it.
|
|
59
|
+
*/
|
|
60
|
+
scale: number;
|
|
25
61
|
/** Vertical gap between the bottom of the circles and the outside landing strip. */
|
|
26
62
|
outsideGap: number;
|
|
27
|
-
/**
|
|
63
|
+
/** Height reserved below the circles for outside tiles. */
|
|
28
64
|
outsideStripHeight: number;
|
|
29
65
|
circles: Array<{
|
|
30
66
|
cx: number;
|
|
@@ -32,27 +68,37 @@ export interface DiagramGeometry {
|
|
|
32
68
|
r: number;
|
|
33
69
|
}>;
|
|
34
70
|
}
|
|
71
|
+
export interface Point {
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
}
|
|
75
|
+
export interface Rect {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
w: number;
|
|
79
|
+
h: number;
|
|
80
|
+
}
|
|
35
81
|
export interface RegionLayout {
|
|
36
82
|
region: Region;
|
|
37
83
|
key: string;
|
|
38
84
|
label: string;
|
|
39
|
-
/**
|
|
40
|
-
hitRect:
|
|
41
|
-
x: number;
|
|
42
|
-
y: number;
|
|
43
|
-
w: number;
|
|
44
|
-
h: number;
|
|
45
|
-
};
|
|
85
|
+
/** A rectangle inside the region, in viewBox coords: the guaranteed drop target. */
|
|
86
|
+
hitRect: Rect;
|
|
46
87
|
/** True iff `(x, y)` falls in this region, given the geometry. */
|
|
47
88
|
pointInRegion: (x: number, y: number) => boolean;
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
89
|
+
/** How many cells the region holds. */
|
|
90
|
+
capacity: number;
|
|
91
|
+
/**
|
|
92
|
+
* Cell centers for `count` tiles in this region, in reading order. Past
|
|
93
|
+
* `capacity` (a geometry `fitGeometry2Set` did not size for the count) the
|
|
94
|
+
* extra tiles share the last cell, or the middle of `hitRect` in a region
|
|
95
|
+
* too small for one.
|
|
96
|
+
*/
|
|
97
|
+
slots: (count: number) => Point[];
|
|
53
98
|
}
|
|
54
99
|
export interface DiagramLayout {
|
|
55
100
|
geometry: DiagramGeometry;
|
|
101
|
+
cell: TileCell;
|
|
56
102
|
regions: RegionLayout[];
|
|
57
103
|
regionByKey: Record<string, RegionLayout>;
|
|
58
104
|
/**
|
|
@@ -62,21 +108,45 @@ export interface DiagramLayout {
|
|
|
62
108
|
outsideStripTop: number;
|
|
63
109
|
}
|
|
64
110
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* overlap ≈ 120 × 340
|
|
72
|
-
* outside = 900 × 140 strip at the bottom of the rect
|
|
111
|
+
* The 2-set geometry at `scale` times the base size, with an outside strip at
|
|
112
|
+
* least `outsideStripHeight` tall. The base holds a 120×120 CSS px square in
|
|
113
|
+
* each region at the 720 px max width:
|
|
114
|
+
* left-only / right-only ≈ 182 × 182 around the circle's center line
|
|
115
|
+
* overlap ≈ 235 × 235
|
|
116
|
+
* outside = 720 × 136 strip at the bottom of the rect
|
|
73
117
|
*/
|
|
118
|
+
export declare function geometry2Set(scale?: number, outsideStripHeight?: number): DiagramGeometry;
|
|
119
|
+
/** The base 2-set geometry. */
|
|
74
120
|
export declare function defaultGeometry2Set(): DiagramGeometry;
|
|
121
|
+
/**
|
|
122
|
+
* The diagram's CSS width: `DIAGRAM_MAX_WIDTH_PX`, or less where the height
|
|
123
|
+
* would pass `DIAGRAM_MAX_VIEWPORT_HEIGHT` of the viewport. It never drops
|
|
124
|
+
* below the width that draws `cell` tiles at `minTileScale`, where each tile
|
|
125
|
+
* exactly fills its cell at the 44 px minimum; a crowded region can push that
|
|
126
|
+
* past the max width. Only a narrower container renders it smaller, and there
|
|
127
|
+
* tiles outgrow their cells. The aspect ratio sets the height, so the box
|
|
128
|
+
* matches the viewBox: tile positions and pointer hits map onto the box, and a
|
|
129
|
+
* letterboxed drawing would leave them off the circles.
|
|
130
|
+
*/
|
|
131
|
+
export declare function diagramCssWidth(geometry: DiagramGeometry, cell: TileCell): string;
|
|
132
|
+
/**
|
|
133
|
+
* Scale for placed tiles when the diagram renders `renderedWidth` CSS px wide:
|
|
134
|
+
* each tile stays the size of its cell, down to `minTileScale(cell)`.
|
|
135
|
+
* Unmeasured (0) renders at full size.
|
|
136
|
+
*/
|
|
137
|
+
export declare function placedTileScale(renderedWidth: number, geometry: DiagramGeometry, cell: TileCell): number;
|
|
138
|
+
/**
|
|
139
|
+
* The smallest geometry holding `counts[key]` tiles of `cell` in each region:
|
|
140
|
+
* the diagram grows in `SCALE_STEP`s while a circle region is short of cells,
|
|
141
|
+
* and the outside strip adds rows for the outside tiles. Tile cells keep their
|
|
142
|
+
* size, so a grown diagram renders them smaller at the same CSS width.
|
|
143
|
+
*/
|
|
144
|
+
export declare function fitGeometry2Set(counts: Record<string, number>, cell?: TileCell): DiagramGeometry;
|
|
75
145
|
/**
|
|
76
146
|
* Build the 2-set layout for a concrete model (uses model circle labels to
|
|
77
147
|
* compose accessible names, and `model.regionLabels` for overrides).
|
|
78
148
|
*/
|
|
79
|
-
export declare function buildLayout2Set(model: Pick<VennModel, 'circles' | 'regionLabels'>, geometry?: DiagramGeometry): DiagramLayout;
|
|
149
|
+
export declare function buildLayout2Set(model: Pick<VennModel, 'circles' | 'regionLabels' | 'language'>, geometry?: DiagramGeometry, cell?: TileCell): DiagramLayout;
|
|
80
150
|
/**
|
|
81
151
|
* Resolve a pointer hit to its region. `pointer` is in viewBox coords.
|
|
82
152
|
* Returns the matched region's descriptor, or `null` for "no region".
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { VennTile } from '../types.js';
|
|
2
2
|
export declare function stripHtml(s: string): string;
|
|
3
3
|
/** Accessible name for a tile (button aria-label, live-region announcements). */
|
|
4
|
-
export declare function tileAccessibleName(tile: Pick<VennTile, 'label' | 'imageUrl' | 'imageAlt'
|
|
4
|
+
export declare function tileAccessibleName(tile: Pick<VennTile, 'label' | 'imageUrl' | 'imageAlt'>, language?: string): string;
|
|
5
|
+
export type TileVerdict = 'correct' | 'incorrect' | 'unanswered';
|
|
6
|
+
/**
|
|
7
|
+
* A tile button's accessible name: what it is, where it sits, and in `evaluate`
|
|
8
|
+
* mode whether that is right - "Crocodile, in Reptile and Egg-layer, incorrect".
|
|
9
|
+
* The placed tiles render in a layer apart from the region anchors, and the
|
|
10
|
+
* verdict badge is an `aria-hidden` icon, so the name is where assistive
|
|
11
|
+
* technology learns both.
|
|
12
|
+
*
|
|
13
|
+
* `regionLabel` is `null` for a tile in the tray. An unplaced tile's verdict is
|
|
14
|
+
* `unanswered`, which "not placed" already says.
|
|
15
|
+
*/
|
|
16
|
+
export declare function tileStatusName(tile: Pick<VennTile, 'label' | 'imageUrl' | 'imageAlt'>, regionLabel: string | null, verdict?: TileVerdict | null, language?: string): string;
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A learner-facing string in `language`, the model's `language`. i18next falls
|
|
3
|
+
* back to English for a language or key it does not hold. Values are not
|
|
4
|
+
* HTML-escaped: they are circle and tile names, and Svelte escapes what it
|
|
5
|
+
* renders.
|
|
6
|
+
*/
|
|
7
|
+
export declare function t(key: string, language?: string, values?: Record<string, unknown>): string;
|
|
8
|
+
/** A string shared across elements, such as the correct-answer toggle's labels. */
|
|
9
|
+
export declare function tCommon(key: string, language?: string): string;
|