WIP vite migration

This commit is contained in:
2023-12-12 19:37:41 +01:00
parent cba850251f
commit 34efa48c3e
15 changed files with 729 additions and 16603 deletions

View File

@ -2,7 +2,7 @@ import { mdiXml } from "@mdi/js";
import Icon from "@mdi/react";
import PictureAsPdfIcon from "@mui/icons-material/PictureAsPdf";
import { IconButton, Tooltip } from "@mui/material";
import f3, { f3Data } from "family-chart";
import "family-chart";
import { jsPDF } from "jspdf";
import React from "react";
import "svg2pdf.js";
@ -24,7 +24,7 @@ export function ComplexFamilyTree(p: {
depth: number;
}): React.ReactElement {
const darkTheme = useDarkTheme();
console.log(f3);
const applyTree = (container: HTMLDivElement) => {
if (!container) return;
@ -207,10 +207,10 @@ function treeToF3Data(
node: FamilyTreeNode,
isUp: boolean,
depth: number
): f3Data[] {
): f3.f3Data[] {
const availableMembers = getAvailableMembers(node, depth);
const list: f3Data[] = [];
const list: f3.f3Data[] = [];
if (isUp) treeToF3DataUpRecurse(node, list, availableMembers);
else treeToF3DataDownRecurse(node, list, availableMembers);
return list;
@ -232,7 +232,7 @@ function memberData(m: Member, c?: Couple): f3.f3DataData {
function treeToF3DataUpRecurse(
node: FamilyTreeNode,
array: f3Data[],
array: f3.f3Data[],
availableMembers: Set<number>,
child?: number,
spouses?: number[]
@ -274,7 +274,7 @@ function treeToF3DataUpRecurse(
function treeToF3DataDownRecurse(
node: FamilyTreeNode,
array: f3Data[],
array: f3.f3Data[],
availableMembers: Set<number>
) {
if (!availableMembers.has(node.member.id)) return;

View File

@ -1,95 +0,0 @@
declare module "family-chart" {
type f3data = any;
type f3tree = any;
interface f3Rels {
spouses?: string[];
father?: string;
mother?: string;
children?: string[];
}
interface f3DataData {
gender: "M" | "F";
avatar?: string;
dead: boolean;
birthday?: string;
deathday?: string;
first_name: string;
last_name: string;
dateOfWedding?: string;
wedding_state?: string;
}
interface f3Data {
id: string;
rels: f3Rels;
data: f3DataData;
}
type f3State = {
data: f3Data[];
main_id?: any;
tree?: f3tree;
node_separation?: number;
level_separation?: number;
};
interface f3Update {
tree: (props) => void;
mainId: (mainId) => void;
data: (data: f3data) => void;
}
interface f3Store {
state: f3State;
update: f3update;
getData: () => f3data;
getTree: () => f3tree;
setOnUpdate: (cb: (props) => void) => void;
methods: any;
}
function createStore(initial_state: f3State): f3Store;
function CalculateTree({
data_stash,
main_id = null,
is_vertical = true,
node_separation = 250,
level_separation = 150,
});
function d3AnimationView(p: {
store: f3Store;
cont: HTMLElement | null;
Card?: any;
});
const handlers: any;
type F3elements = {
Card: (props: {
store: f3Store;
svg: HTMLElement;
mini_tree: boolean;
link_break: boolean;
cardEditForm?: boolean;
card_dim: {
w: number;
h: number;
text_x: number;
text_y: number;
img_w: number;
img_h: number;
img_x: number;
img_y: number;
};
card_display: ((data: f3Data) => string)[];
}) => F3CardBuilder;
};
type F3CardBuilder = (p: { node; d }) => HTMLElement;
const elements: F3elements;
}

View File

@ -13,6 +13,7 @@ import { downloadBlob } from "../../utils/files_utils";
import { getTextWidth } from "../../utils/render_utils";
import "./simpletree.css";
import "./Roboto-normal";
import "svg2pdf.js";
const FACE_WIDTH = 60;
const FACE_HEIGHT = 70;
@ -92,7 +93,8 @@ function buildSimpleTreeNode(
): SimpleTreeNode {
if (depth === 0) throw new Error("Too much recursion reached!");
const lastCouple = tree.couples?.[tree.couples?.length - 1 ?? 0];
const lastCoupleId = tree.couples?.length ?? 1;
const lastCouple = tree.couples?.[lastCoupleId - 1];
// Preprocess children
let childrenToProcess = tree.down;