@rubin-epo/epo-widget-lib 2.0.2 → 2.0.4

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 (77) hide show
  1. package/dist/SortableTable.cjs +1 -0
  2. package/dist/SortableTable.d.ts +3 -0
  3. package/dist/SortableTable.js +5 -0
  4. package/dist/SourceSelector.cjs +1 -1
  5. package/dist/SourceSelector.js +6 -4
  6. package/dist/atomic/Blinker/Blinker.cjs +1 -1
  7. package/dist/atomic/Blinker/Blinker.d.ts +1 -0
  8. package/dist/atomic/Blinker/Blinker.js +27 -25
  9. package/dist/atomic/SelectionList/index.cjs +1 -0
  10. package/dist/{widgets/SourceSelector → atomic}/SelectionList/index.d.ts +1 -1
  11. package/dist/atomic/SelectionList/index.js +31 -0
  12. package/dist/localeStrings/en/epo-widget-lib.json +12 -3
  13. package/dist/localeStrings/es/epo-widget-lib.json +8 -5
  14. package/dist/mock-data/OrbitalSim/index.d.ts +162 -0
  15. package/dist/widgets/OrbitalSim/Context/OrbitalSimContext.types.d.ts +57 -0
  16. package/dist/widgets/OrbitalSim/Context/index.cjs +1 -1
  17. package/dist/widgets/OrbitalSim/Context/index.d.ts +2 -38
  18. package/dist/widgets/OrbitalSim/Context/index.js +61 -39
  19. package/dist/widgets/OrbitalSim/Controls/PlaybackSpeed.cjs +1 -1
  20. package/dist/widgets/OrbitalSim/Controls/PlaybackSpeed.js +53 -68
  21. package/dist/widgets/OrbitalSim/Controls/styles.cjs +38 -32
  22. package/dist/widgets/OrbitalSim/Controls/styles.d.ts +1 -0
  23. package/dist/widgets/OrbitalSim/Controls/styles.js +53 -46
  24. package/dist/widgets/OrbitalSim/Observations/Observation.cjs +1 -1
  25. package/dist/widgets/OrbitalSim/Observations/Observation.js +11 -10
  26. package/dist/widgets/OrbitalSim/Observations/styles.cjs +11 -0
  27. package/dist/widgets/OrbitalSim/Observations/styles.d.ts +1 -0
  28. package/dist/widgets/OrbitalSim/Observations/styles.js +16 -0
  29. package/dist/widgets/OrbitalSim/OrbitalSim.cjs +1 -1
  30. package/dist/widgets/OrbitalSim/OrbitalSim.js +94 -77
  31. package/dist/widgets/OrbitalSim/OrbitalSim.module.css.cjs +1 -1
  32. package/dist/widgets/OrbitalSim/OrbitalSim.module.css.js +2 -4
  33. package/dist/widgets/OrbitalSim/Orbitals/Orbital.cjs +1 -1
  34. package/dist/widgets/OrbitalSim/Orbitals/Orbital.js +41 -41
  35. package/dist/widgets/OrbitalSim/Orbitals/OrbitalDetails.cjs +1 -1
  36. package/dist/widgets/OrbitalSim/Orbitals/OrbitalDetails.js +19 -17
  37. package/dist/widgets/OrbitalSim/Orbitals/Orbitals.cjs +1 -1
  38. package/dist/widgets/OrbitalSim/Orbitals/Orbitals.d.ts +2 -1
  39. package/dist/widgets/OrbitalSim/Orbitals/Orbitals.js +41 -40
  40. package/dist/widgets/OrbitalSim/Orbitals/styles.cjs +15 -8
  41. package/dist/widgets/OrbitalSim/Orbitals/styles.js +17 -10
  42. package/dist/widgets/OrbitalSim/Sun.cjs +1 -1
  43. package/dist/widgets/OrbitalSim/Sun.js +13 -14
  44. package/dist/widgets/OrbitalSim/orbitalUtilities.cjs +1 -1
  45. package/dist/widgets/OrbitalSim/orbitalUtilities.d.ts +65 -0
  46. package/dist/widgets/OrbitalSim/orbitalUtilities.js +100 -57
  47. package/dist/widgets/OrbitalSim/styles.cjs +47 -12
  48. package/dist/widgets/OrbitalSim/styles.d.ts +3 -0
  49. package/dist/widgets/OrbitalSim/styles.js +52 -14
  50. package/dist/widgets/SortableTable/SortableTable.cjs +1 -0
  51. package/dist/widgets/SortableTable/SortableTable.d.ts +19 -0
  52. package/dist/widgets/SortableTable/SortableTable.js +41 -0
  53. package/dist/widgets/SortableTable/index.d.ts +1 -0
  54. package/dist/widgets/SortableTable/styles.cjs +8 -0
  55. package/dist/widgets/SortableTable/styles.d.ts +1 -0
  56. package/dist/widgets/SortableTable/styles.js +13 -0
  57. package/dist/widgets/SourceSelector/MovingSourceMap/index.cjs +1 -0
  58. package/dist/widgets/SourceSelector/MovingSourceMap/index.d.ts +13 -0
  59. package/dist/widgets/SourceSelector/MovingSourceMap/index.js +42 -0
  60. package/dist/widgets/SourceSelector/MovingSourceMap/styles.cjs +14 -0
  61. package/dist/widgets/SourceSelector/MovingSourceMap/styles.d.ts +2 -0
  62. package/dist/widgets/SourceSelector/MovingSourceMap/styles.js +20 -0
  63. package/dist/widgets/SourceSelector/MovingSourceSelector.cjs +1 -0
  64. package/dist/widgets/SourceSelector/MovingSourceSelector.d.ts +24 -0
  65. package/dist/widgets/SourceSelector/MovingSourceSelector.js +119 -0
  66. package/dist/widgets/SourceSelector/SourceSelector.cjs +1 -1
  67. package/dist/widgets/SourceSelector/SourceSelector.d.ts +1 -1
  68. package/dist/widgets/SourceSelector/SourceSelector.js +43 -42
  69. package/dist/widgets/SourceSelector/index.d.ts +2 -1
  70. package/dist/widgets/SourceSelector/mocks/index.d.ts +1 -0
  71. package/package.json +2 -1
  72. package/dist/widgets/OrbitalSim/Context/OrbitalSimContext.d.ts +0 -0
  73. package/dist/widgets/SourceSelector/SelectionList/index.cjs +0 -1
  74. package/dist/widgets/SourceSelector/SelectionList/index.js +0 -31
  75. /package/dist/{widgets/SourceSelector → atomic}/SelectionList/styles.cjs +0 -0
  76. /package/dist/{widgets/SourceSelector → atomic}/SelectionList/styles.d.ts +0 -0
  77. /package/dist/{widgets/SourceSelector → atomic}/SelectionList/styles.js +0 -0
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./widgets/SortableTable/SortableTable.cjs");exports.SortableTable=e.default;exports.default=e.default;
@@ -0,0 +1,3 @@
1
+ export * from './widgets/SortableTable/index'
2
+ import _default from './widgets/SortableTable/index'
3
+ export default _default
@@ -0,0 +1,5 @@
1
+ import { default as l, default as t } from "./widgets/SortableTable/SortableTable.js";
2
+ export {
3
+ l as SortableTable,
4
+ t as default
5
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./widgets/SourceSelector/SourceSelector.cjs"),t=require("./widgets/SourceSelector/SelectionList/index.cjs"),u=require("./widgets/SourceSelector/Message/Message.cjs");exports.default=e.default;exports.SelectionList=t.default;exports.Message=u.default;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./widgets/SourceSelector/SourceSelector.cjs"),t=require("./widgets/SourceSelector/MovingSourceSelector.cjs"),r=require("./atomic/SelectionList/index.cjs"),o=require("./widgets/SourceSelector/Message/Message.cjs");exports.default=e.default;exports.MovingSourceSelector=t.default;exports.SelectionList=r.default;exports.Message=o.default;
@@ -1,8 +1,10 @@
1
1
  import o from "./widgets/SourceSelector/SourceSelector.js";
2
- import { default as a } from "./widgets/SourceSelector/SelectionList/index.js";
3
- import { default as s } from "./widgets/SourceSelector/Message/Message.js";
2
+ import { default as a } from "./widgets/SourceSelector/MovingSourceSelector.js";
3
+ import { default as l } from "./atomic/SelectionList/index.js";
4
+ import { default as u } from "./widgets/SourceSelector/Message/Message.js";
4
5
  export {
5
- s as Message,
6
- a as SelectionList,
6
+ u as Message,
7
+ a as MovingSourceSelector,
8
+ l as SelectionList,
7
9
  o as default
8
10
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),h=require("react"),_=require("../../lib/utils.cjs"),k=require("../../hooks/useInterval.cjs"),C=require("../ImageStack/index.cjs"),D=require("./Controls/Controls.cjs"),g=require("./styles.cjs"),j=({images:n=[],activeIndex:i=0,autoplay:q=!0,loop:B=!0,interval:p=200,blinkCallback:s,onClickCallback:l,loadedCallback:u,className:y,showControls:S=!0,children:v,extraControls:m})=>{const[c,d]=h.useState(q),[a,I]=h.useState(!1),r=n.length>1,x=(e=0)=>{const N=n.length-1;return _.getClampedArrayIndex(i+e,N)},f=()=>{if(r){const e=x(1);B===!1&&e===n.length-1&&o(),s&&s(e)}},o=()=>{d(!1)},P=()=>{d(e=>!e)},A=()=>{o(),f()},M=()=>{o(),s&&s(x(-1))};return k.default(f,r&&a&&c?p:null),t.jsxs(g.BlinkerContainer,{"data-testid":"blinker-container",onClick:e=>l&&l(e),className:y,children:[t.jsx(C.default,{loadCallback:()=>{I(!0),u&&u()},visible:i,images:n}),v,t.jsx(g.ControlsContainer,{children:r&&S&&t.jsxs(t.Fragment,{children:[t.jsx(D.default,{isDisabled:!a,playing:c,handleStartStop:P,handleNext:A,handlePrevious:M}),m]})})]})};j.displayName="Atomic.Blinker";exports.default=j;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),h=require("react"),k=require("../../lib/utils.cjs"),C=require("../../hooks/useInterval.cjs"),D=require("../ImageStack/index.cjs"),F=require("./Controls/Controls.cjs"),g=require("./styles.cjs"),j=({images:n=[],activeIndex:i=0,autoplay:q=!0,loop:B=!0,interval:p=200,blinkCallback:s,onClickCallback:l,loadedCallback:u,className:y,showControls:S=!0,children:v,extraControls:m,pauseCallback:I=()=>{}})=>{const[c,d]=h.useState(q),[a,P]=h.useState(!1),r=n.length>1,x=(e=0)=>{const _=n.length-1;return k.getClampedArrayIndex(i+e,_)},f=()=>{if(r){const e=x(1);B===!1&&e===n.length-1&&o(),s&&s(e)}},o=()=>{d(!1)},A=()=>{I(),d(e=>!e)},M=()=>{o(),f()},N=()=>{o(),s&&s(x(-1))};return C.default(f,r&&a&&c?p:null),t.jsxs(g.BlinkerContainer,{"data-testid":"blinker-container",onClick:e=>l&&l(e),className:y,children:[t.jsx(D.default,{loadCallback:()=>{P(!0),u&&u()},visible:i,images:n}),v,t.jsx(g.ControlsContainer,{children:r&&S&&t.jsxs(t.Fragment,{children:[t.jsx(F.default,{isDisabled:!a,playing:c,handleStartStop:A,handleNext:M,handlePrevious:N}),m]})})]})};j.displayName="Atomic.Blinker";exports.default=j;
@@ -16,6 +16,7 @@ export interface BlinkerProps {
16
16
  className?: string;
17
17
  showControls?: boolean;
18
18
  extraControls?: ReactNode;
19
+ pauseCallback?: () => void;
19
20
  }
20
21
  declare const Blinker: FunctionComponent<PropsWithChildren<BlinkerProps>>;
21
22
  export default Blinker;
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { jsxs as u, jsx as s, Fragment as C } from "react/jsx-runtime";
2
+ import { jsxs as u, jsx as s, Fragment as D } from "react/jsx-runtime";
3
3
  import { useState as h } from "react";
4
- import { getClampedArrayIndex as D } from "../../lib/utils.js";
5
- import F from "../../hooks/useInterval.js";
6
- import L from "../ImageStack/index.js";
7
- import q from "./Controls/Controls.js";
8
- import { BlinkerContainer as w, ControlsContainer as z } from "./styles.js";
9
- const E = ({
4
+ import { getClampedArrayIndex as F } from "../../lib/utils.js";
5
+ import L from "../../hooks/useInterval.js";
6
+ import q from "../ImageStack/index.js";
7
+ import w from "./Controls/Controls.js";
8
+ import { BlinkerContainer as z, ControlsContainer as E } from "./styles.js";
9
+ const G = ({
10
10
  images: e = [],
11
11
  activeIndex: i = 0,
12
12
  autoplay: x = !0,
@@ -18,11 +18,13 @@ const E = ({
18
18
  className: y,
19
19
  showControls: I = !0,
20
20
  children: S,
21
- extraControls: j
21
+ extraControls: j,
22
+ pauseCallback: k = () => {
23
+ }
22
24
  }) => {
23
- const [d, m] = h(x), [c, k] = h(!1), r = e.length > 1, f = (t = 0) => {
24
- const P = e.length - 1;
25
- return D(i + t, P);
25
+ const [d, m] = h(x), [c, v] = h(!1), r = e.length > 1, f = (t = 0) => {
26
+ const C = e.length - 1;
27
+ return F(i + t, C);
26
28
  }, p = () => {
27
29
  if (r) {
28
30
  const t = f(1);
@@ -30,40 +32,40 @@ const E = ({
30
32
  }
31
33
  }, o = () => {
32
34
  m(!1);
33
- }, v = () => {
34
- m((t) => !t);
35
35
  }, A = () => {
36
- o(), p();
36
+ k(), m((t) => !t);
37
37
  }, N = () => {
38
+ o(), p();
39
+ }, P = () => {
38
40
  o(), n && n(f(-1));
39
41
  };
40
- return F(p, r && c && d ? g : null), /* @__PURE__ */ u(
41
- w,
42
+ return L(p, r && c && d ? g : null), /* @__PURE__ */ u(
43
+ z,
42
44
  {
43
45
  "data-testid": "blinker-container",
44
46
  onClick: (t) => l && l(t),
45
47
  className: y,
46
48
  children: [
47
49
  /* @__PURE__ */ s(
48
- L,
50
+ q,
49
51
  {
50
52
  loadCallback: () => {
51
- k(!0), a && a();
53
+ v(!0), a && a();
52
54
  },
53
55
  visible: i,
54
56
  images: e
55
57
  }
56
58
  ),
57
59
  S,
58
- /* @__PURE__ */ s(z, { children: r && I && /* @__PURE__ */ u(C, { children: [
60
+ /* @__PURE__ */ s(E, { children: r && I && /* @__PURE__ */ u(D, { children: [
59
61
  /* @__PURE__ */ s(
60
- q,
62
+ w,
61
63
  {
62
64
  isDisabled: !c,
63
65
  playing: d,
64
- handleStartStop: v,
65
- handleNext: A,
66
- handlePrevious: N
66
+ handleStartStop: A,
67
+ handleNext: N,
68
+ handlePrevious: P
67
69
  }
68
70
  ),
69
71
  j
@@ -72,7 +74,7 @@ const E = ({
72
74
  }
73
75
  );
74
76
  };
75
- E.displayName = "Atomic.Blinker";
77
+ G.displayName = "Atomic.Blinker";
76
78
  export {
77
- E as default
79
+ G as default
78
80
  };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("react-i18next"),s=require("./styles.cjs"),a=require("../Button/patterns/Reset.cjs"),n=({className:r,onRemoveCallback:c,sources:t=[]})=>{const{t:i}=u.useTranslation();return e.jsxs(s.SelectionWrapper,{children:[t.length>0&&e.jsx(s.SelectionList,{className:r,children:t.map(({type:o,id:l})=>e.jsxs(s.DescriptionWrapper,{children:[e.jsx("dt",{children:i("selection_list.selected_source",{type:i(`selection_list.sources.${o}`)})}),e.jsx("dd",{children:l})]},l))}),e.jsx(a.default,{isDisabled:t.length<1,onResetCallback:c})]})};n.displayName="Widgets.SelectionList";exports.default=n;
@@ -1,5 +1,5 @@
1
1
  import { FunctionComponent } from 'react';
2
- import { SourceType } from '../../../types/astro';
2
+ import { SourceType } from '../../types/astro';
3
3
 
4
4
  interface SelectionListProps {
5
5
  className?: string;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
3
+ import { useTranslation as c } from "react-i18next";
4
+ import { SelectionWrapper as a, SelectionList as p, DescriptionWrapper as d } from "./styles.js";
5
+ import m from "../Button/patterns/Reset.js";
6
+ const h = ({
7
+ className: n,
8
+ onRemoveCallback: r,
9
+ sources: t = []
10
+ }) => {
11
+ const { t: i } = c();
12
+ return /* @__PURE__ */ l(a, { children: [
13
+ t.length > 0 && /* @__PURE__ */ e(p, { className: n, children: t.map(({ type: o, id: s }) => /* @__PURE__ */ l(d, { children: [
14
+ /* @__PURE__ */ e("dt", { children: i("selection_list.selected_source", {
15
+ type: i(`selection_list.sources.${o}`)
16
+ }) }),
17
+ /* @__PURE__ */ e("dd", { children: s })
18
+ ] }, s)) }),
19
+ /* @__PURE__ */ e(
20
+ m,
21
+ {
22
+ isDisabled: t.length < 1,
23
+ onResetCallback: r
24
+ }
25
+ )
26
+ ] });
27
+ };
28
+ h.displayName = "Widgets.SelectionList";
29
+ export {
30
+ h as default
31
+ };
@@ -61,12 +61,15 @@
61
61
  "export": "Export"
62
62
  }
63
63
  },
64
- "source_selector": {
64
+ "selection_list": {
65
65
  "selected_source": "Selected {{type}}:",
66
66
  "sources": {
67
67
  "galaxy": "Galaxy",
68
- "supernova": "Supernova"
69
- },
68
+ "supernova": "Supernova",
69
+ "observation": "Observation"
70
+ }
71
+ },
72
+ "source_selector": {
70
73
  "messages": {
71
74
  "success": "You found it!",
72
75
  "failure": "Try again."
@@ -161,6 +164,7 @@
161
164
  }
162
165
  },
163
166
  "playback": {
167
+ "sec_with_count": "1 sec = {{count}} days",
164
168
  "time_equivalence": "1 sec is 1 year",
165
169
  "normal_time": "Normal Time",
166
170
  "time_step": "Time Step"
@@ -171,5 +175,10 @@
171
175
  "earth": "Earth",
172
176
  "mars": "Mars",
173
177
  "neptune": "Neptune"
178
+ },
179
+ "neo": {
180
+ "apollo": "Apollo",
181
+ "amor": "Amor",
182
+ "atira": "Atira"
174
183
  }
175
184
  }
@@ -48,15 +48,18 @@
48
48
  "export": "Exportar"
49
49
  }
50
50
  },
51
+ "selection_list": {
52
+ "selected_source": "{{type}} Seleccionada:",
53
+ "sources": {
54
+ "galaxy": "Galaxia",
55
+ "supernova": "Supernova",
56
+ "observation": "Observación"
57
+ }
58
+ },
51
59
  "source_selector": {
52
60
  "messages": {
53
61
  "success": "¡Muy bien!",
54
62
  "failure": "Inténtalo de nuevo."
55
- },
56
- "selected_source": "Seleccionada {{type}}:",
57
- "sources": {
58
- "galaxy": "Galaxia",
59
- "supernova": "Supernova"
60
63
  }
61
64
  },
62
65
  "camera_filter": {
@@ -0,0 +1,162 @@
1
+ export declare const SwappableOrbitsData: {
2
+ orbits: {
3
+ neos: {
4
+ a: number;
5
+ e: number;
6
+ i: number;
7
+ H: number;
8
+ Ref: string;
9
+ Principal_desig: string;
10
+ Translated_desig_key: string;
11
+ orbitColor: string;
12
+ objectColor: string;
13
+ objectRadius: number;
14
+ }[];
15
+ };
16
+ swappableOrbits: boolean;
17
+ };
18
+ export declare const PrimaryData: {
19
+ orbits: {
20
+ neos: {
21
+ NEO_flag: number;
22
+ One_km_NEO_flag: number;
23
+ H: number;
24
+ G: number;
25
+ Num_obs: number;
26
+ rms: number;
27
+ U: string;
28
+ Arc_years: string;
29
+ Perturbers: string;
30
+ Perturbers_2: string;
31
+ Number: string;
32
+ Name: string;
33
+ Principal_desig: string;
34
+ Epoch: number;
35
+ M: number;
36
+ Peri: number;
37
+ Node: number;
38
+ i: number;
39
+ e: number;
40
+ n: number;
41
+ a: number;
42
+ Ref: string;
43
+ Num_opps: number;
44
+ Computer: string;
45
+ Hex_flags: string;
46
+ Last_obs: string;
47
+ Tp: number;
48
+ Orbital_period: number;
49
+ Perihelion_dist: number;
50
+ Aphelion_dist: number;
51
+ Semilatus_rectum: number;
52
+ Synodic_period: number;
53
+ Orbit_type: string;
54
+ }[];
55
+ detailsRows: null;
56
+ };
57
+ activeObs: undefined;
58
+ selectionCallback: () => void;
59
+ paused: boolean;
60
+ pov: string;
61
+ defaultZoom: number;
62
+ potentialOrbits: null;
63
+ observations: null;
64
+ noDetails: boolean;
65
+ noControls: boolean;
66
+ detailsSet: null;
67
+ refObjs: string[];
68
+ noLabels: null;
69
+ };
70
+ export declare const PotentialOrbitsData: {
71
+ orbits: {
72
+ neos: ({
73
+ Node: number;
74
+ a: number;
75
+ e: number;
76
+ i: number;
77
+ Peri: number;
78
+ M: number;
79
+ Principal_desig: string;
80
+ Name: string;
81
+ Ref: string;
82
+ Epoch?: undefined;
83
+ } | {
84
+ Node: number;
85
+ a: number;
86
+ e: number;
87
+ i: number;
88
+ Peri: number;
89
+ M: number;
90
+ Epoch: string;
91
+ Principal_desig?: undefined;
92
+ Name?: undefined;
93
+ Ref?: undefined;
94
+ })[];
95
+ activeNeo: null;
96
+ activeObs: undefined;
97
+ selectionCallback: () => void;
98
+ paused: null;
99
+ pov: null;
100
+ defaultZoom: number;
101
+ potentialOrbits: boolean;
102
+ observations: ({
103
+ id: string;
104
+ label: string;
105
+ interactable: boolean;
106
+ isActive: boolean;
107
+ position: number;
108
+ isAnswer?: undefined;
109
+ } | {
110
+ id: string;
111
+ label: string;
112
+ interactable: boolean;
113
+ isActive: boolean;
114
+ position: number;
115
+ isAnswer: boolean;
116
+ })[];
117
+ detailsRows: null;
118
+ };
119
+ showTimeControls: boolean;
120
+ allowOrbitRotation: boolean;
121
+ noDetails: null;
122
+ detailsSet: null;
123
+ refObjs: null;
124
+ noLabels: null;
125
+ };
126
+ export declare const ObjectDetailsData: {
127
+ orbits: {
128
+ neos: {
129
+ H: number;
130
+ Principal_desig: string;
131
+ M: number;
132
+ Peri: number;
133
+ Node: number;
134
+ i: number;
135
+ e: number;
136
+ n: number;
137
+ a: number;
138
+ Ref: string;
139
+ Orbit_type: string;
140
+ diameter: number;
141
+ Earth_moid: number;
142
+ Jupiter_moid: number;
143
+ }[];
144
+ detailsRows: {
145
+ rowColor: string;
146
+ rowTitle: string;
147
+ rowContent: string;
148
+ }[];
149
+ };
150
+ showTimeControls: boolean;
151
+ showDetailsTable: boolean;
152
+ activeObs: undefined;
153
+ selectionCallback: () => void;
154
+ paused: null;
155
+ pov: null;
156
+ defaultZoom: null;
157
+ potentialOrbits: null;
158
+ observations: null;
159
+ detailsSet: string;
160
+ refObjs: null;
161
+ noLabels: null;
162
+ };
@@ -0,0 +1,57 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ export interface OrbitalSimProviderProps {
4
+ children: ReactNode;
5
+ orbitData: Orbits;
6
+ showDetailsTable?: boolean;
7
+ allowOrbitRotation?: boolean;
8
+ showTimeControls?: boolean;
9
+ selectedAnswer: string | null;
10
+ updateSelectedAnswer: (newSelectedAnswer: string | null) => void;
11
+ swappableOrbits?: boolean;
12
+ }
13
+ export type OrbitalSimContextValues = {
14
+ orbits: Orbits;
15
+ showDetailsTable?: boolean;
16
+ allowOrbitRotation?: boolean;
17
+ showTimeControls?: boolean;
18
+ setOrbits: React.Dispatch<React.SetStateAction<Orbits>>;
19
+ observations: Observation[];
20
+ setObservations: React.Dispatch<React.SetStateAction<Observation[]>>;
21
+ updateActiveObservation: (activeId: string) => void;
22
+ swappableOrbits: boolean;
23
+ };
24
+ export type Observation = {
25
+ id: string;
26
+ label: string;
27
+ interactable: boolean;
28
+ isActive: boolean;
29
+ position: number;
30
+ isAnswer?: boolean;
31
+ };
32
+ export type Neo = {
33
+ a: number;
34
+ e: number;
35
+ i: number;
36
+ Peri: number;
37
+ Node: number;
38
+ Ref: string;
39
+ Principal_desig: string;
40
+ };
41
+ export type DetailsRow = {
42
+ rowTitle: string;
43
+ rowContent: string | TrustedHTML;
44
+ };
45
+ export type Orbits = {
46
+ neos: Neo[] | null;
47
+ activeNeo: Neo | null;
48
+ observations: Observation[];
49
+ paused: boolean;
50
+ pov: string | null;
51
+ defaultZoom: number | null;
52
+ potentialOrbits: boolean;
53
+ noDetails: boolean;
54
+ detailsRows: DetailsRow[] | null;
55
+ refObjs: string[] | null;
56
+ noControls: boolean;
57
+ };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),e=require("react"),u=e.createContext(null);function d(){const n=e.useContext(u);if(!n)throw new Error("OrbitalSim components cannot be rendered outside the OrbitalSimContext.Provider component.");return n}function m({children:n,orbitData:l}){const[s,i]=e.useState({neos:null,activeNeo:null,observations:[],activeObs:null,selectionCallback:null,paused:null,pov:null,defaultZoom:null,potentialOrbits:null,noDetails:null,detailsSet:null,detailsRows:null,refObjs:null,noLabels:null,noControls:!1}),[t,o]=e.useState(()=>s.observations??[]);e.useEffect(()=>{i(l),o(l.observations)},[l]);const a=b=>{if(t&&t.length>0){let v=t.map(r=>r.id==b?{...r,isActive:!0}:{...r,isActive:!1});o(v)}},c=e.useMemo(()=>({orbits:s,setOrbits:i,observations:t,setObservations:o,updateActiveObservation:a}),[s,i,t,o,a]);return O.jsx(u.Provider,{value:c,children:n})}exports.OrbitalSimContext=u;exports.OrbitalSimProvider=m;exports.useOrbitalSimContext=d;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),t=require("react"),b=t.createContext(null);function P(){const o=t.useContext(b);if(!o)throw new Error("OrbitalSim components cannot be rendered outside the OrbitalSimContext.Provider component.");return o}function g({children:o,orbitData:u,showDetailsTable:v=!1,allowOrbitRotation:m=!1,showTimeControls:d=!1,selectedAnswer:i,updateSelectedAnswer:x,swappableOrbits:O=!1}){const[a,c]=t.useState({neos:null,activeNeo:null,observations:[],paused:!1,pov:null,defaultZoom:null,potentialOrbits:!1,noDetails:!1,detailsRows:null,refObjs:null,noControls:!1}),[e,n]=t.useState(()=>a.observations??[]);t.useEffect(()=>{c(u),n(u.observations)},[u]),t.useEffect(()=>{if(e&&e.length>0){let l=e.map(r=>({...r,isActive:r.id===i}));n(l)}},[i]);const S=l=>{if(e&&e.length>0){let r=e.map(s=>s.id==l?{...s,isActive:!0}:{...s,isActive:!1});n(r);const f=e.find(s=>s.id===l);x((f==null?void 0:f.label)||null)}},p=t.useMemo(()=>({orbits:a,showDetailsTable:v,allowOrbitRotation:m,showTimeControls:d,setOrbits:c,observations:e,setObservations:n,updateActiveObservation:S,selectedAnswer:i,swappableOrbits:O}),[a,v,m,d,c,e,n,S,i,O]);return C.jsx(b.Provider,{value:p,children:o})}exports.OrbitalSimContext=b;exports.OrbitalSimProvider=g;exports.useOrbitalSimContext=P;
@@ -1,41 +1,5 @@
1
- import { ReactNode } from 'react';
1
+ import { OrbitalSimContextValues, OrbitalSimProviderProps } from './OrbitalSimContext.types.ts';
2
2
 
3
- interface OrbitalSimProviderProps {
4
- children: ReactNode;
5
- orbitData: Orbits;
6
- }
7
- type OrbitalSimContextValues = {
8
- orbits: Orbits;
9
- setOrbits: React.Dispatch<React.SetStateAction<Orbits>>;
10
- observations: Observation[];
11
- setObservations: React.Dispatch<React.SetStateAction<Observation[]>>;
12
- updateActiveObservation: (activeId: string) => void;
13
- };
14
- type Observation = {
15
- id: string;
16
- label: string;
17
- interactable: boolean;
18
- isActive: boolean;
19
- position: number;
20
- isAnswer?: boolean;
21
- };
22
- type Orbits = {
23
- neos: any;
24
- activeNeo: any;
25
- observations: Observation[];
26
- activeObs: any;
27
- selectionCallback: any;
28
- paused: any;
29
- pov: any;
30
- defaultZoom: any;
31
- potentialOrbits: any;
32
- noDetails: any;
33
- detailsSet: any;
34
- detailsRows: any;
35
- refObjs: any;
36
- noLabels: any;
37
- noControls: boolean;
38
- };
39
3
  export declare const OrbitalSimContext: import('react').Context<OrbitalSimContextValues | null>;
40
4
  export default OrbitalSimContext;
41
5
  /**
@@ -63,4 +27,4 @@ export declare function useOrbitalSimContext(): OrbitalSimContextValues;
63
27
  *
64
28
  * @returns
65
29
  */
66
- export declare function OrbitalSimProvider({ children, orbitData }: OrbitalSimProviderProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function OrbitalSimProvider({ children, orbitData, showDetailsTable, allowOrbitRotation, showTimeControls, selectedAnswer, updateSelectedAnswer, swappableOrbits }: OrbitalSimProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,60 +1,82 @@
1
1
  "use client";
2
- import { jsx as m } from "react/jsx-runtime";
3
- import { createContext as d, useState as u, useEffect as f, useMemo as O, useContext as p } from "react";
4
- const a = d(null);
5
- function S() {
6
- const t = p(a);
7
- if (!t)
2
+ import { jsx as P } from "react/jsx-runtime";
3
+ import { createContext as g, useState as p, useEffect as O, useMemo as h, useContext as j } from "react";
4
+ const x = g(null);
5
+ function M() {
6
+ const o = j(x);
7
+ if (!o)
8
8
  throw new Error(
9
9
  "OrbitalSim components cannot be rendered outside the OrbitalSimContext.Provider component."
10
10
  );
11
- return t;
11
+ return o;
12
12
  }
13
- function w({ children: t, orbitData: o }) {
14
- const [l, s] = u({
13
+ function N({
14
+ children: o,
15
+ orbitData: r,
16
+ showDetailsTable: c = !1,
17
+ allowOrbitRotation: m = !1,
18
+ showTimeControls: v = !1,
19
+ selectedAnswer: s,
20
+ updateSelectedAnswer: S,
21
+ swappableOrbits: b = !1
22
+ }) {
23
+ const [u, a] = p({
15
24
  neos: null,
16
25
  activeNeo: null,
17
26
  observations: [],
18
- activeObs: null,
19
- selectionCallback: null,
20
- paused: null,
27
+ paused: !1,
21
28
  pov: null,
22
29
  defaultZoom: null,
23
- potentialOrbits: null,
24
- noDetails: null,
25
- detailsSet: null,
30
+ potentialOrbits: !1,
31
+ noDetails: !1,
26
32
  detailsRows: null,
27
33
  refObjs: null,
28
- noLabels: null,
29
34
  noControls: !1
30
- }), [e, n] = u(
31
- () => l.observations ?? []
35
+ }), [t, e] = p(
36
+ () => u.observations ?? []
32
37
  );
33
- f(() => {
34
- s(o), n(o.observations);
35
- }, [o]);
36
- const r = (b) => {
37
- if (e && e.length > 0) {
38
- let v = e.map((i) => i.id == b ? { ...i, isActive: !0 } : { ...i, isActive: !1 });
39
- n(v);
38
+ O(() => {
39
+ a(r), e(r.observations);
40
+ }, [r]), O(() => {
41
+ if (t && t.length > 0) {
42
+ let i = t.map((l) => ({ ...l, isActive: l.id === s }));
43
+ e(i);
40
44
  }
41
- }, c = O(() => ({
42
- orbits: l,
43
- setOrbits: s,
44
- observations: e,
45
- setObservations: n,
46
- updateActiveObservation: r
45
+ }, [s]);
46
+ const d = (i) => {
47
+ if (t && t.length > 0) {
48
+ let l = t.map((n) => n.id == i ? { ...n, isActive: !0 } : { ...n, isActive: !1 });
49
+ e(l);
50
+ const f = t.find((n) => n.id === i);
51
+ S((f == null ? void 0 : f.label) || null);
52
+ }
53
+ }, C = h(() => ({
54
+ orbits: u,
55
+ showDetailsTable: c,
56
+ allowOrbitRotation: m,
57
+ showTimeControls: v,
58
+ setOrbits: a,
59
+ observations: t,
60
+ setObservations: e,
61
+ updateActiveObservation: d,
62
+ selectedAnswer: s,
63
+ swappableOrbits: b
47
64
  }), [
48
- l,
49
- s,
65
+ u,
66
+ c,
67
+ m,
68
+ v,
69
+ a,
70
+ t,
50
71
  e,
51
- n,
52
- r
72
+ d,
73
+ s,
74
+ b
53
75
  ]);
54
- return /* @__PURE__ */ m(a.Provider, { value: c, children: t });
76
+ return /* @__PURE__ */ P(x.Provider, { value: C, children: o });
55
77
  }
56
78
  export {
57
- a as OrbitalSimContext,
58
- w as OrbitalSimProvider,
59
- S as useOrbitalSimContext
79
+ x as OrbitalSimContext,
80
+ N as OrbitalSimProvider,
81
+ M as useOrbitalSimContext
60
82
  };