@rubin-epo/epo-widget-lib 2.0.3 → 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 (60) 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 +11 -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 +12 -0
  16. package/dist/widgets/OrbitalSim/Context/index.cjs +1 -1
  17. package/dist/widgets/OrbitalSim/Context/index.d.ts +1 -1
  18. package/dist/widgets/OrbitalSim/Context/index.js +58 -32
  19. package/dist/widgets/OrbitalSim/OrbitalSim.cjs +1 -1
  20. package/dist/widgets/OrbitalSim/OrbitalSim.js +94 -77
  21. package/dist/widgets/OrbitalSim/Orbitals/Orbital.cjs +1 -1
  22. package/dist/widgets/OrbitalSim/Orbitals/Orbital.js +41 -41
  23. package/dist/widgets/OrbitalSim/Orbitals/OrbitalDetails.cjs +1 -1
  24. package/dist/widgets/OrbitalSim/Orbitals/OrbitalDetails.js +21 -23
  25. package/dist/widgets/OrbitalSim/Orbitals/Orbitals.cjs +1 -1
  26. package/dist/widgets/OrbitalSim/Orbitals/Orbitals.d.ts +2 -1
  27. package/dist/widgets/OrbitalSim/Orbitals/Orbitals.js +41 -40
  28. package/dist/widgets/OrbitalSim/orbitalUtilities.cjs +1 -1
  29. package/dist/widgets/OrbitalSim/orbitalUtilities.d.ts +65 -0
  30. package/dist/widgets/OrbitalSim/orbitalUtilities.js +100 -57
  31. package/dist/widgets/OrbitalSim/styles.cjs +33 -5
  32. package/dist/widgets/OrbitalSim/styles.d.ts +2 -0
  33. package/dist/widgets/OrbitalSim/styles.js +36 -6
  34. package/dist/widgets/SortableTable/SortableTable.cjs +1 -0
  35. package/dist/widgets/SortableTable/SortableTable.d.ts +19 -0
  36. package/dist/widgets/SortableTable/SortableTable.js +41 -0
  37. package/dist/widgets/SortableTable/index.d.ts +1 -0
  38. package/dist/widgets/SortableTable/styles.cjs +8 -0
  39. package/dist/widgets/SortableTable/styles.d.ts +1 -0
  40. package/dist/widgets/SortableTable/styles.js +13 -0
  41. package/dist/widgets/SourceSelector/MovingSourceMap/index.cjs +1 -0
  42. package/dist/widgets/SourceSelector/MovingSourceMap/index.d.ts +13 -0
  43. package/dist/widgets/SourceSelector/MovingSourceMap/index.js +42 -0
  44. package/dist/widgets/SourceSelector/MovingSourceMap/styles.cjs +14 -0
  45. package/dist/widgets/SourceSelector/MovingSourceMap/styles.d.ts +2 -0
  46. package/dist/widgets/SourceSelector/MovingSourceMap/styles.js +20 -0
  47. package/dist/widgets/SourceSelector/MovingSourceSelector.cjs +1 -0
  48. package/dist/widgets/SourceSelector/MovingSourceSelector.d.ts +24 -0
  49. package/dist/widgets/SourceSelector/MovingSourceSelector.js +119 -0
  50. package/dist/widgets/SourceSelector/SourceSelector.cjs +1 -1
  51. package/dist/widgets/SourceSelector/SourceSelector.d.ts +1 -1
  52. package/dist/widgets/SourceSelector/SourceSelector.js +43 -42
  53. package/dist/widgets/SourceSelector/index.d.ts +2 -1
  54. package/dist/widgets/SourceSelector/mocks/index.d.ts +1 -0
  55. package/package.json +1 -1
  56. package/dist/widgets/SourceSelector/SelectionList/index.cjs +0 -1
  57. package/dist/widgets/SourceSelector/SelectionList/index.js +0 -31
  58. /package/dist/{widgets/SourceSelector → atomic}/SelectionList/styles.cjs +0 -0
  59. /package/dist/{widgets/SourceSelector → atomic}/SelectionList/styles.d.ts +0 -0
  60. /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."
@@ -172,5 +175,10 @@
172
175
  "earth": "Earth",
173
176
  "mars": "Mars",
174
177
  "neptune": "Neptune"
178
+ },
179
+ "neo": {
180
+ "apollo": "Apollo",
181
+ "amor": "Amor",
182
+ "atira": "Atira"
175
183
  }
176
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
+ };
@@ -3,13 +3,23 @@ import { ReactNode } from 'react';
3
3
  export interface OrbitalSimProviderProps {
4
4
  children: ReactNode;
5
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;
6
12
  }
7
13
  export type OrbitalSimContextValues = {
8
14
  orbits: Orbits;
15
+ showDetailsTable?: boolean;
16
+ allowOrbitRotation?: boolean;
17
+ showTimeControls?: boolean;
9
18
  setOrbits: React.Dispatch<React.SetStateAction<Orbits>>;
10
19
  observations: Observation[];
11
20
  setObservations: React.Dispatch<React.SetStateAction<Observation[]>>;
12
21
  updateActiveObservation: (activeId: string) => void;
22
+ swappableOrbits: boolean;
13
23
  };
14
24
  export type Observation = {
15
25
  id: string;
@@ -25,6 +35,8 @@ export type Neo = {
25
35
  i: number;
26
36
  Peri: number;
27
37
  Node: number;
38
+ Ref: string;
39
+ Principal_desig: string;
28
40
  };
29
41
  export type DetailsRow = {
30
42
  rowTitle: string;
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),e=require("react"),a=e.createContext(null);function O(){const o=e.useContext(a);if(!o)throw new Error("OrbitalSim components cannot be rendered outside the OrbitalSimContext.Provider component.");return o}function d({children:o,orbitData:s}){const[i,r]=e.useState({neos:null,activeNeo:null,observations:[],paused:!1,pov:null,defaultZoom:null,potentialOrbits:!1,noDetails:!1,detailsRows:null,refObjs:null,noControls:!1}),[t,n]=e.useState(()=>i.observations??[]);e.useEffect(()=>{r(s),n(s.observations)},[s]);const u=b=>{if(t&&t.length>0){let v=t.map(l=>l.id==b?{...l,isActive:!0}:{...l,isActive:!1});n(v)}},c=e.useMemo(()=>({orbits:i,setOrbits:r,observations:t,setObservations:n,updateActiveObservation:u}),[i,r,t,n,u]);return m.jsx(a.Provider,{value:c,children:o})}exports.OrbitalSimContext=a;exports.OrbitalSimProvider=d;exports.useOrbitalSimContext=O;
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;
@@ -27,4 +27,4 @@ export declare function useOrbitalSimContext(): OrbitalSimContextValues;
27
27
  *
28
28
  * @returns
29
29
  */
30
- 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,17 +1,26 @@
1
1
  "use client";
2
- import { jsx as f } from "react/jsx-runtime";
3
- import { createContext as m, useState as a, useEffect as d, useMemo as O, useContext as p } from "react";
4
- const u = m(null);
5
- function S() {
6
- const t = p(u);
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: n }) {
14
- const [s, i] = a({
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: [],
@@ -23,34 +32,51 @@ function w({ children: t, orbitData: n }) {
23
32
  detailsRows: null,
24
33
  refObjs: null,
25
34
  noControls: !1
26
- }), [e, o] = a(
27
- () => s.observations ?? []
35
+ }), [t, e] = p(
36
+ () => u.observations ?? []
28
37
  );
29
- d(() => {
30
- i(n), o(n.observations);
31
- }, [n]);
32
- const l = (v) => {
33
- if (e && e.length > 0) {
34
- let b = e.map((r) => r.id == v ? { ...r, isActive: !0 } : { ...r, isActive: !1 });
35
- o(b);
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);
36
44
  }
37
- }, c = O(() => ({
38
- orbits: s,
39
- setOrbits: i,
40
- observations: e,
41
- setObservations: o,
42
- updateActiveObservation: l
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
43
64
  }), [
44
- s,
45
- i,
65
+ u,
66
+ c,
67
+ m,
68
+ v,
69
+ a,
70
+ t,
46
71
  e,
47
- o,
48
- l
72
+ d,
73
+ s,
74
+ b
49
75
  ]);
50
- return /* @__PURE__ */ f(u.Provider, { value: c, children: t });
76
+ return /* @__PURE__ */ P(x.Provider, { value: C, children: o });
51
77
  }
52
78
  export {
53
- u as OrbitalSimContext,
54
- w as OrbitalSimProvider,
55
- S as useOrbitalSimContext
79
+ x as OrbitalSimContext,
80
+ N as OrbitalSimProvider,
81
+ M as useOrbitalSimContext
56
82
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),t=require("react"),R=require("./Orbitals/OrbitalDetails.cjs"),T=require("./Camera/CameraController.cjs"),E=require("./Camera/Camera.cjs"),F=require("./Orbitals/Orbitals.cjs"),M=require("./Sun.cjs"),V=require("./Controls/PlaybackSpeed.cjs"),W=require("./Controls/PlaybackControls.cjs"),m=require("./styles.cjs"),_=require("./Context/index.cjs");function G(){const{orbits:q}=_.useOrbitalSimContext(),{paused:l,pov:y,defaultZoom:n,potentialOrbits:S,noDetails:O,noControls:g=!1}=q,u={min:1157e-8,max:365.25,initial:11.574,step:1},[r,a]=t.useState(!l),[v,o]=t.useState(1),[C,p]=t.useState(0),[b,x]=t.useState(l?0:u.initial),[j,c]=t.useState(0),[i,d]=t.useState(0),[h,D]=t.useState(1);t.useEffect(()=>{i>0?(x(u.initial),o(1),c(0),d(-1)):i<0&&(c(0),a(!0),d(0))},[i]);const P=s=>{x(+s)},Z=()=>{r||o(1),a(!r)},k=()=>{a(s=>!1),d(s=>s+1)},z=s=>{a(!1),o(1),p(f=>f+1)},L=s=>{a(!1),o(-1),p(f=>f+1)};return e.jsxs(e.Fragment,{children:[e.jsx(m.GlobalStyles,{}),e.jsxs(m.OrbitalSimWrapper,{children:[!S&&!O&&e.jsx(R.default,{}),!l&&e.jsx(V.default,{elapsedTime:j,dayPerVizSec:b,speeds:u,sliderOnChangeCallback:P}),!g&&e.jsx(W.default,{playing:r,handleStartStop:Z,handleNext:z,handlePrevious:L,isDisabled:!1,handleReset:k}),e.jsxs(m.CanvasWrapper,{orthographic:!0,children:[e.jsx(T.default,{pov:y,reset:i}),e.jsx(E.default,{left:5e3,right:15e3,top:15e3,bottom:-15e3,near:.1,far:3e4,position:[0,0,8e3],defaultZoom:n||1}),e.jsx("ambientLight",{intensity:.9}),e.jsx(F.default,{defaultZoom:n||1,playing:r,stepDirection:v,dayPerVizSec:b,frameOverride:C,potentialOrbits:S,elapsedTime:j,setElapsedTime:c,reset:i,zoomLevel:h,setZoomLevel:D}),e.jsx(M.default,{zoomLevel:h,defaultZoom:n||1})]})]})]})}exports.default=G;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),s=require("react"),M=require("./Orbitals/OrbitalDetails.cjs"),V=require("./Camera/CameraController.cjs"),W=require("./Camera/Camera.cjs"),B=require("./Orbitals/Orbitals.cjs"),G=require("./Sun.cjs"),N=require("./Controls/PlaybackSpeed.cjs"),A=require("./Controls/PlaybackControls.cjs"),l=require("./styles.cjs"),H=require("./Context/index.cjs");function I(){const{orbits:i,showDetailsTable:q,allowOrbitRotation:v,showTimeControls:m,swappableOrbits:x}=H.useOrbitalSimContext(),{paused:h,pov:y,defaultZoom:c,potentialOrbits:w,detailsRows:P}=i,u={min:1157e-8,max:365.25,initial:11.574,step:1},[n,a]=s.useState(!h),[D,o]=s.useState(1),[R,j]=s.useState(0),[O,d]=s.useState(h?0:u.initial),[g,p]=s.useState(0),[r,b]=s.useState(0),[C,k]=s.useState(1),[f,T]=s.useState({neos:[{Principal_desig:""}]});s.useEffect(()=>{m||(a(!1),d(0)),r>0?(d(u.initial),o(1),p(0),b(-1)):r<0&&(p(0),a(!0),b(0))},[r]);const Z=t=>{d(+t)},_=()=>{n||o(1),a(!n)},F=()=>{a(t=>!1),b(t=>t+1)},z=t=>{a(!1),o(1),j(S=>S+1)},L=t=>{a(!1),o(-1),j(S=>S+1)},E=t=>{T({neos:[t]})};return e.jsxs(e.Fragment,{children:[e.jsx(l.GlobalStyles,{}),e.jsxs(l.OrbitalSimWrapper,{children:[x?e.jsx(l.SwappableOrbitsContainer,{children:i&&i.neos&&i.neos.map(t=>e.jsx(l.SwappableOrbitButton,{onClick:()=>E(t),"data-active":Object.keys(f).length?t.Principal_desig===f.neos[0].Principal_desig:!1,children:t.Ref}))}):e.jsxs(e.Fragment,{children:[P&&q&&e.jsx(M.default,{}),m&&e.jsxs(e.Fragment,{children:[e.jsx(N.default,{elapsedTime:g,dayPerVizSec:O,speeds:u,sliderOnChangeCallback:Z}),e.jsx(A.default,{playing:n,handleStartStop:_,handleNext:z,handlePrevious:L,isDisabled:!1,handleReset:F})]})]}),e.jsxs(l.CanvasWrapper,{orthographic:!0,children:[e.jsx(V.default,{pov:v?null:y??"top",reset:r}),e.jsx(W.default,{left:5e3,right:15e3,top:15e3,bottom:-15e3,near:.1,far:3e4,position:[0,0,8e3],defaultZoom:c||1}),e.jsx("ambientLight",{intensity:.9}),e.jsx(B.default,{defaultZoom:c||1,playing:n,stepDirection:D,dayPerVizSec:O,frameOverride:R,potentialOrbits:w,elapsedTime:g,setElapsedTime:p,reset:r,zoomLevel:C,setZoomLevel:k,orbits:x?f:i}),e.jsx(G.default,{zoomLevel:C,defaultZoom:c||1})]})]})]})}exports.default=I;