@esmirnov.ai/sperm-lab 0.4.2 → 0.4.3

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.
@@ -418,7 +418,7 @@ export function SpermLab({ seed = 42, count = 48, initialFactors, initialFactor,
418
418
  return _jsxs("div", { className: "sl-factor", children: [_jsxs("div", { className: "sl-factor-row", children: [_jsx("label", { htmlFor: rangeId, children: shortLabels[id] }), _jsx("input", { id: rangeId, "data-factor": id, type: "range", min: "0", max: "100", step: "1", value: value, "aria-label": shortLabels[id] === factor.title ? factor.title : `${shortLabels[id]}: ${factor.title}`, "aria-valuetext": `${value} of 100, relative illustrative setting`, style: { "--sl-progress": `${value}%` }, onChange: event => changeFactor(id, Number(event.target.value) / 100) }), _jsx("output", { htmlFor: rangeId, children: value })] }), _jsxs("details", { className: "sl-factor-help", children: [_jsxs("summary", { children: [_jsxs("span", { children: ["About ", shortLabels[id].toLowerCase()] }), _jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: _jsx("path", { d: "m5 6 3 3 3-3" }) })] }), _jsx("p", { children: factor.summary }), _jsx("p", { children: factor.mechanism }), _jsx("p", { className: "sl-evidence", children: factor.evidence }), _jsx("p", { children: factor.limits }), _jsx("p", { className: "sl-help-timescale", children: factor.timescale }), _jsx("ul", { children: factor.sources.map(source => _jsx("li", { children: _jsx("a", { href: source.url, target: "_blank", rel: "noopener noreferrer", children: source.title }) }, source.url)) })] })] }, id);
419
419
  })] }, group.title)) });
420
420
  }
421
- return _jsxs("div", { ref: root, className: `sperm-lab sl-lab sl-lab-v3 ${className}`.trim(), style: style, children: [_jsxs("div", { className: "sl-intro-line", children: [_jsxs("p", { children: [_jsx("strong", { children: "Change the factors. Watch one sample." }), " Each slider acts independently."] }), _jsx("span", { children: "All 12 settings use relative scales." })] }), _jsxs("div", { className: "sl-workbench", children: [controlColumn("left"), _jsxs("section", { className: "sl-field", "aria-label": "Live sperm sample", children: [_jsxs("div", { className: "sl-sample-bar", children: [_jsxs("div", { children: [_jsx("h2", { children: prepared ? "Prepared defect examples" : defaults.teachingPopulation ? "Illustrative sample" : "Live sample" }), _jsxs("span", { children: [metrics.total, " fictional cells"] })] }), _jsxs("div", { className: "sl-actions", children: [_jsx("button", { className: "sl-explore", type: "button", "aria-pressed": popupOpen, "aria-controls": `${prefix}-sample`, onClick: explore, children: "Explore" }), _jsx("button", { type: "button", "aria-pressed": paused, onClick: () => setPaused(value => !value), children: paused ? "Resume" : "Pause" }), _jsx("button", { type: "button", onClick: reset, children: "Reset sample" })] })] }), _jsxs("div", { className: "sl-concentration", children: [_jsx("span", { id: `${prefix}-concentration`, children: "Concentration" }), _jsxs("output", { "data-concentration": metrics.total, "aria-labelledby": `${prefix}-concentration`, children: [metrics.total, " cells / model field"] }), _jsx("small", { children: "Synthetic model count. No clinical units." })] }), defaults.teachingPopulation && !prepared && _jsx("p", { className: "sl-teaching-population", children: "The teaching sample includes common defect examples. Counts do not show their frequency in people." }), unavailable && _jsx("p", { role: "status", children: "Canvas is unavailable. The sample counts, cell inspector, and factor explanations remain available." }), _jsxs("div", { id: `${prefix}-sample`, className: "sl-canvas-wrap", "data-popup": popupOpen && Boolean(selected), style: { "--sl-popup-min-height": `${popupHeight}px` }, children: [_jsx("canvas", { ref: canvas, tabIndex: 0, role: "group", "aria-label": "Interactive sperm sample. Use Explore to follow a swimmer. Drag to stir. Click a cell for details. Arrow keys create currents. Enter selects the next cell and opens its details. Escape closes details. Space pauses.", "aria-describedby": `${prefix}-help`, onPointerDown: pointerDown, onPointerMove: pointerMove, onPointerUp: pointerUp, onPointerCancel: () => actions.current.release(), onLostPointerCapture: () => { pointer.current = null; }, onKeyDown: keyboard, onContextMenu: event => event.preventDefault(), children: "The sample needs canvas support. Use the cell inspector and model counts for a text alternative." }), popupOpen && selected && _jsxs(_Fragment, { children: [_jsx("svg", { className: "sl-popup-connector", "aria-hidden": "true", children: _jsx("line", { ref: popupConnector }) }), _jsxs("div", { ref: popup, className: "sl-cell-popup", role: "dialog", "aria-modal": "false", "aria-labelledby": `${prefix}-popup-title`, "data-cell-popup": "true", "data-cell-id": selected.id, children: [_jsxs("header", { children: [_jsxs("h3", { id: `${prefix}-popup-title`, children: ["Cell ", selected.id + 1] }), _jsx("button", { ref: popupClose, className: "sl-popup-close", type: "button", "aria-label": "Close cell details", onClick: () => { setPopupOpen(false); canvas.current?.focus({ preventScroll: true }); }, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "m5 5 10 10M15 5 5 15" }) }) })] }), _jsx(CellPopupDetails, { cell: selected, dna: dna }), _jsx("button", { className: "sl-popup-anatomy", type: "button", onClick: () => { setPopupOpen(false); requestAnimationFrame(() => inspector.current?.scrollIntoView({ block: "start", behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" })); }, children: "Full anatomy" })] })] })] }), _jsx("p", { id: `${prefix}-help`, className: "sl-canvas-help", children: "Use Explore to follow a swimmer. Click or tap another cell to switch. Drag to stir the sample." }), _jsxs("div", { className: "sl-sample-tools", children: [_jsx("button", { type: "button", onClick: () => current(.3, .1), disabled: paused, children: "Create a current" }), _jsx("button", { type: "button", onClick: () => nextCell(), children: "Next swimmer" }), _jsx("button", { type: "button", onClick: prepareExamples, children: "Inspect defect examples" })] }), _jsxs("div", { className: "sl-display", children: [_jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: dna, onChange: event => setDna(event.target.checked) }), "DNA overlay"] }), _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: trails, onChange: event => setTrails(event.target.checked) }), "Trails"] }), _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: slowMotion, onChange: event => setSlowMotion(event.target.checked) }), "Slow motion"] })] }), _jsx("p", { className: "sl-overlay-note", children: "Red marks illustrated abnormalities. Disconnected red pieces inside the nucleus show schematic DNA fragmentation. The overlay is not ordinary microscopy." }), _jsx("p", { className: "sl-model-note", children: "Sliders prepare an illustrative later cohort. Counts do not predict personal fertility." }), prepared && _jsxs("div", { className: "sl-prepared-note", children: [_jsx("p", { children: "These examples contain head, tail, midpiece, and DNA traits. They do not show the effects of a specific exposure." }), _jsx("button", { type: "button", onClick: restore, children: "Return to current settings" })] })] }), controlColumn("right"), _jsxs("section", { className: "sl-readouts", "aria-labelledby": `${prefix}-counts-title`, children: [_jsx("h2", { id: `${prefix}-counts-title`, children: "In this sample" }), _jsx("dl", { children: [
421
+ return _jsxs("div", { ref: root, className: `sperm-lab sl-lab sl-lab-v3 ${className}`.trim(), style: style, children: [_jsxs("div", { className: "sl-intro-line", children: [_jsxs("p", { children: [_jsx("strong", { children: "Change the factors. Watch one sample." }), " Each slider acts independently."] }), _jsx("span", { children: "All 12 settings use relative scales." })] }), _jsxs("div", { className: "sl-workbench", children: [_jsxs("section", { className: "sl-field", "aria-label": "Live sperm sample", children: [_jsxs("div", { className: "sl-sample-bar", children: [_jsxs("div", { children: [_jsx("h2", { children: prepared ? "Prepared defect examples" : defaults.teachingPopulation ? "Illustrative sample" : "Live sample" }), _jsxs("span", { children: [metrics.total, " fictional cells"] })] }), _jsxs("div", { className: "sl-actions", children: [_jsx("button", { className: "sl-explore", type: "button", "aria-pressed": popupOpen, "aria-controls": `${prefix}-sample`, onClick: explore, children: "Explore" }), _jsx("button", { type: "button", "aria-pressed": paused, onClick: () => setPaused(value => !value), children: paused ? "Resume" : "Pause" }), _jsx("button", { type: "button", onClick: reset, children: "Reset sample" })] })] }), _jsxs("div", { className: "sl-concentration", children: [_jsx("span", { id: `${prefix}-concentration`, children: "Concentration" }), _jsxs("output", { "data-concentration": metrics.total, "aria-labelledby": `${prefix}-concentration`, children: [metrics.total, " cells / model field"] }), _jsx("small", { children: "Synthetic model count. No clinical units." })] }), unavailable && _jsx("p", { role: "status", children: "Canvas is unavailable. The sample counts, cell inspector, and factor explanations remain available." }), _jsxs("div", { id: `${prefix}-sample`, className: "sl-canvas-wrap", "data-popup": popupOpen && Boolean(selected), style: { "--sl-popup-min-height": `${popupHeight}px` }, children: [_jsx("canvas", { ref: canvas, tabIndex: 0, role: "group", "aria-label": "Interactive sperm sample. Use Explore to follow a swimmer. Drag to stir. Click a cell for details. Arrow keys create currents. Enter selects the next cell and opens its details. Escape closes details. Space pauses.", "aria-describedby": `${prefix}-help`, onPointerDown: pointerDown, onPointerMove: pointerMove, onPointerUp: pointerUp, onPointerCancel: () => actions.current.release(), onLostPointerCapture: () => { pointer.current = null; }, onKeyDown: keyboard, onContextMenu: event => event.preventDefault(), children: "The sample needs canvas support. Use the cell inspector and model counts for a text alternative." }), popupOpen && selected && _jsxs(_Fragment, { children: [_jsx("svg", { className: "sl-popup-connector", "aria-hidden": "true", children: _jsx("line", { ref: popupConnector }) }), _jsxs("div", { ref: popup, className: "sl-cell-popup", role: "dialog", "aria-modal": "false", "aria-labelledby": `${prefix}-popup-title`, "data-cell-popup": "true", "data-cell-id": selected.id, children: [_jsxs("header", { children: [_jsxs("h3", { id: `${prefix}-popup-title`, children: ["Cell ", selected.id + 1] }), _jsx("button", { ref: popupClose, className: "sl-popup-close", type: "button", "aria-label": "Close cell details", onClick: () => { setPopupOpen(false); canvas.current?.focus({ preventScroll: true }); }, children: _jsx("svg", { viewBox: "0 0 20 20", "aria-hidden": "true", children: _jsx("path", { d: "m5 5 10 10M15 5 5 15" }) }) })] }), _jsx(CellPopupDetails, { cell: selected, dna: dna }), _jsx("button", { className: "sl-popup-anatomy", type: "button", onClick: () => { setPopupOpen(false); requestAnimationFrame(() => inspector.current?.scrollIntoView({ block: "start", behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" })); }, children: "Full anatomy" })] })] })] }), _jsxs("div", { className: "sl-sample-tools", children: [_jsx("button", { type: "button", onClick: () => current(.3, .1), disabled: paused, children: "Create a current" }), _jsx("button", { type: "button", onClick: () => nextCell(), children: "Next swimmer" }), _jsx("button", { type: "button", onClick: prepareExamples, children: "Inspect defect examples" }), prepared && _jsx("button", { type: "button", onClick: restore, children: "Return to current settings" })] }), _jsxs("div", { className: "sl-display", children: [_jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: dna, onChange: event => setDna(event.target.checked) }), "DNA overlay"] }), _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: trails, onChange: event => setTrails(event.target.checked) }), "Trails"] }), _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: slowMotion, onChange: event => setSlowMotion(event.target.checked) }), "Slow motion"] })] })] }), controlColumn("left"), controlColumn("right"), _jsxs("div", { className: "sl-sample-notes", children: [_jsx("p", { id: `${prefix}-help`, className: "sl-canvas-help", children: "Use Explore to follow a swimmer. Click or tap another cell to switch. Drag to stir the sample." }), defaults.teachingPopulation && !prepared && _jsx("p", { className: "sl-teaching-population", children: "The teaching sample includes common defect examples. Counts do not show their frequency in people." }), _jsx("p", { className: "sl-overlay-note", children: "Red marks illustrated abnormalities. Disconnected red pieces inside the nucleus show schematic DNA fragmentation. The overlay is not ordinary microscopy." }), _jsx("p", { className: "sl-model-note", children: "Sliders prepare an illustrative later cohort. Counts do not predict personal fertility." }), prepared && _jsx("div", { className: "sl-prepared-note", children: _jsx("p", { children: "These examples contain head, tail, midpiece, and DNA traits. They do not show the effects of a specific exposure." }) })] }), _jsxs("section", { className: "sl-readouts", "aria-labelledby": `${prefix}-counts-title`, children: [_jsx("h2", { id: `${prefix}-counts-title`, children: "In this sample" }), _jsx("dl", { children: [
422
422
  ["Cells", metrics.total], ["Active motion", metrics.motile], ["Forward", metrics.progressive], ["Slow", metrics.slow],
423
423
  ["Nonprogressive", metrics.nonprogressive], ["Still", metrics.immotile], ["Alive", metrics.alive],
424
424
  ].map(([label, value]) => _jsxs("div", { children: [_jsx("dt", { children: label }), _jsx("dd", { children: value })] }, label)) })] }), _jsxs("section", { className: "sl-catalog", "aria-labelledby": `${prefix}-catalog-title`, children: [_jsxs("header", { children: [_jsx("h2", { id: `${prefix}-catalog-title`, children: "Common examples" }), _jsx("p", { children: "These curated examples explain separate traits. Their frequency is not clinical prevalence. Select an example to inspect its cell." })] }), _jsx("div", { className: "sl-defect-catalog", children: DEFECT_CATALOG.map(defect => {
package/dist/styles.css CHANGED
@@ -24,7 +24,7 @@
24
24
  .sl-intro-line p { margin: 0; font-size: 13px; }
25
25
  .sl-intro-line strong { font-weight: 600; }
26
26
  .sl-intro-line > span { font-size: 11px; opacity: .75; }
27
- .sl-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); grid-template-areas: "left field right" "left readouts right" "catalog catalog catalog" "inspector inspector inspector"; align-items: start; gap: 20px 24px; }
27
+ .sl-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); grid-template-areas: "left field right" "left notes right" "left readouts right" "catalog catalog catalog" "inspector inspector inspector"; align-items: start; gap: 20px 24px; }
28
28
  .sl-controls { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
29
29
  .sl-controls-left { grid-area: left; }
30
30
  .sl-controls-right { grid-area: right; }
@@ -53,6 +53,8 @@
53
53
  .sl-factor-help ul { margin: 8px 0 0; padding: 0; list-style: none; }
54
54
  .sl-factor-help a { display: inline-flex; align-items: center; min-height: 32px; font-size: 10px; line-height: 1.5; color: var(--sl-accent); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
55
55
  .sl-field { grid-area: field; min-width: 0; }
56
+ .sl-sample-notes { grid-area: notes; min-width: 0; }
57
+ .sl-sample-notes > :first-child { margin-top: 0; }
56
58
  .sl-sample-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; padding-bottom: 9px; border-bottom: 1px solid var(--sl-rule); }
57
59
  .sl-sample-bar > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
58
60
  .sl-sample-bar h2 { margin: 0; font-size: 14px; line-height: 1.5; font-weight: 600; }
@@ -168,14 +170,13 @@
168
170
  .sl-mechanisms li small { margin-top: 5px; color: var(--sl-accent); font-size: 10px; }
169
171
  .sl-prepared-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--sl-rule); }
170
172
  .sl-prepared-note p { margin: 0; font-size: 11px; }
171
- .sl-prepared-note button { margin-top: 3px; padding-inline: 0; border: 0; text-decoration: underline; text-underline-offset: 3px; }
172
173
  @container sperm-lab (max-width: 1000px) {
173
174
  .sl-workbench { grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr); gap: 18px 18px; }
174
175
  .sl-canvas-wrap { min-height: 280px; }
175
176
  .sl-defect-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
176
177
  }
177
178
  @container sperm-lab (max-width: 800px) {
178
- .sl-workbench { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "field field" "readouts readouts" "catalog catalog" "inspector inspector" "left right"; gap: 22px; }
179
+ .sl-workbench { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "field field" "left right" "readouts readouts" "notes notes" "catalog catalog" "inspector inspector"; gap: 22px; }
179
180
  .sl-defect-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
180
181
  .sl-controls { padding-top: 18px; border-top: 1px solid var(--sl-rule); }
181
182
  .sl-factor-row input[type="range"] { min-height: 44px; }
@@ -185,7 +186,7 @@
185
186
  .sl-inspector-content { gap: 18px; }
186
187
  }
187
188
  @container sperm-lab (max-width: 560px) {
188
- .sl-workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "field" "readouts" "catalog" "inspector" "left" "right"; }
189
+ .sl-workbench { grid-template-columns: minmax(0, 1fr); grid-template-areas: "field" "left" "right" "readouts" "notes" "catalog" "inspector"; }
189
190
  .sl-defect-catalog { grid-template-columns: minmax(0, 1fr); }
190
191
  .sl-canvas-wrap { min-height: 270px; max-height: 360px; aspect-ratio: 1.15; }
191
192
  .sl-factor-help summary { min-height: 38px; font-size: 11px; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esmirnov.ai/sperm-lab",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "An interactive sperm education lab with 12 factors, a headless TypeScript simulation, and an embeddable React component.",
5
5
  "type": "module",
6
6
  "license": "MIT",