react-advanced-odontogram 2.0.2 → 2.2.0

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.
Files changed (41) hide show
  1. package/README.md +38 -1335
  2. package/dist/index.d.ts +716 -4
  3. package/dist/odontogram.js +3209 -2398
  4. package/dist/odontogram.js.map +1 -1
  5. package/package.json +7 -8
  6. package/dist/App.d.ts +0 -148
  7. package/dist/DualStateConfirm.d.ts +0 -25
  8. package/dist/ExportOptionsModal.d.ts +0 -26
  9. package/dist/PerioChart.d.ts +0 -67
  10. package/dist/PerioSidebar.d.ts +0 -1
  11. package/dist/SettingsModal.d.ts +0 -84
  12. package/dist/bridgeOverlay.d.ts +0 -116
  13. package/dist/fhir/codesystems.d.ts +0 -51
  14. package/dist/fhir/fieldMappings.d.ts +0 -35
  15. package/dist/fhir/fromFhir.d.ts +0 -7
  16. package/dist/fhir/primitives.d.ts +0 -16
  17. package/dist/fhir/toFhir.d.ts +0 -20
  18. package/dist/fhir/toFhirPerio.d.ts +0 -70
  19. package/dist/fhir/types.d.ts +0 -108
  20. package/dist/i18n/translations.d.ts +0 -27
  21. package/dist/i18n/useI18n.d.ts +0 -39
  22. package/dist/odontogram.d.ts +0 -1214
  23. package/dist/perioClassification.d.ts +0 -90
  24. package/dist/perioExport.d.ts +0 -13
  25. package/dist/perioGraphic.d.ts +0 -496
  26. package/dist/perioIndexNames.d.ts +0 -29
  27. package/dist/perioPdf.d.ts +0 -77
  28. package/dist/plugin.d.ts +0 -63
  29. package/dist/registry/axes.d.ts +0 -9
  30. package/dist/registry/fhir.d.ts +0 -3
  31. package/dist/registry/fromFhir.d.ts +0 -3
  32. package/dist/registry/restorations.d.ts +0 -26
  33. package/dist/registry/svgActivate.d.ts +0 -15
  34. package/dist/registry/svgLayers.d.ts +0 -14
  35. package/dist/registry/types.d.ts +0 -70
  36. package/dist/registry/uiOptions.d.ts +0 -17
  37. package/dist/registry/validate.d.ts +0 -4
  38. package/dist/status_extras.d.ts +0 -58
  39. package/dist/theme.d.ts +0 -51
  40. package/dist/tour.d.ts +0 -9
  41. package/dist/utils/numbering.d.ts +0 -23
@@ -1,77 +0,0 @@
1
- /** UI-3b Task 6/7: which PDF sections the user opted into. The perio
2
- * sections are additionally auto-skipped whenever `data.hasPerio` is false
3
- * (see {@link assemblePdf}), regardless of these flags — a blank perio
4
- * chart never gets an empty "Periodontal status" page. */
5
- export interface PdfExportOptions {
6
- patientData: boolean;
7
- odontogram: boolean;
8
- perioStatus: boolean;
9
- perioDescription: boolean;
10
- }
11
- /** Minimal case-identity shape the PDF header needs (patient name + exam
12
- * date). Deliberately a LOCAL structural type rather than importing
13
- * odontogram.ts's `CaseMeta` — `getCaseMeta()`'s return value satisfies it
14
- * structurally, and keeping this module free of any `odontogram.ts` import
15
- * avoids a circular dependency (odontogram.ts is the one importing FROM
16
- * perioPdf.ts). */
17
- export interface PdfCaseIdentity {
18
- patientName: string | null;
19
- examDate: string | null;
20
- }
21
- /** Pixel dimensions of a rasterized chart, used to keep the embedded PDF
22
- * image's aspect ratio correct. Optional — `assemblePdf` falls back to a
23
- * reasonable default aspect ratio when omitted (e.g. in the unit test's
24
- * minimal fixture). */
25
- export interface PdfImageSize {
26
- width: number;
27
- height: number;
28
- }
29
- /** Pre-rendered input for {@link assemblePdf} — every PNG/text value is
30
- * already computed by `exportPdf()` before this is built; `assemblePdf`
31
- * itself performs no I/O. */
32
- export interface PdfAssembleData {
33
- /** `hasAnyPerioData()` — when false, BOTH perio sections are omitted no
34
- * matter what `opts.perioStatus`/`opts.perioDescription` ask for. */
35
- hasPerio: boolean;
36
- caseMeta: PdfCaseIdentity;
37
- odontogramPng: string;
38
- odontogramSummaryText: string;
39
- odontogramImageSize?: PdfImageSize;
40
- perioPng: string;
41
- perioSummaryText: string;
42
- perioImageSize?: PdfImageSize;
43
- }
44
- /** The minimal jsPDF surface `assemblePdf` drives — lets tests inject a
45
- * lightweight fake without constructing a real `jsPDF` (see the jsdom note
46
- * above). A real `jsPDF` instance satisfies this structurally. */
47
- export interface PdfDocLike {
48
- text: (text: string, x: number, y: number, options?: any) => PdfDocLike;
49
- addImage: (imageData: string, format: string, x: number, y: number, width: number, height: number) => PdfDocLike;
50
- addPage: (...args: any[]) => PdfDocLike;
51
- setFontSize: (size: number) => PdfDocLike;
52
- setFont: (fontName: string, fontStyle?: string) => PdfDocLike;
53
- save: (filename?: string) => void;
54
- internal: {
55
- pageSize: {
56
- getWidth: () => number;
57
- getHeight: () => number;
58
- };
59
- };
60
- }
61
- /**
62
- * Assemble the PDF report from pre-rendered `data`, gated by `opts`. PURE —
63
- * no I/O, no rasterization; `docFactory` defaults to a real `new jsPDF()`
64
- * but tests always inject a fake (see the jsdom note above).
65
- *
66
- * Section order: (1) header (patient name + exam date) when
67
- * `opts.patientData`; (2) odontogram image + summary prose when
68
- * `opts.odontogram`; (3) perio chart image when `data.hasPerio &&
69
- * opts.perioStatus`; (4) perio summary/classification text + the
70
- * explanatory abbreviation-legend footer when `data.hasPerio &&
71
- * opts.perioDescription` — the footer is tied to `perioDescription`
72
- * (mirrors the export dialog's "Perio description + footer" grouping) not
73
- * to "any perio section shown", so enabling only the perio graphic
74
- * (`perioStatus`) without the description never prints a legend for text
75
- * that isn't there.
76
- */
77
- export declare function assemblePdf(opts: PdfExportOptions, data: PdfAssembleData, docFactory?: () => PdfDocLike): PdfDocLike;
package/dist/plugin.d.ts DELETED
@@ -1,63 +0,0 @@
1
- import type { Language } from "./i18n/translations";
2
- /**
3
- * Defines the SVG layer where a plugin's visual output will be inserted.
4
- *
5
- * | Layer | Z-order | Description |
6
- * |---------------|---------|----------------------------------------|
7
- * | `base` | 0 | Below the tooth — background indicators |
8
- * | `restoration` | 3 | Between endo and crown layers |
9
- * | `overlay` | 6 | Top-most — badges, markers, highlights |
10
- */
11
- export type PluginLayer = "base" | "restoration" | "overlay";
12
- /**
13
- * Custom SVG plugin definition for the Odontogram engine.
14
- *
15
- * Plugins can inject custom SVG content into each tooth's rendering and
16
- * maintain per-tooth custom state that is automatically included in
17
- * JSON export/import.
18
- *
19
- * @example
20
- * ```typescript
21
- * const implantBrandPlugin: OdontogramPlugin = {
22
- * id: "implant-brand",
23
- * label: { hu: "Implantátum márka", en: "Implant brand", de: "Implantat-Marke", ... },
24
- * layer: "overlay",
25
- * renderSvg: (toothNo, _quadrant, customState) => {
26
- * if (!customState?.brand) return null;
27
- * return `<text x="16" y="60" font-size="6" fill="#3b7bff">${customState.brand}</text>`;
28
- * },
29
- * };
30
- * ```
31
- */
32
- export type OdontogramPlugin = {
33
- /** Unique plugin identifier (used as key in customStates). */
34
- id: string;
35
- /** Localized display label for the plugin (shown in the state tooltip). */
36
- label: Partial<Record<Language, string>>;
37
- /**
38
- * SVG layer where this plugin's output will be rendered.
39
- * @see {@link PluginLayer}
40
- */
41
- layer: PluginLayer;
42
- /**
43
- * Render SVG markup for a specific tooth. Return an SVG fragment string
44
- * (will be wrapped in a `<g>` element) or `null`/`undefined` to render nothing.
45
- *
46
- * @param toothNo - The FDI tooth number (11–48).
47
- * @param quadrant - The quadrant (1–4) derived from the tooth number.
48
- * @param customState - The plugin's custom state for this tooth, or `undefined`.
49
- */
50
- renderSvg: (toothNo: number, quadrant: 1 | 2 | 3 | 4, customState: unknown) => string | null | undefined;
51
- /**
52
- * Optional: which panel section this plugin adds controls to.
53
- * When set to `"custom"`, the engine will render a dedicated panel
54
- * section for the plugin (future expansion).
55
- */
56
- panelSection?: "custom";
57
- };
58
- /**
59
- * Get the quadrant number (1–4) for a given FDI tooth number.
60
- */
61
- export declare function getQuadrant(toothNo: number): 1 | 2 | 3 | 4;
62
- /** Z-index priority for SVG plugin layers. */
63
- export declare const LAYER_Z: Record<PluginLayer, number>;
@@ -1,9 +0,0 @@
1
- /**
2
- * Registry catalog coding data (SP2 Stage 0). One `ClinicalAxis` per
3
- * `FIELD_MAPPINGS` row (`src/fhir/fieldMappings.ts`), with finding codes and
4
- * value codings transcribed from `LOCAL_VALUE_MAPS` (`src/fhir/codesystems.ts`).
5
- * Enforced verbatim by `src/__tests__/parity.test.ts` ("registry catalog
6
- * matches today's tables"). No SNOMED/ICD codes populated (SP2 keeps them empty).
7
- */
8
- import type { ClinicalAxis } from "./types";
9
- export declare const AXES: ClinicalAxis[];
@@ -1,3 +0,0 @@
1
- import type { Bundle, OdontogramExportPayload, FhirExportOptions } from "../fhir/types";
2
- /** Registry-driven FHIR bundle build. Byte-identical to the legacy buildFhirBundle. */
3
- export declare function buildFhirBundleFromRegistry(payload: OdontogramExportPayload, options?: FhirExportOptions): Bundle;
@@ -1,3 +0,0 @@
1
- import type { OdontogramExportPayload } from "../fhir/types";
2
- /** Registry-driven inverse of buildFhirBundle. Byte-identical to the legacy parseFhirBundle. */
3
- export declare function parseFhirBundleFromRegistry(bundle: unknown): OdontogramExportPayload;
@@ -1,26 +0,0 @@
1
- export type RestorationType = "none" | "crown" | "inlay" | "onlay" | "veneer" | "bridge";
2
- export type RestorationMaterial = "none" | "emax" | "gold" | "gradia" | "zircon" | "metal" | "metal-ceramic" | "telescope" | "temporary";
3
- export type ToothView = "front" | "occlusal";
4
- export declare const RESTORATION_MATRIX: Record<Exclude<RestorationType, "none">, {
5
- materials: RestorationMaterial[];
6
- occlusalOnly?: boolean;
7
- }>;
8
- export declare function isValidRestoration(type: RestorationType, material: RestorationMaterial, view: ToothView): boolean;
9
- export declare function composeRestorationLayers(type: RestorationType, material: RestorationMaterial, view: ToothView): string[];
10
- export declare function allRestorationLayers(): string[];
11
- export interface RestorationOption {
12
- restorationType: RestorationType;
13
- restorationMaterial: RestorationMaterial;
14
- labelKey: string;
15
- typeLabelKey?: string;
16
- materialLabelKey?: string;
17
- prefixKey?: string;
18
- prosthesis?: ProsthesisValue;
19
- }
20
- export type ProsthesisValue = "healing-abutment" | "locator" | "locator-denture" | "bar" | "bar-denture" | "removable-partial" | "removable-full";
21
- export interface RestorationOptionsCtx {
22
- isImplant?: boolean;
23
- view?: ToothView;
24
- toothSelection?: string;
25
- }
26
- export declare function restorationOptions(view: ToothView, ctx?: RestorationOptionsCtx): RestorationOption[];
@@ -1,15 +0,0 @@
1
- import type { FlagCtx } from "./types";
2
- interface Deps {
3
- setActive: (el: any, on: boolean) => void;
4
- svgGetById: (root: any, id: string) => any;
5
- isToothPresent: (sel: string) => boolean;
6
- isUnderGum: (sel: string) => boolean;
7
- isExtraction: (sel: string) => boolean;
8
- fissureAllowedTeeth: Set<number>;
9
- brokenVariants: Set<string>;
10
- }
11
- /** Compute the render's derived booleans (mirrors applyStateToSvgSingle). */
12
- export declare function buildFlagCtx(state: any, toothNo: number, d: Deps): FlagCtx;
13
- /** Activate the in-scope boolean-flag layers + the mods set layers. Order-independent. */
14
- export declare function applyFlagLayers(svg: any, state: any, ctx: FlagCtx, d: Deps): void;
15
- export {};
@@ -1,14 +0,0 @@
1
- /** Non-axis layers the render clears (base/pulp/milktooth/bruxism/crown-branch intermediates/etc.).
2
- * Transcribed verbatim from odontogram.ts applyStateToSvgSingle's clear block (:742-787).
3
- * Also includes "implant" and "milktooth": those two ids are NOT cleared by the :742-787
4
- * block itself (they are activation-toggled right after it, at :763-764 via
5
- * setActive("implant", isImplant) / setActive("milktooth", isMilktooth)), but
6
- * axisClearLayers() below derives them from AXES (toothSelection.svgLayer) since they
7
- * are legitimate switchable SVG layers. Clearing them here is byte-identical to today's
8
- * render because :763-764 immediately re-sets them to the correct value right after —
9
- * setActive() is a pure, idempotent attribute write. They are listed explicitly here so
10
- * allClearLayers() equals this list as a set (see the set-equality test). */
11
- export declare const FIXED_CLEAR_LAYERS: string[];
12
- export declare function axisClearLayers(): string[];
13
- /** The full set of layers the render turns off before applying active state. */
14
- export declare function allClearLayers(): string[];
@@ -1,70 +0,0 @@
1
- /** Registry type definitions for the clinical-axis engine (SP2). Types only. */
2
- export type AxisKind = "enum" | "boolean" | "set" | "surfaceSet" | "restoration" | "derived" | "global";
3
- /** Context for filtering curated UI option lists (`uiOptions` / `optionsFor`). */
4
- export interface UiOptCtx {
5
- isMilktooth?: boolean;
6
- }
7
- /** A coded concept: local code always present; SNOMED/ICD optional and additive. */
8
- export interface ConceptRef {
9
- local: string;
10
- display: string;
11
- snomed?: string;
12
- icd?: {
13
- system: string;
14
- code: string;
15
- }[];
16
- }
17
- /** One allowed value of an axis. svgLayer/ui are added in later stages. */
18
- export interface AxisValue {
19
- id: string;
20
- coding: ConceptRef;
21
- labelKey?: string;
22
- svgLayer?: string | string[];
23
- }
24
- /** Precomputed render context for flag activation (mirrors the render's derived booleans). */
25
- export interface FlagCtx {
26
- isImplant: boolean;
27
- isMilktooth: boolean;
28
- underGum: boolean;
29
- extraction: boolean;
30
- isNone: boolean;
31
- toothPresent: boolean;
32
- fissureAllowed: boolean;
33
- contactAllowed: boolean;
34
- bruxismAllowed: boolean;
35
- extractionPlanAllowed: boolean;
36
- }
37
- /** One chartable tooth axis. Resolver fields are optional here (filled per stage). */
38
- export interface ClinicalAxis {
39
- id: string;
40
- field: string;
41
- kind: AxisKind;
42
- finding: ConceptRef;
43
- valueGroup?: string;
44
- values?: AxisValue[];
45
- skipValue?: string;
46
- surfacesField?: string;
47
- flag?: string;
48
- svgLayer?: string;
49
- appliesWhen?: (ctx: FlagCtx, state: any) => boolean;
50
- uiOptions?: {
51
- value: string;
52
- labelKey: string;
53
- when?: (ctx: UiOptCtx) => boolean;
54
- }[];
55
- }
56
- /** Per-tooth rendering context (static tables; populated in later stages). */
57
- export interface ToothContext {
58
- fdi: number;
59
- template: 11 | 13 | 14 | 16;
60
- view: "front" | "occlusal";
61
- isAnterior: boolean;
62
- isMolar: boolean;
63
- mirror: boolean;
64
- rot: 0 | 180;
65
- fissureAllowed: boolean;
66
- milktoothAllowed: boolean;
67
- }
68
- /** Placeholder for the eventual axis-keyed state; SP2 keeps the current container.
69
- * Kept as a nominal type so later stages can tighten it. */
70
- export type ToothState = Record<string, unknown>;
@@ -1,17 +0,0 @@
1
- import type { UiOptCtx } from "./types";
2
- /** Feature-flag state consumed by the registry (extensible key→boolean map). */
3
- export type RegistryFlags = Record<string, boolean>;
4
- /**
5
- * First consumer of `ClinicalAxis.flag` (SP4 Task 5). An axis with no `flag`
6
- * is always active; an axis carrying a `flag` is active only when that flag is
7
- * set in `flags`. Currently gates `pulpLatin` (`flag: "latinPulpDetail"`),
8
- * which is satisfied iff the pulp-detail setting is "latin". This governs UI
9
- * authoring only — a stored value still serializes / round-trips regardless.
10
- */
11
- export declare function isAxisFlagSatisfied(axisId: string, flags?: RegistryFlags): boolean;
12
- /** Ordered {value, labelKey} option list for an axis (curated UI metadata).
13
- * Returns `[]` for a flag-gated axis whose flag is unsatisfied. */
14
- export declare function optionsFor(axisId: string, ctx?: UiOptCtx, flags?: RegistryFlags): {
15
- value: string;
16
- labelKey: string;
17
- }[];
@@ -1,4 +0,0 @@
1
- /** The allowed enum/set values for an axis, sourced from the registry catalog. */
2
- export declare function validValues(axisId: string): Set<string>;
3
- /** The allowed tooth-surface ids (a value group used by caries/filling, not an axis). */
4
- export declare function validSurfaces(): Set<string>;
@@ -1,58 +0,0 @@
1
- /**
2
- * Pre-configured dental status presets for quick application of common
3
- * restorative scenarios (bridges, full-arch, partial/full removable, bar dentures).
4
- *
5
- * `arches` defines the FDI tooth layout; `options` is the array of presets
6
- * selectable from the "Extras" dropdown in the UI.
7
- */
8
- export declare const STATUS_EXTRAS: {
9
- arches: {
10
- upper: number[];
11
- lower: number[];
12
- wisdom: {
13
- upper: number[];
14
- lower: number[];
15
- };
16
- };
17
- options: ({
18
- id: string;
19
- labelKey: string;
20
- type: string;
21
- teeth: number[];
22
- material: string;
23
- arch?: undefined;
24
- missingMaterial?: undefined;
25
- implants?: undefined;
26
- missing?: undefined;
27
- } | {
28
- id: string;
29
- labelKey: string;
30
- type: string;
31
- arch: string;
32
- material: string;
33
- missingMaterial: string;
34
- teeth?: undefined;
35
- implants?: undefined;
36
- missing?: undefined;
37
- } | {
38
- id: string;
39
- labelKey: string;
40
- type: string;
41
- arch: string;
42
- teeth?: undefined;
43
- material?: undefined;
44
- missingMaterial?: undefined;
45
- implants?: undefined;
46
- missing?: undefined;
47
- } | {
48
- id: string;
49
- labelKey: string;
50
- type: string;
51
- arch: string;
52
- implants: number[];
53
- missing: number[];
54
- teeth?: undefined;
55
- material?: undefined;
56
- missingMaterial?: undefined;
57
- })[];
58
- };
package/dist/theme.d.ts DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * Theme configuration for the Odontogram component.
3
- *
4
- * Allows host applications to override the default color palette without
5
- * modifying CSS files. All properties are optional — only the provided
6
- * values are overridden; the rest fall back to the built-in defaults.
7
- *
8
- * Colors are applied as CSS custom properties (`--odon-*`) on the
9
- * component root element, so they work regardless of whether the host
10
- * uses Tailwind CSS or plain CSS.
11
- *
12
- * @example
13
- * ```tsx
14
- * const myTheme: OdontogramThemeConfig = {
15
- * colors: {
16
- * accent: '#e74c3c',
17
- * background: '#fafafa',
18
- * },
19
- * };
20
- * <App themeConfig={myTheme} />
21
- * ```
22
- */
23
- export type OdontogramThemeConfig = {
24
- colors?: {
25
- /** Primary background. Default: `#f3f6fb` (light) / `#0f172a` (dark). */
26
- background?: string;
27
- /** Panel & card background. Default: `#ffffff` (light) / `#1e293b` (dark). */
28
- panel?: string;
29
- /** Card background. Default: same as panel. */
30
- card?: string;
31
- /** Primary text color. Default: `#1e2a3a` (light) / `#f1f5f9` (dark). */
32
- text?: string;
33
- /** Muted / secondary text color. Default: `#5b6b7d` (light) / `#94a3b8` (dark). */
34
- muted?: string;
35
- /** Border / divider color. Default: `#d7e0ec` (light) / `#334155` (dark). */
36
- line?: string;
37
- /** Primary accent (buttons, active states). Default: `#3b7bff`. */
38
- accent?: string;
39
- /** Secondary accent (success, selected states). Default: `#12b981`. */
40
- accent2?: string;
41
- };
42
- };
43
- /**
44
- * Apply an {@link OdontogramThemeConfig} to a DOM element by setting
45
- * CSS custom properties. Pass `null` or `undefined` to clear all
46
- * theme overrides.
47
- *
48
- * @param element - The root element to apply theme variables to.
49
- * @param config - The theme configuration, or `null`/`undefined` to reset.
50
- */
51
- export declare function applyThemeConfig(element: HTMLElement | null, config: OdontogramThemeConfig | null | undefined): void;
package/dist/tour.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export interface TourStep {
2
- selector: string;
3
- titleKey: string;
4
- textKey: string;
5
- }
6
- export declare const TOUR_STEPS: TourStep[];
7
- export declare function clampStep(i: number): number;
8
- /** Start the 12-step interactive intro tour. */
9
- export declare function startIntroTour(): void;
@@ -1,23 +0,0 @@
1
- /**
2
- * Supported tooth numbering systems.
3
- * - **FDI** – ISO 3950 two-digit notation (default in most countries).
4
- * - **UNIVERSAL** – ADA numbering (1-32 adult, A-T primary).
5
- * - **PALMER** – Quadrant-based notation (UR/UL/LL/LR + position).
6
- */
7
- export type NumberingSystem = "FDI" | "UNIVERSAL" | "PALMER";
8
- /**
9
- * Convert an FDI tooth number to the label for the requested numbering system.
10
- *
11
- * @param fdiTooth - Tooth number in FDI notation (e.g. `14`, `55`). Accepts a string that can be parsed as a number.
12
- * @param system - The target numbering system (`"FDI"`, `"UNIVERSAL"`, or `"PALMER"`).
13
- * @returns The formatted label (e.g. `"5"` for Universal, `"UR-4"` for Palmer). Returns the input as-is when it cannot be mapped.
14
- *
15
- * @example
16
- * ```ts
17
- * toLabel(14, "FDI"); // "14"
18
- * toLabel(14, "UNIVERSAL"); // "5"
19
- * toLabel(14, "PALMER"); // "UR-4"
20
- * toLabel(55, "UNIVERSAL"); // "A"
21
- * ```
22
- */
23
- export declare function toLabel(fdiTooth: number | string, system: NumberingSystem): string;