Remove InputOptions

This commit is contained in:
Nathan Bierema 2023-01-02 09:20:31 -05:00
parent 02cb2bbaba
commit ea03537271

View File

@ -12,60 +12,6 @@ import {
import { tooltip } from 'd3tooltip'; import { tooltip } from 'd3tooltip';
import type { StyleValue } from 'd3tooltip'; import type { StyleValue } from 'd3tooltip';
// TODO Can we remove InputOptions?
export interface InputOptions {
// eslint-disable-next-line @typescript-eslint/ban-types
state?: {} | null;
// eslint-disable-next-line @typescript-eslint/ban-types
tree?: Node | {};
rootKeyName: string;
pushMethod: 'push' | 'unshift';
id: string;
chartStyles: { [key: string]: StyleValue };
nodeStyleOptions: {
colors: {
default: string;
collapsed: string;
parent: string;
};
radius: number;
};
textStyleOptions: {
colors: {
default: string;
hover: string;
};
};
linkStyles: { [key: string]: StyleValue };
size: number;
aspectRatio: number;
initialZoom: number;
margin: {
top: number;
right: number;
bottom: number;
left: number;
};
isSorted: boolean;
heightBetweenNodesCoeff: number;
widthBetweenNodesCoeff: number;
transitionDuration: number;
blinkDuration: number;
onClickText: (datum: Node) => void;
tooltipOptions: {
disabled?: boolean;
left?: number | undefined;
top?: number | undefined;
offset?: {
left: number;
top: number;
};
style?: { [key: string]: StyleValue } | undefined;
indentationSize?: number;
};
}
interface Options { interface Options {
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
state?: {} | null; state?: {} | null;
@ -105,7 +51,7 @@ interface Options {
widthBetweenNodesCoeff: number; widthBetweenNodesCoeff: number;
transitionDuration: number; transitionDuration: number;
blinkDuration: number; blinkDuration: number;
onClickText: () => void; onClickText: (datum: HierarchyPointNode<Node>) => void;
tooltipOptions: { tooltipOptions: {
disabled: boolean; disabled: boolean;
left: number | undefined; left: number | undefined;
@ -171,7 +117,7 @@ const defaultOptions: Options = {
}, },
style: undefined, style: undefined,
}, },
}; } satisfies Options;
export interface Node { export interface Node {
name: string; name: string;
@ -200,10 +146,7 @@ interface NodePosition {
y: number; y: number;
} }
export default function ( export default function (DOMNode: HTMLElement, options: Partial<Options> = {}) {
DOMNode: HTMLElement,
options: Partial<InputOptions> = {}
) {
const { const {
id, id,
chartStyles, chartStyles,
@ -225,7 +168,7 @@ export default function (
tree, tree,
tooltipOptions, tooltipOptions,
onClickText, onClickText,
} = deepmerge(defaultOptions, options) as Options; } = deepmerge(defaultOptions, options);
const width = size - margin.left - margin.right; const width = size - margin.left - margin.right;
const height = size * aspectRatio - margin.top - margin.bottom; const height = size * aspectRatio - margin.top - margin.bottom;