chrono-phylo-tree 1.0.15 → 1.1.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 (66) hide show
  1. package/eslint.config.js +28 -0
  2. package/global.d.ts +26 -0
  3. package/index.html +13 -0
  4. package/package.json +3 -7
  5. package/src/App.css +131 -0
  6. package/src/App.tsx +149 -0
  7. package/src/assets/react.svg +1 -0
  8. package/src/classes/Species.tsx +267 -0
  9. package/src/components/HoverDescription.tsx +27 -0
  10. package/src/components/LanguageSelector.tsx +29 -0
  11. package/src/components/Menu.tsx +348 -0
  12. package/src/components/NavBar.tsx +234 -0
  13. package/src/components/PhTree.tsx +362 -0
  14. package/src/index.css +68 -0
  15. package/src/index.ts +4 -0
  16. package/src/main.tsx +10 -0
  17. package/src/types.d.ts +9 -0
  18. package/src/utils/between.tsx +3 -0
  19. package/src/utils/example.tsx +73 -0
  20. package/src/utils/hexToRGBA.tsx +12 -0
  21. package/src/utils/scientificNotation.tsx +20 -0
  22. package/src/utils/setFromJson.tsx +40 -0
  23. package/src/utils/translate.tsx +68 -0
  24. package/src/utils/updateSpecies.tsx +129 -0
  25. package/src/vite-env.d.ts +1 -0
  26. package/tsconfig.app.json +26 -0
  27. package/tsconfig.json +17 -0
  28. package/tsconfig.node.json +24 -0
  29. package/vite.config.ts +34 -0
  30. package/dist/App.d.ts +0 -3
  31. package/dist/App.d.ts.map +0 -1
  32. package/dist/chrono-phylo-tree.js +0 -1111
  33. package/dist/chrono-phylo-tree.umd.cjs +0 -15
  34. package/dist/classes/Species.d.ts +0 -35
  35. package/dist/classes/Species.d.ts.map +0 -1
  36. package/dist/components/HoverDescription.d.ts +0 -15
  37. package/dist/components/HoverDescription.d.ts.map +0 -1
  38. package/dist/components/LanguageSelector.d.ts +0 -9
  39. package/dist/components/LanguageSelector.d.ts.map +0 -1
  40. package/dist/components/Menu.d.ts +0 -15
  41. package/dist/components/Menu.d.ts.map +0 -1
  42. package/dist/components/NavBar.d.ts +0 -33
  43. package/dist/components/NavBar.d.ts.map +0 -1
  44. package/dist/components/PhTree.d.ts +0 -31
  45. package/dist/components/PhTree.d.ts.map +0 -1
  46. package/dist/index.d.ts +0 -5
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/main.d.ts +0 -1
  49. package/dist/main.d.ts.map +0 -1
  50. package/dist/utils/between.d.ts +0 -2
  51. package/dist/utils/between.d.ts.map +0 -1
  52. package/dist/utils/example.d.ts +0 -3
  53. package/dist/utils/example.d.ts.map +0 -1
  54. package/dist/utils/hexToRGBA.d.ts +0 -2
  55. package/dist/utils/hexToRGBA.d.ts.map +0 -1
  56. package/dist/utils/scientificNotation.d.ts +0 -2
  57. package/dist/utils/scientificNotation.d.ts.map +0 -1
  58. package/dist/utils/setFromJson.d.ts +0 -3
  59. package/dist/utils/setFromJson.d.ts.map +0 -1
  60. package/dist/utils/translate.d.ts +0 -4
  61. package/dist/utils/translate.d.ts.map +0 -1
  62. package/dist/utils/updateSpecies.d.ts +0 -7
  63. package/dist/utils/updateSpecies.d.ts.map +0 -1
  64. /package/{dist → public}/logo.png +0 -0
  65. /package/{dist → public}/translate.csv +0 -0
  66. /package/{dist → public}/vite.svg +0 -0
@@ -0,0 +1,129 @@
1
+ import { Species } from "../classes/Species";
2
+ import { codeTextAlt } from "./translate";
3
+
4
+ export const saveSpecies = (
5
+ setSpecies: (sp?: Species) => void,
6
+ language: string
7
+ ) => async (
8
+ s: Species,
9
+ name: string,
10
+ apparition: number,
11
+ duration: number,
12
+ description: string,
13
+ image: string
14
+ ) => {
15
+ if(duration <= 0){
16
+ const alertText = await codeTextAlt("alert01", language, [name])
17
+ alert(alert);
18
+ throw new Error(alertText);
19
+ }
20
+ const newSpecies = s.copy();
21
+ setSpecies(undefined);
22
+ newSpecies.name = name;
23
+ newSpecies.apparition = apparition;
24
+ newSpecies.duration = duration;
25
+ newSpecies.description = description === "" ? undefined : description;
26
+ newSpecies.image = image === "" ? undefined : image;
27
+ setSpecies(newSpecies.firstAncestor());
28
+ };
29
+
30
+ export const createDescendant = (
31
+ setSpecies: (sp?: Species) => void,
32
+ language: string,
33
+ presentTimeBoolean: boolean,
34
+ setPresentTime: (time: number) => void,
35
+ setScale: (scale: number) => void
36
+ ) => async (
37
+ s: Species,
38
+ name: string,
39
+ afterApparition: number,
40
+ duration: number,
41
+ description: string,
42
+ image: string
43
+ ) => {
44
+ if(duration <= 0){
45
+ const alertText = await codeTextAlt("alert01", language, [name]);
46
+ alert(alertText);
47
+ throw new Error(alertText);
48
+ }
49
+ if(afterApparition < 0 || afterApparition > s.duration) {
50
+ const alertText = await codeTextAlt("alert02", language, [name, s.apparition.toString(), s.extinction().toString(), s.name]);
51
+ alert(alertText);
52
+ throw new Error(alertText);
53
+ }
54
+ const newSpecies = s.addDescendant(name, afterApparition, duration, description, image, true).firstAncestor();
55
+ //*
56
+ setSpecies(undefined);
57
+ if(presentTimeBoolean){
58
+ setPresentTime(newSpecies.absoluteExtinction());
59
+ }
60
+ setScale(newSpecies.absoluteDuration());
61
+ setSpecies(newSpecies);
62
+ //*/
63
+ };
64
+
65
+ export const createAncestor = (
66
+ setSpecies: (sp?: Species) => void,
67
+ language: string,
68
+ presentTimeBoolean: boolean,
69
+ setPresentTime: (time: number) => void,
70
+ setScale: (scale: number) => void
71
+ ) => async (
72
+ s: Species,
73
+ name: string,
74
+ previousApparition: number,
75
+ duration: number,
76
+ description: string,
77
+ image: string
78
+ ) => {
79
+ if(duration <= 0){
80
+ const alertText = await codeTextAlt("alert01", language, [name])
81
+ alert(alert);
82
+ throw new Error(alertText);
83
+ }
84
+ if(previousApparition < 0 || duration < previousApparition) {
85
+ const alertText = await codeTextAlt("alert02" + (duration < previousApparition) ? "_0" : "", language, [name, s.apparition.toString(), s.name]);
86
+ alert(alertText);
87
+ throw new Error(alertText);
88
+ }
89
+ const newSpecies = s.addAncestor(name, previousApparition, duration, description, image, true, true).firstAncestor();
90
+ //*
91
+ setSpecies(undefined);
92
+ if(presentTimeBoolean){
93
+ setPresentTime(newSpecies.absoluteExtinction());
94
+ }
95
+ setScale(newSpecies.absoluteDuration());
96
+ setSpecies(newSpecies);
97
+ //*/
98
+ };
99
+
100
+ export const deleteAncestor = (
101
+ sp: Species,
102
+ setSpecies: (sp?: Species) => void,
103
+ setScale: (scale: number) => void,
104
+ language: string
105
+ ) => async () => {
106
+ if(!confirm(await codeTextAlt("cnfrm00" + (sp.ancestor?.ancestor ? "_0" : ""), language, [sp.name]))) {
107
+ return;
108
+ }
109
+ setSpecies(undefined);
110
+ const removingAncestor = sp?.copy();
111
+ removingAncestor.ancestor = undefined;
112
+ setScale(removingAncestor.absoluteDuration());
113
+ setSpecies(removingAncestor);
114
+ };
115
+
116
+ export const deleteSpecies = (
117
+ sp: Species,
118
+ setSpecies: (sp?: Species) => void,
119
+ language: string
120
+ ) => async () => {
121
+ if(!confirm(await codeTextAlt("cnfrm01" + (sp.descendants.length > 0 ? "_0" : ""), language, [sp.name]))) {
122
+ return;
123
+ }
124
+ setSpecies(undefined);
125
+ const removingSpecies = sp?.copy();
126
+ const ancestor = removingSpecies?.ancestor;
127
+ ancestor?.removeDescendant(removingSpecies);
128
+ setSpecies(ancestor?.firstAncestor());
129
+ };
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2020",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
+ "module": "ESNext",
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "isolatedModules": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
+ "jsx": "react-jsx",
17
+
18
+ /* Linting */
19
+ "strict": true,
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noUncheckedSideEffectImports": true
24
+ },
25
+ "include": ["src"]
26
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+ "rootDir": "./src",
5
+ "target": "ES6",
6
+ "module": "ES6",
7
+ "moduleResolution": "Node",
8
+ "jsx": "react-jsx",
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "sourceMap": true,
12
+ "strict": true,
13
+ "skipLibCheck": true,
14
+ "esModuleInterop": true
15
+ },
16
+ "include": ["src/**/*.ts", "src/*.ts", "src/*.d.ts"]
17
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2022",
5
+ "lib": ["ES2023"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "isolatedModules": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+
16
+ /* Linting */
17
+ "strict": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedSideEffectImports": true
22
+ },
23
+ "include": ["vite.config.ts"]
24
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import tailwindcss from '@tailwindcss/vite'
4
+ import { dirname, resolve } from 'node:path'
5
+ import { fileURLToPath } from 'node:url'
6
+ import dts from 'vite-plugin-dts'
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url))
9
+
10
+ // https://vite.dev/config/
11
+ export default defineConfig({
12
+ plugins: [
13
+ react(),
14
+ tailwindcss(),
15
+ dts(),
16
+ ],
17
+ build: {
18
+ lib: {
19
+ entry: resolve(__dirname, 'src/index.ts'),
20
+ name: 'chrono-phylo-tree',
21
+ fileName: 'chrono-phylo-tree',
22
+ },
23
+ rollupOptions: {
24
+ external: ["react", "react-dom", "react/jsx-runtime"],
25
+ output: {
26
+ globals: {
27
+ react: "React",
28
+ "react-dom": "ReactDom",
29
+ "react/jsx-runtime": "react/jsx-runtime",
30
+ },
31
+ },
32
+ },
33
+ },
34
+ })
package/dist/App.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare function App(): import("react/jsx-runtime").JSX.Element;
2
- export default App;
3
- //# sourceMappingURL=App.d.ts.map
package/dist/App.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,CAAA;AAclB,iBAAS,GAAG,4CAmIX;AAED,eAAe,GAAG,CAAA"}