@rubin-epo/epo-widget-lib 2.0.8 → 2.0.9

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.
@@ -17,8 +17,8 @@ export type OrbitalSimContextValues = {
17
17
  showTimeControls?: boolean;
18
18
  setOrbits: React.Dispatch<React.SetStateAction<Orbits>>;
19
19
  observations: Observation[];
20
- setObservations: React.Dispatch<React.SetStateAction<Observation[]>>;
21
20
  updateActiveObservation: (activeId: string) => void;
21
+ selectedAnswer: string | null;
22
22
  swappableOrbits: boolean;
23
23
  };
24
24
  export type Observation = {
@@ -1 +1 @@
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:O=!1,selectedAnswer:i,updateSelectedAnswer:x,swappableOrbits:d=!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.label===i}));n(l)}},[i,e]);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:O,setOrbits:c,observations:e,setObservations:n,updateActiveObservation:S,selectedAnswer:i,swappableOrbits:d}),[a,v,m,O,c,e,n,S,i,d]);return C.jsx(b.Provider,{value:p,children:o})}exports.OrbitalSimContext=b;exports.OrbitalSimProvider=g;exports.useOrbitalSimContext=P;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),t=require("react"),c=t.createContext(null);function g(){const s=t.useContext(c);if(!s)throw new Error("OrbitalSim components cannot be rendered outside the OrbitalSimContext.Provider component.");return s}function j({children:s,orbitData:r,showDetailsTable:f=!1,allowOrbitRotation:b=!1,showTimeControls:v=!1,selectedAnswer:i,updateSelectedAnswer:x,swappableOrbits:m=!1}){const[l,u]=t.useState({neos:null,activeNeo:null,observations:[],paused:!1,pov:null,defaultZoom:null,potentialOrbits:!1,noDetails:!1,detailsRows:null,refObjs:null,noControls:!1}),[e,S]=t.useState(()=>l.observations??[]);t.useEffect(()=>{u(r),S(r.observations)},[r]);const d=t.useMemo(()=>e&&e.length>0?e.map(n=>({...n,isActive:n.label===i})):[],[i,e]),O=n=>{if(e&&e.length>0){let C=e.map(o=>o.id==n?{...o,isActive:!0}:{...o,isActive:!1});S(C);const a=e.find(o=>o.id===n);x((a==null?void 0:a.label)||null)}},p=t.useMemo(()=>({orbits:l,showDetailsTable:f,allowOrbitRotation:b,showTimeControls:v,setOrbits:u,observations:d,updateActiveObservation:O,selectedAnswer:i,swappableOrbits:m}),[l,f,b,v,u,d,O,i,m]);return P.jsx(c.Provider,{value:p,children:s})}exports.OrbitalSimContext=c;exports.OrbitalSimProvider=j;exports.useOrbitalSimContext=g;
@@ -1,26 +1,26 @@
1
1
  "use client";
2
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);
3
+ import { createContext as g, useState as p, useEffect as j, useMemo as x, useContext as A } from "react";
4
+ const O = g(null);
5
+ function N() {
6
+ const o = A(O);
7
7
  if (!o)
8
8
  throw new Error(
9
9
  "OrbitalSim components cannot be rendered outside the OrbitalSimContext.Provider component."
10
10
  );
11
11
  return o;
12
12
  }
13
- function N({
13
+ function W({
14
14
  children: o,
15
- orbitData: r,
16
- showDetailsTable: c = !1,
17
- allowOrbitRotation: m = !1,
18
- showTimeControls: v = !1,
15
+ orbitData: i,
16
+ showDetailsTable: a = !1,
17
+ allowOrbitRotation: f = !1,
18
+ showTimeControls: c = !1,
19
19
  selectedAnswer: s,
20
20
  updateSelectedAnswer: S,
21
- swappableOrbits: b = !1
21
+ swappableOrbits: v = !1
22
22
  }) {
23
- const [u, a] = p({
23
+ const [l, r] = p({
24
24
  neos: null,
25
25
  activeNeo: null,
26
26
  observations: [],
@@ -32,51 +32,47 @@ function N({
32
32
  detailsRows: null,
33
33
  refObjs: null,
34
34
  noControls: !1
35
- }), [t, e] = p(
36
- () => u.observations ?? []
35
+ }), [t, b] = p(
36
+ () => l.observations ?? []
37
37
  );
38
- O(() => {
39
- a(r), e(r.observations);
40
- }, [r]), O(() => {
38
+ j(() => {
39
+ r(i), b(i.observations);
40
+ }, [i]);
41
+ const m = x(
42
+ () => t && t.length > 0 ? t.map((e) => ({ ...e, isActive: e.label === s })) : [],
43
+ [s, t]
44
+ ), d = (e) => {
41
45
  if (t && t.length > 0) {
42
- let l = t.map((i) => ({ ...i, isActive: i.label === s }));
43
- e(l);
46
+ let h = t.map((n) => n.id == e ? { ...n, isActive: !0 } : { ...n, isActive: !1 });
47
+ b(h);
48
+ const u = t.find((n) => n.id === e);
49
+ S((u == null ? void 0 : u.label) || null);
44
50
  }
45
- }, [s, t]);
46
- const d = (l) => {
47
- if (t && t.length > 0) {
48
- let i = t.map((n) => n.id == l ? { ...n, isActive: !0 } : { ...n, isActive: !1 });
49
- e(i);
50
- const f = t.find((n) => n.id === l);
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,
51
+ }, C = x(() => ({
52
+ orbits: l,
53
+ showDetailsTable: a,
54
+ allowOrbitRotation: f,
55
+ showTimeControls: c,
56
+ setOrbits: r,
57
+ observations: m,
61
58
  updateActiveObservation: d,
62
59
  selectedAnswer: s,
63
- swappableOrbits: b
60
+ swappableOrbits: v
64
61
  }), [
65
- u,
62
+ l,
63
+ a,
64
+ f,
66
65
  c,
66
+ r,
67
67
  m,
68
- v,
69
- a,
70
- t,
71
- e,
72
68
  d,
73
69
  s,
74
- b
70
+ v
75
71
  ]);
76
- return /* @__PURE__ */ P(x.Provider, { value: C, children: o });
72
+ return /* @__PURE__ */ P(O.Provider, { value: C, children: o });
77
73
  }
78
74
  export {
79
- x as OrbitalSimContext,
80
- N as OrbitalSimProvider,
81
- M as useOrbitalSimContext
75
+ O as OrbitalSimContext,
76
+ W as OrbitalSimProvider,
77
+ N as useOrbitalSimContext
82
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubin-epo/epo-widget-lib",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "Rubin Observatory Education & Public Outreach team React scientific and educational widgets.",
5
5
  "author": "Rubin EPO",
6
6
  "license": "MIT",
@@ -102,7 +102,7 @@
102
102
  "dependencies": {
103
103
  "@react-three/drei": "^10.7.6",
104
104
  "@react-three/fiber": "9",
105
- "@rubin-epo/epo-react-lib": "3.0.1",
105
+ "@rubin-epo/epo-react-lib": "^3.0.1",
106
106
  "@rubin-epo/epo-widget-lib": "2.0.2",
107
107
  "context-filter-polyfill": "^0.3.6",
108
108
  "d3-array": "^3.2.4",