Skip to content

Commit e8b7b7d

Browse files
committed
refactor(types): replace DirectionClass enum with const object and refine direction types
1 parent af981c2 commit e8b7b7d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/types/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import type { createDragMoveHelper } from '../utils/dragMoveHelper'
1111
import type SelectionArea from '@viselect/vanilla'
1212
export { type MindElixirMethods } from '../methods'
1313

14-
export enum DirectionClass {
15-
LHS = 'lhs',
16-
RHS = 'rhs',
17-
}
14+
export const DirectionClass = {
15+
LHS: 'lhs',
16+
RHS: 'rhs',
17+
} as const
18+
19+
export type DirectionClass = (typeof DirectionClass)[keyof typeof DirectionClass]
1820

1921
type Before = Partial<{
2022
[K in Operations]: (...args: Parameters<OperationMap[K]>) => Promise<boolean> | boolean
@@ -91,7 +93,7 @@ export interface MindElixirInstance extends Omit<Required<Options>, 'markdown' |
9193
waitCopy: Topic[] | null
9294

9395
scaleVal: number
94-
tempDirection: number | null
96+
tempDirection: 0 | 1 | 2 | null
9597

9698
container: HTMLElement
9799
map: HTMLElement
@@ -131,7 +133,7 @@ type PathString = string
131133
*/
132134
export interface Options {
133135
el: string | HTMLElement
134-
direction?: number
136+
direction?: 0 | 1 | 2
135137
locale?: Locale
136138
draggable?: boolean
137139
editable?: boolean
@@ -246,6 +248,6 @@ export type MindElixirData = {
246248
nodeData: NodeObj
247249
arrows?: Arrow[]
248250
summaries?: Summary[]
249-
direction?: number
251+
direction?: 0 | 1 | 2
250252
theme?: Theme
251253
}

0 commit comments

Comments
 (0)