hpo-react-visualizer 0.0.1 → 0.0.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.
package/dist/index.d.cts CHANGED
@@ -5,10 +5,16 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  * Supported organ identifiers
6
6
  */
7
7
  type OrganId = "head" | "eye" | "ear" | "heart" | "lung" | "digestive" | "kidney" | "integument" | "constitutional" | "limbs" | "nervous" | "breast" | "thoracicCavity" | "voice" | "metabolism" | "cell" | "endocrine" | "neoplasm" | "immune" | "muscle" | "growth" | "prenatal" | "blood";
8
+ /**
9
+ * HPO official category labels
10
+ * @see https://hpo.jax.org/
11
+ */
12
+ type HPOLabel = "others" | "Growth abnormality" | "Abnormality of the genitourinary system" | "Abnormality of the immune system" | "Abnormality of the digestive system" | "Abnormality of metabolism/homeostasis" | "Abnormality of head or neck" | "Abnormality of the musculoskeletal system" | "Abnormality of the nervous system" | "Abnormality of the respiratory system" | "Abnormality of the eye" | "Abnormality of the cardiovascular system" | "Abnormality of the ear" | "Abnormality of prenatal development or birth" | "Abnormality of the integument" | "Abnormality of the breast" | "Abnormality of the endocrine system" | "Abnormality of blood and blood-forming tissues" | "Abnormality of limbs" | "Abnormality of the voice" | "Constitutional symptom" | "Neoplasm" | "Abnormal cellular phenotype" | "Abnormality of the thoracic cavity";
8
13
  /**
9
14
  * Color scheme for each organ.
10
15
  */
11
16
  type ColorName = "blue" | "yellow" | "gray";
17
+ type ColorScheme = ColorName;
12
18
  /**
13
19
  * Color step
14
20
  */
@@ -129,6 +135,10 @@ interface HpoVisualizerProps {
129
135
  className?: string;
130
136
  /** Additional inline styles */
131
137
  style?: CSSProperties;
138
+ /** Maximum zoom level (default: 5 = 500%) */
139
+ maxZoom?: number;
140
+ /** Enable zoom with mouse wheel (default: true) */
141
+ wheelZoom?: boolean;
132
142
  }
133
143
 
134
144
  /**
@@ -143,6 +153,19 @@ declare const ORGAN_NAMES_EN: Record<OrganId, string>;
143
153
  * Display names for organs (Korean)
144
154
  */
145
155
  declare const ORGAN_NAMES_KO: Record<OrganId, string>;
156
+ /**
157
+ * All HPO category labels
158
+ */
159
+ declare const HPO_LABELS: readonly HPOLabel[];
160
+ /**
161
+ * Mapping from HPO label to OrganId
162
+ * Note: "others" has no corresponding OrganId
163
+ */
164
+ declare const HPO_LABEL_TO_ORGAN: Record<Exclude<HPOLabel, "others">, OrganId>;
165
+ /**
166
+ * Mapping from OrganId to HPO label
167
+ */
168
+ declare const ORGAN_TO_HPO_LABEL: Record<OrganId, Exclude<HPOLabel, "others">>;
146
169
  /**
147
170
  * Color palettes for each color scheme.
148
171
  * Based on Tailwind CSS color palette.
@@ -162,8 +185,12 @@ declare const ANIMATION_DURATION_MS = 150;
162
185
  * - Click to select/deselect organs
163
186
  * - Hover effects work independently even when an organ is selected
164
187
  * - Exposes hover and selection state via callbacks
188
+ * - Zoom and pan support with mouse wheel and drag
165
189
  */
166
- declare function HpoVisualizer({ organs, visibleOrgans, hoveredOrgan: controlledHovered, selectedOrgan: controlledSelected, onHover, onSelect, colorPalette: inputColorPalette, width, height, className, style, }: HpoVisualizerProps): react_jsx_runtime.JSX.Element;
190
+ declare function HpoVisualizer({ organs, visibleOrgans, hoveredOrgan: controlledHovered, selectedOrgan: controlledSelected, onHover, onSelect, colorPalette: inputColorPalette, width, height, className, style, maxZoom, wheelZoom, }: HpoVisualizerProps): react_jsx_runtime.JSX.Element;
191
+
192
+ declare const createUniformOrganColorSchemes: (organIds: readonly OrganId[], scheme: ColorScheme) => Record<OrganId, ColorScheme>;
193
+ declare const createOrganOutlineSet: (organIds: readonly OrganId[], enabled: boolean) => Set<OrganId>;
167
194
 
168
195
  interface OrganSvgWrapperProps {
169
196
  /** Organ identifier */
@@ -182,13 +209,13 @@ interface OrganSvgWrapperProps {
182
209
  onMouseLeave: () => void;
183
210
  /** Click handler */
184
211
  onClick: () => void;
185
- /** X position in parent coordinate system */
212
+ /** X position in parent viewBox coordinate system */
186
213
  x: number;
187
- /** Y position in parent coordinate system */
214
+ /** Y position in parent viewBox coordinate system */
188
215
  y: number;
189
- /** Width of the organ SVG viewport */
216
+ /** Width of the organ SVG viewport in viewBox units */
190
217
  width: number;
191
- /** Height of the organ SVG viewport */
218
+ /** Height of the organ SVG viewport in viewBox units */
192
219
  height: number;
193
220
  /** ViewBox for the organ SVG (local coordinate system) */
194
221
  viewBox: string;
@@ -237,8 +264,9 @@ interface UseOrganInteractionResult {
237
264
  * - Click on organ sets selectedOrgan and calls onSelect
238
265
  * - Click on already selected organ deselects it
239
266
  * - Click on different organ changes selection
267
+ * - Deselect keeps hover state when still over the organ
240
268
  * - Hover effects work independently even when an organ is selected
241
269
  */
242
270
  declare function useOrganInteraction(options?: UseOrganInteractionOptions): UseOrganInteractionResult;
243
271
 
244
- export { ANIMATION_DURATION_MS, type ColorScale as ColorPalette, type ColorName as ColorScheme, DEFAULT_COLOR_PALETTE, HpoVisualizer, type HpoVisualizerProps, ORGAN_COMPONENTS, ORGAN_IDS, ORGAN_NAMES_EN, ORGAN_NAMES_KO, type OrganConfig, type OrganId, type OrganInteractionHandlers, type OrganInteractionState, type OrganStyle, OrganSvg, type OrganSvgProps, type OrganSvgWrapperProps, type UseOrganInteractionOptions, type UseOrganInteractionResult, useOrganInteraction };
272
+ export { ANIMATION_DURATION_MS, type ColorScale as ColorPalette, type ColorName as ColorScheme, DEFAULT_COLOR_PALETTE, type HPOLabel, HPO_LABELS, HPO_LABEL_TO_ORGAN, HpoVisualizer, type HpoVisualizerProps, ORGAN_COMPONENTS, ORGAN_IDS, ORGAN_NAMES_EN, ORGAN_NAMES_KO, ORGAN_TO_HPO_LABEL, type OrganConfig, type OrganId, type OrganInteractionHandlers, type OrganInteractionState, type OrganStyle, OrganSvg, type OrganSvgProps, type OrganSvgWrapperProps, type UseOrganInteractionOptions, type UseOrganInteractionResult, createOrganOutlineSet, createUniformOrganColorSchemes, useOrganInteraction };
package/dist/index.d.ts CHANGED
@@ -5,10 +5,16 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  * Supported organ identifiers
6
6
  */
7
7
  type OrganId = "head" | "eye" | "ear" | "heart" | "lung" | "digestive" | "kidney" | "integument" | "constitutional" | "limbs" | "nervous" | "breast" | "thoracicCavity" | "voice" | "metabolism" | "cell" | "endocrine" | "neoplasm" | "immune" | "muscle" | "growth" | "prenatal" | "blood";
8
+ /**
9
+ * HPO official category labels
10
+ * @see https://hpo.jax.org/
11
+ */
12
+ type HPOLabel = "others" | "Growth abnormality" | "Abnormality of the genitourinary system" | "Abnormality of the immune system" | "Abnormality of the digestive system" | "Abnormality of metabolism/homeostasis" | "Abnormality of head or neck" | "Abnormality of the musculoskeletal system" | "Abnormality of the nervous system" | "Abnormality of the respiratory system" | "Abnormality of the eye" | "Abnormality of the cardiovascular system" | "Abnormality of the ear" | "Abnormality of prenatal development or birth" | "Abnormality of the integument" | "Abnormality of the breast" | "Abnormality of the endocrine system" | "Abnormality of blood and blood-forming tissues" | "Abnormality of limbs" | "Abnormality of the voice" | "Constitutional symptom" | "Neoplasm" | "Abnormal cellular phenotype" | "Abnormality of the thoracic cavity";
8
13
  /**
9
14
  * Color scheme for each organ.
10
15
  */
11
16
  type ColorName = "blue" | "yellow" | "gray";
17
+ type ColorScheme = ColorName;
12
18
  /**
13
19
  * Color step
14
20
  */
@@ -129,6 +135,10 @@ interface HpoVisualizerProps {
129
135
  className?: string;
130
136
  /** Additional inline styles */
131
137
  style?: CSSProperties;
138
+ /** Maximum zoom level (default: 5 = 500%) */
139
+ maxZoom?: number;
140
+ /** Enable zoom with mouse wheel (default: true) */
141
+ wheelZoom?: boolean;
132
142
  }
133
143
 
134
144
  /**
@@ -143,6 +153,19 @@ declare const ORGAN_NAMES_EN: Record<OrganId, string>;
143
153
  * Display names for organs (Korean)
144
154
  */
145
155
  declare const ORGAN_NAMES_KO: Record<OrganId, string>;
156
+ /**
157
+ * All HPO category labels
158
+ */
159
+ declare const HPO_LABELS: readonly HPOLabel[];
160
+ /**
161
+ * Mapping from HPO label to OrganId
162
+ * Note: "others" has no corresponding OrganId
163
+ */
164
+ declare const HPO_LABEL_TO_ORGAN: Record<Exclude<HPOLabel, "others">, OrganId>;
165
+ /**
166
+ * Mapping from OrganId to HPO label
167
+ */
168
+ declare const ORGAN_TO_HPO_LABEL: Record<OrganId, Exclude<HPOLabel, "others">>;
146
169
  /**
147
170
  * Color palettes for each color scheme.
148
171
  * Based on Tailwind CSS color palette.
@@ -162,8 +185,12 @@ declare const ANIMATION_DURATION_MS = 150;
162
185
  * - Click to select/deselect organs
163
186
  * - Hover effects work independently even when an organ is selected
164
187
  * - Exposes hover and selection state via callbacks
188
+ * - Zoom and pan support with mouse wheel and drag
165
189
  */
166
- declare function HpoVisualizer({ organs, visibleOrgans, hoveredOrgan: controlledHovered, selectedOrgan: controlledSelected, onHover, onSelect, colorPalette: inputColorPalette, width, height, className, style, }: HpoVisualizerProps): react_jsx_runtime.JSX.Element;
190
+ declare function HpoVisualizer({ organs, visibleOrgans, hoveredOrgan: controlledHovered, selectedOrgan: controlledSelected, onHover, onSelect, colorPalette: inputColorPalette, width, height, className, style, maxZoom, wheelZoom, }: HpoVisualizerProps): react_jsx_runtime.JSX.Element;
191
+
192
+ declare const createUniformOrganColorSchemes: (organIds: readonly OrganId[], scheme: ColorScheme) => Record<OrganId, ColorScheme>;
193
+ declare const createOrganOutlineSet: (organIds: readonly OrganId[], enabled: boolean) => Set<OrganId>;
167
194
 
168
195
  interface OrganSvgWrapperProps {
169
196
  /** Organ identifier */
@@ -182,13 +209,13 @@ interface OrganSvgWrapperProps {
182
209
  onMouseLeave: () => void;
183
210
  /** Click handler */
184
211
  onClick: () => void;
185
- /** X position in parent coordinate system */
212
+ /** X position in parent viewBox coordinate system */
186
213
  x: number;
187
- /** Y position in parent coordinate system */
214
+ /** Y position in parent viewBox coordinate system */
188
215
  y: number;
189
- /** Width of the organ SVG viewport */
216
+ /** Width of the organ SVG viewport in viewBox units */
190
217
  width: number;
191
- /** Height of the organ SVG viewport */
218
+ /** Height of the organ SVG viewport in viewBox units */
192
219
  height: number;
193
220
  /** ViewBox for the organ SVG (local coordinate system) */
194
221
  viewBox: string;
@@ -237,8 +264,9 @@ interface UseOrganInteractionResult {
237
264
  * - Click on organ sets selectedOrgan and calls onSelect
238
265
  * - Click on already selected organ deselects it
239
266
  * - Click on different organ changes selection
267
+ * - Deselect keeps hover state when still over the organ
240
268
  * - Hover effects work independently even when an organ is selected
241
269
  */
242
270
  declare function useOrganInteraction(options?: UseOrganInteractionOptions): UseOrganInteractionResult;
243
271
 
244
- export { ANIMATION_DURATION_MS, type ColorScale as ColorPalette, type ColorName as ColorScheme, DEFAULT_COLOR_PALETTE, HpoVisualizer, type HpoVisualizerProps, ORGAN_COMPONENTS, ORGAN_IDS, ORGAN_NAMES_EN, ORGAN_NAMES_KO, type OrganConfig, type OrganId, type OrganInteractionHandlers, type OrganInteractionState, type OrganStyle, OrganSvg, type OrganSvgProps, type OrganSvgWrapperProps, type UseOrganInteractionOptions, type UseOrganInteractionResult, useOrganInteraction };
272
+ export { ANIMATION_DURATION_MS, type ColorScale as ColorPalette, type ColorName as ColorScheme, DEFAULT_COLOR_PALETTE, type HPOLabel, HPO_LABELS, HPO_LABEL_TO_ORGAN, HpoVisualizer, type HpoVisualizerProps, ORGAN_COMPONENTS, ORGAN_IDS, ORGAN_NAMES_EN, ORGAN_NAMES_KO, ORGAN_TO_HPO_LABEL, type OrganConfig, type OrganId, type OrganInteractionHandlers, type OrganInteractionState, type OrganStyle, OrganSvg, type OrganSvgProps, type OrganSvgWrapperProps, type UseOrganInteractionOptions, type UseOrganInteractionResult, createOrganOutlineSet, createUniformOrganColorSchemes, useOrganInteraction };