@salloomd/teeth-selector 0.0.1 → 0.0.2

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.
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import type { TeethPreviewProps } from "../lib/types";
3
+ declare const TeethPreview: React.ForwardRefExoticComponent<TeethPreviewProps & React.RefAttributes<SVGSVGElement>>;
4
+ export { TeethPreview };
5
+ //# sourceMappingURL=teeth-preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teeth-preview.d.ts","sourceRoot":"","sources":["../../components/teeth-preview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMtD,QAAA,MAAM,YAAY,yFAiHjB,CAAC;AAIF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,63 @@
1
+ import * as React from "react";
2
+ import { type Tooth } from "../lib/teeth";
3
+ import type { TeethSelectorProps, TeethSelectorState } from "../lib/types";
4
+ type SelectionAction = {
5
+ type: "toggle-tooth";
6
+ toothId: number;
7
+ } | {
8
+ type: "toggle-bridge";
9
+ fromId: number;
10
+ toId: number;
11
+ } | {
12
+ type: "select-upper";
13
+ } | {
14
+ type: "select-lower";
15
+ } | {
16
+ type: "clear-all";
17
+ } | {
18
+ type: "select-range";
19
+ teethIds: number[];
20
+ } | {
21
+ type: "set";
22
+ state: TeethSelectorState;
23
+ };
24
+ interface TeethSelectorContextValue {
25
+ state: TeethSelectorState;
26
+ dispatch: React.Dispatch<SelectionAction>;
27
+ dragState: DragState;
28
+ setDragState: React.Dispatch<React.SetStateAction<DragState>>;
29
+ }
30
+ export declare function useTeethSelectorContext(): TeethSelectorContextValue;
31
+ interface DragState {
32
+ start: number | null;
33
+ current: number | null;
34
+ teethInRange: number[];
35
+ }
36
+ declare const TeethSelector: React.ForwardRefExoticComponent<TeethSelectorProps & React.RefAttributes<HTMLDivElement>>;
37
+ interface TeethChartProps {
38
+ width?: number;
39
+ height?: number;
40
+ className?: string;
41
+ renderTooth?: (props: {
42
+ tooth: Tooth;
43
+ isSelected: boolean;
44
+ isInDragRange: boolean;
45
+ }, defaultElement: React.JSX.Element) => React.ReactNode;
46
+ renderBridge?: (props: {
47
+ fromId: number;
48
+ toId: number;
49
+ exists: boolean;
50
+ position: {
51
+ x1: number;
52
+ y1: number;
53
+ x2: number;
54
+ y2: number;
55
+ midX: number;
56
+ midY: number;
57
+ };
58
+ }, defaultElement: React.JSX.Element) => React.ReactNode;
59
+ enableDragSelection?: boolean;
60
+ }
61
+ declare const TeethChart: React.ForwardRefExoticComponent<TeethChartProps & React.RefAttributes<SVGSVGElement>>;
62
+ export { TeethSelector, TeethChart };
63
+ //# sourceMappingURL=teeth-selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teeth-selector.d.ts","sourceRoot":"","sources":["../../components/teeth-selector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAIL,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAM3E,KAAK,eAAe,GAChB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,KAAK,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C,OAAO,KAC9B,KAAK,CAAC,SAAS,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,QAAA,MAAM,UAAU,uFA4Mf,CAAC;AAIF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { TeethSelector, TeethChart, useTeethSelectorContext, } from "./components/teeth-selector";
2
+ export { TeethPreview } from "./components/teeth-preview";
3
+ export { teethData, adjacentTeethPairs, getTeethInRange, parseTeethSelection, formatTeethSelection, sameSide, } from "./lib/teeth";
4
+ export type { Tooth } from "./lib/teeth";
5
+ export type { TeethSelectorProps, TeethSelectorState, TeethSelectorRenderProps, TeethChartProps, TeethPreviewProps, ToothRenderProps, BridgeRenderProps, } from "./lib/types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,UAAU,EACV,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,GACT,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface Tooth {
2
+ order: number;
3
+ id: number;
4
+ name: string;
5
+ position: "upper" | "lower";
6
+ side: "left" | "right";
7
+ d: string;
8
+ }
9
+ export declare const teethData: Tooth[];
10
+ export declare const adjacentTeethPairs: [number, number][];
11
+ export declare function getTeethInRange(startId: number, endId: number): number[];
12
+ export declare function sameSide(tooth1: number, tooth2: number): boolean;
13
+ export declare function parseTeethSelection(input: string): {
14
+ selectedTeeth: number[];
15
+ bridges: number[][];
16
+ };
17
+ export declare function formatTeethSelection(selectedTeeth: number[], bridges: number[][]): string;
18
+ //# sourceMappingURL=teeth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teeth.d.ts","sourceRoot":"","sources":["../../lib/teeth.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,CAAC,EAAE,MAAM,CAAC;CACX;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,EAqQ5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAiChD,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAYxE;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG;IAClD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;CACrB,CA0CA;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,EAAE,MAAM,EAAE,EAAE,GAClB,MAAM,CAyDR"}
@@ -0,0 +1,93 @@
1
+ import type { Tooth } from "./teeth";
2
+ export interface TeethSelectorState {
3
+ selectedTeeth: number[];
4
+ bridges: number[][];
5
+ }
6
+ export interface TeethSelectorRenderProps extends TeethSelectorState {
7
+ /** Toggle a tooth's selection state */
8
+ toggleTooth: (toothId: number) => void;
9
+ /** Toggle a bridge between two teeth */
10
+ toggleBridge: (fromId: number, toId: number) => void;
11
+ /** Select all upper teeth with bridges */
12
+ selectUpper: () => void;
13
+ /** Select all lower teeth with bridges */
14
+ selectLower: () => void;
15
+ /** Select a range of teeth with bridges */
16
+ selectRange: (teethIds: number[]) => void;
17
+ /** Clear all selections */
18
+ clearAll: () => void;
19
+ /** Check if a tooth is selected */
20
+ isSelected: (toothId: number) => boolean;
21
+ /** Check if a bridge exists between two teeth */
22
+ hasBridge: (fromId: number, toId: number) => boolean;
23
+ /** Get sorted selected teeth data */
24
+ getSelectedTeethData: () => Tooth[];
25
+ }
26
+ export interface TeethSelectorProps {
27
+ /** Initial selected teeth IDs */
28
+ defaultSelectedTeeth?: number[];
29
+ /** Initial bridges as pairs of tooth IDs */
30
+ defaultBridges?: number[][];
31
+ /** Controlled selected teeth */
32
+ selectedTeeth?: number[];
33
+ /** Controlled bridges */
34
+ bridges?: number[][];
35
+ /** Callback when selection changes */
36
+ onSelectionChange?: (selectedTeeth: Tooth[]) => void;
37
+ /** Callback when bridges change */
38
+ onBridgeChange?: (bridges: number[][]) => void;
39
+ /** Unified callback for any change */
40
+ onChange?: (selectedTeeth: Tooth[], bridges: number[][]) => void;
41
+ /** Render function receiving state and actions */
42
+ children: (props: TeethSelectorRenderProps) => React.ReactNode;
43
+ }
44
+ export interface ToothRenderProps {
45
+ tooth: Tooth;
46
+ isSelected: boolean;
47
+ isInDragRange: boolean;
48
+ }
49
+ export interface BridgeRenderProps {
50
+ fromId: number;
51
+ toId: number;
52
+ exists: boolean;
53
+ position: {
54
+ x1: number;
55
+ y1: number;
56
+ x2: number;
57
+ y2: number;
58
+ midX: number;
59
+ midY: number;
60
+ };
61
+ }
62
+ export interface TeethChartProps {
63
+ /** Width of the SVG */
64
+ width?: number;
65
+ /** Height of the SVG */
66
+ height?: number;
67
+ /** Additional class names */
68
+ className?: string;
69
+ /** Custom render function for each tooth */
70
+ renderTooth?: (props: ToothRenderProps, defaultElement: React.ReactElement) => React.ReactNode;
71
+ /** Custom render function for each bridge */
72
+ renderBridge?: (props: BridgeRenderProps, defaultElement: React.ReactElement) => React.ReactNode;
73
+ /** Enable drag selection */
74
+ enableDragSelection?: boolean;
75
+ }
76
+ export interface TeethPreviewProps {
77
+ /** Teeth selection string (e.g., "11, [21, 23], 31") */
78
+ teeth: string;
79
+ /** Width of the SVG */
80
+ width?: number;
81
+ /** Height of the SVG */
82
+ height?: number;
83
+ /** Additional class names */
84
+ className?: string;
85
+ /** Custom render function for selected teeth */
86
+ renderTooth?: (props: {
87
+ tooth: Tooth;
88
+ isSelected: boolean;
89
+ }, defaultElement: React.ReactElement) => React.ReactNode;
90
+ /** Custom render function for bridges */
91
+ renderBridge?: (props: Omit<BridgeRenderProps, "exists">, defaultElement: React.ReactElement) => React.ReactNode;
92
+ }
93
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMrC,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,uCAAuC;IACvC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,wCAAwC;IACxC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,0CAA0C;IAC1C,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,2CAA2C;IAC3C,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,2B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SAAS,CAAC;CACtB"}
package/package.json CHANGED
@@ -1,14 +1,23 @@
1
1
  {
2
2
  "name": "@salloomd/teeth-selector",
3
- "version": "0.0.1",
4
- "module": "index.ts",
3
+ "version": "0.0.2",
5
4
  "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
6
15
  "files": [
7
16
  "dist"
8
17
  ],
9
18
  "sideEffects": false,
10
19
  "scripts": {
11
- "build": "bun build index.ts --outdir dist",
20
+ "build": "bun build index.ts --outdir dist && tsc -p tsconfig.build.json",
12
21
  "storybook": "storybook dev -p 6006",
13
22
  "build-storybook": "storybook build"
14
23
  },