@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
+ export { default, default as SortableTable } from './SortableTable';
@@ -0,0 +1,8 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("styled-components"),l=e=>e&&e.__esModule?e:{default:e},d=l(t),o=d.default.table`
2
+ border: 1px solid #000000;
3
+ text-align: center;
4
+ border-spacing: 0px;
5
+ & > th, td, thead, thead > tr > th{
6
+ border: 1px solid #000000;
7
+ }
8
+ `;exports.Table=o;
@@ -0,0 +1 @@
1
+ export declare const Table: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, never>> & string;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import t from "styled-components";
3
+ const r = t.table`
4
+ border: 1px solid #000000;
5
+ text-align: center;
6
+ border-spacing: 0px;
7
+ & > th, td, thead, thead > tr > th{
8
+ border: 1px solid #000000;
9
+ }
10
+ `;
11
+ export {
12
+ r as Table
13
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),o=require("../utils.cjs"),n=require("./styles.cjs"),p=(e,r)=>typeof e=="string"?e.includes("%")?`${100-parseFloat(e)}%`:r-parseFloat(e):r-e,a=({width:e,height:r,movingSources:i,selectedSource:d,currentIndex:c})=>s.jsxs(s.Fragment,{children:[" ",i&&i.map((t,u)=>{let l=t.sources[c];if(d.includes(t.id))return s.jsx(n.SVG,{preserveAspectRatio:"xMidYMid meet",viewBox:`0 0 ${e} ${r}`,children:s.jsx("g",{role:"list",children:s.jsx(n.Point,{cx:l.x,cy:p(l.y,r),fill:"transparent",stroke:t.color??"#fed828",strokeWidth:3,tabIndex:0,role:"listitem",r:`${o.getRadius(t.type,NaN)*100}%`,id:`${t.id}`},`${t.id}-${u}`)})})})]});a.displayName="Widgets.MovingSourceMap";exports.default=a;
@@ -0,0 +1,13 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { MovingSources } from '../../../types/astro';
3
+
4
+ export interface MovingSourceMapProps {
5
+ width: number;
6
+ height: number;
7
+ isPlaying: boolean;
8
+ movingSources: MovingSources[];
9
+ selectedSource: string[];
10
+ currentIndex: number;
11
+ }
12
+ declare const MovingSourceMap: FunctionComponent<MovingSourceMapProps>;
13
+ export default MovingSourceMap;
@@ -0,0 +1,42 @@
1
+ import { jsxs as o, Fragment as p, jsx as s } from "react/jsx-runtime";
2
+ import { getRadius as c } from "../utils.js";
3
+ import { SVG as f, Point as x } from "./styles.js";
4
+ const $ = (e, r) => typeof e == "string" ? e.includes("%") ? `${100 - parseFloat(e)}%` : r - parseFloat(e) : r - e, m = ({
5
+ width: e,
6
+ height: r,
7
+ movingSources: i,
8
+ selectedSource: d,
9
+ currentIndex: n
10
+ }) => /* @__PURE__ */ o(p, { children: [
11
+ " ",
12
+ i && i.map((t, l) => {
13
+ let a = t.sources[n];
14
+ if (d.includes(t.id))
15
+ return /* @__PURE__ */ s(
16
+ f,
17
+ {
18
+ preserveAspectRatio: "xMidYMid meet",
19
+ viewBox: `0 0 ${e} ${r}`,
20
+ children: /* @__PURE__ */ s("g", { role: "list", children: /* @__PURE__ */ s(
21
+ x,
22
+ {
23
+ cx: a.x,
24
+ cy: $(a.y, r),
25
+ fill: "transparent",
26
+ stroke: t.color ?? "#fed828",
27
+ strokeWidth: 3,
28
+ tabIndex: 0,
29
+ role: "listitem",
30
+ r: `${c(t.type, NaN) * 100}%`,
31
+ id: `${t.id}`
32
+ },
33
+ `${t.id}-${l}`
34
+ ) })
35
+ }
36
+ );
37
+ })
38
+ ] });
39
+ m.displayName = "Widgets.MovingSourceMap";
40
+ export {
41
+ m as default
42
+ };
@@ -0,0 +1,14 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("styled-components"),n=t=>t&&t.__esModule?t:{default:t},e=n(o),s=e.default.svg`
2
+ pointer-events: none;
3
+ position: absolute;
4
+ bottom: 0;
5
+ left: 0;
6
+ `,r=e.default.circle`
7
+ cursor: pointer;
8
+ transition: transform ease var(--DURATION, 0.2s);
9
+ transform-origin: center;
10
+
11
+ &:focus {
12
+ outline: none;
13
+ }
14
+ `;exports.Point=r;exports.SVG=s;
@@ -0,0 +1,2 @@
1
+ export declare const SVG: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').SVGProps<SVGSVGElement>, never>> & string;
2
+ export declare const Point: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').SVGProps<SVGCircleElement>, never>> & string;
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import o from "styled-components";
3
+ const n = o.svg`
4
+ pointer-events: none;
5
+ position: absolute;
6
+ bottom: 0;
7
+ left: 0;
8
+ `, e = o.circle`
9
+ cursor: pointer;
10
+ transition: transform ease var(--DURATION, 0.2s);
11
+ transform-origin: center;
12
+
13
+ &:focus {
14
+ outline: none;
15
+ }
16
+ `;
17
+ export {
18
+ e as Point,
19
+ n as SVG
20
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),u=require("react"),G=require("react-i18next"),J=require("../../layout/AspectRatio/index.cjs"),K=require("../../atomic/Loader/index.cjs"),Q=require("@rubin-epo/epo-react-lib/IconComposer"),U=require("./MovingSourceMap/index.cjs"),k=require("./utils.cjs"),Z=require("./styles.cjs"),O=require("../../hooks/useInterval.cjs"),ee=require("./Message/Message.cjs"),te=require("../../atomic/ElapsedTime/ElapsedTime.cjs"),se=e=>e&&e.__esModule?e:{default:e},ne=se(Q),oe=(e,n)=>{var l;const t={day:0,hour:0},s=e[n];if(!s)return t;const c=(s==null?void 0:s.date)-((l=e[0])==null?void 0:l.date);return c?{day:Math.round(c)||0,hour:Math.round(24/c%24)||0}:t},re=(e,n,t)=>Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)<=Math.pow(t,2),ce=(e,n,t)=>t?e[n]?[e[n].image]:[]:e.map(({image:s})=>s),j=({width:e=600,height:n=600,selectedSource:t=[],alerts:s=[],activeAlertIndex:c=0,alertChangeCallback:l,selectionCallback:p,blinkConfig:_,isDisplayOnly:d=!1,isLoading:P,className:w,movingSources:i=[]})=>{const[f,q]=u.useState(0),[B,F]=u.useState(!0),[b,L]=u.useState(!0),[R,y]=u.useState(),[T,m]=u.useState(!1),{t:I}=G.useTranslation(),S=!B&&!P,V=(r,g,h)=>{if(i)for(let a of i){const x=a.sources[f];if(re(r,{x:k.toDecimalPercent(x.x)*g,y:k.toDecimalPercent(x.y)*h},k.getRadius(a.type,a.radius)*g))return a.id}},v=()=>{y(I("source_selector.messages.failure")),m(!0)},D=()=>{L(r=>!r)},N=()=>{y(o.jsxs(o.Fragment,{children:[o.jsx(ne.default,{icon:"checkmark"}),I("source_selector.messages.success")]})),m(!0)},W=({clientX:r,clientY:g,target:h})=>{if(!S||d)return;const{tagName:a,clientWidth:x,clientHeight:C}=h;if(a.toLowerCase()!=="img")return;const{left:Y,top:A}=h.getBoundingClientRect(),M=V({x:r-Y,y:C-g+A},x,C);if(M){if(t.includes(M))return;p&&p(t.concat(M)),N()}else v()},$=()=>{m(!1)},{day:z,hour:E}=oe(s,c),H=ce(s,c,d),X=()=>{b&&(f>i[0].sources.length-2?q(0):q(r=>r+1))};return O.default(X,500),o.jsxs(J.default,{ratio:1,className:w,children:[!d&&o.jsx(ee.default,{onMessageChangeCallback:$,isVisible:T,children:R}),i&&o.jsx(Z.BackgroundBlinker,{images:H,activeIndex:f,blinkCallback:l,loadedCallback:()=>F(!1),onClickCallback:W,extraControls:s.length>0&&!d&&o.jsx(te.default,{day:z,hour:E}),interval:400,pauseCallback:D,..._,children:o.jsx(U.default,{width:e,height:n,isPlaying:b,currentIndex:f,movingSources:i,selectedSource:t})}),!S&&o.jsx(K.default,{})]})};j.displayName="Widgets.MovingSourceSelector";exports.default=j;
@@ -0,0 +1,24 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { Alert, MovingSources } from '../../types/astro';
3
+
4
+ interface BlinkConfig {
5
+ autoplay?: boolean;
6
+ loop?: boolean;
7
+ duration?: number;
8
+ }
9
+ interface SourceSelectorProps {
10
+ width?: number;
11
+ height?: number;
12
+ alerts: Alert[];
13
+ selectedSource?: string[];
14
+ activeAlertIndex?: number;
15
+ alertChangeCallback?: (index: number) => void;
16
+ selectionCallback?: (data: string[]) => void;
17
+ blinkConfig?: BlinkConfig;
18
+ isDisplayOnly?: boolean;
19
+ isLoading?: boolean;
20
+ className?: string;
21
+ movingSources: MovingSources[];
22
+ }
23
+ declare const MovingSourceSelector: FunctionComponent<SourceSelectorProps>;
24
+ export default MovingSourceSelector;
@@ -0,0 +1,119 @@
1
+ "use client";
2
+ import { jsxs as B, jsx as a, Fragment as G } from "react/jsx-runtime";
3
+ import { useState as l } from "react";
4
+ import { useTranslation as J } from "react-i18next";
5
+ import K from "../../layout/AspectRatio/index.js";
6
+ import Q from "../../atomic/Loader/index.js";
7
+ import U from "@rubin-epo/epo-react-lib/IconComposer";
8
+ import Z from "./MovingSourceMap/index.js";
9
+ import { getRadius as $, toDecimalPercent as L } from "./utils.js";
10
+ import { BackgroundBlinker as O } from "./styles.js";
11
+ import ee from "../../hooks/useInterval.js";
12
+ import te from "./Message/Message.js";
13
+ import oe from "../../atomic/ElapsedTime/ElapsedTime.js";
14
+ const ne = (e, n) => {
15
+ var u;
16
+ const t = { day: 0, hour: 0 }, o = e[n];
17
+ if (!o) return t;
18
+ const r = (o == null ? void 0 : o.date) - ((u = e[0]) == null ? void 0 : u.date);
19
+ return r ? {
20
+ day: Math.round(r) || 0,
21
+ hour: Math.round(24 / r % 24) || 0
22
+ } : t;
23
+ }, se = (e, n, t) => Math.pow(e.x - n.x, 2) + Math.pow(e.y - n.y, 2) <= Math.pow(t, 2), re = (e, n, t) => t ? e[n] ? [e[n].image] : [] : e.map(({ image: o }) => o), ie = ({
24
+ width: e = 600,
25
+ height: n = 600,
26
+ selectedSource: t = [],
27
+ alerts: o = [],
28
+ activeAlertIndex: r = 0,
29
+ alertChangeCallback: u,
30
+ selectionCallback: M,
31
+ blinkConfig: P,
32
+ isDisplayOnly: d = !1,
33
+ isLoading: w,
34
+ className: F,
35
+ movingSources: c = []
36
+ }) => {
37
+ const [f, x] = l(0), [R, V] = l(!0), [b, j] = l(!0), [N, y] = l(), [T, p] = l(!1), { t: I } = J(), S = !R && !w, W = (s, m, g) => {
38
+ if (c)
39
+ for (let i of c) {
40
+ const h = i.sources[f];
41
+ if (se(
42
+ s,
43
+ {
44
+ x: L(h.x) * m,
45
+ y: L(h.y) * g
46
+ },
47
+ $(i.type, i.radius) * m
48
+ ))
49
+ return i.id;
50
+ }
51
+ }, _ = () => {
52
+ y(I("source_selector.messages.failure")), p(!0);
53
+ }, v = () => {
54
+ j((s) => !s);
55
+ }, z = () => {
56
+ y(
57
+ /* @__PURE__ */ B(G, { children: [
58
+ /* @__PURE__ */ a(U, { icon: "checkmark" }),
59
+ I("source_selector.messages.success")
60
+ ] })
61
+ ), p(!0);
62
+ }, A = ({
63
+ clientX: s,
64
+ clientY: m,
65
+ target: g
66
+ }) => {
67
+ if (!S || d) return;
68
+ const {
69
+ tagName: i,
70
+ clientWidth: h,
71
+ clientHeight: k
72
+ } = g;
73
+ if (i.toLowerCase() !== "img") return;
74
+ const { left: q, top: D } = g.getBoundingClientRect(), C = W(
75
+ { x: s - q, y: k - m + D },
76
+ h,
77
+ k
78
+ );
79
+ if (C) {
80
+ if (t.includes(C)) return;
81
+ M && M(t.concat(C)), z();
82
+ } else
83
+ _();
84
+ }, E = () => {
85
+ p(!1);
86
+ }, { day: H, hour: X } = ne(o, r), Y = re(o, r, d);
87
+ return ee(() => {
88
+ b && (f > c[0].sources.length - 2 ? x(0) : x((s) => s + 1));
89
+ }, 500), /* @__PURE__ */ B(K, { ratio: 1, className: F, children: [
90
+ !d && /* @__PURE__ */ a(
91
+ te,
92
+ {
93
+ onMessageChangeCallback: E,
94
+ isVisible: T,
95
+ children: N
96
+ }
97
+ ),
98
+ c && /* @__PURE__ */ a(
99
+ O,
100
+ {
101
+ images: Y,
102
+ activeIndex: f,
103
+ blinkCallback: u,
104
+ loadedCallback: () => V(!1),
105
+ onClickCallback: A,
106
+ extraControls: o.length > 0 && !d && /* @__PURE__ */ a(oe, { day: H, hour: X }),
107
+ interval: 400,
108
+ pauseCallback: v,
109
+ ...P,
110
+ children: /* @__PURE__ */ a(Z, { width: e, height: n, isPlaying: b, currentIndex: f, movingSources: c, selectedSource: t })
111
+ }
112
+ ),
113
+ !S && /* @__PURE__ */ a(Q, {})
114
+ ] });
115
+ };
116
+ ie.displayName = "Widgets.MovingSourceSelector";
117
+ export {
118
+ ie as default
119
+ };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),h=require("react"),z=require("react-i18next"),E=require("../../layout/AspectRatio/index.cjs"),H=require("../../atomic/Loader/index.cjs"),X=require("@rubin-epo/epo-react-lib/IconComposer"),Y=require("./SourceMap/index.cjs"),m=require("./utils.cjs"),G=require("./styles.cjs"),J=require("./Message/Message.cjs"),K=require("../../atomic/ElapsedTime/ElapsedTime.cjs"),Q=e=>e&&e.__esModule?e:{default:e},U=Q(X),Z=(e,t)=>{var c;const s={day:0,hour:0},n=e[t];if(!n)return s;const o=(n==null?void 0:n.date)-((c=e[0])==null?void 0:c.date);return o?{day:Math.round(o)||0,hour:Math.round(24/o%24)||0}:s},A=(e,t,s)=>Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)<=Math.pow(s,2),O=(e,t,s,n)=>{var o;return(o=n.find(({x:c,y:u,radius:i,type:l})=>A(e,{x:m.toDecimalPercent(c)*t,y:m.toDecimalPercent(u)*s},m.getRadius(l,i)*t)))==null?void 0:o.id},ee=(e,t,s)=>s?e[t]?[e[t].image]:[]:e.map(({image:n})=>n),S=({width:e=600,height:t=600,selectedSource:s=[],sources:n,alerts:o=[],activeAlertIndex:c=0,alertChangeCallback:u,selectionCallback:i,blinkConfig:l,isDisplayOnly:a=!1,isLoading:b,className:j})=>{const[p,_]=h.useState(!0),[y,x]=h.useState(),[I,d]=h.useState(!1),{t:C}=z.useTranslation(),M=!p&&!b,w=()=>{x(C("source_selector.messages.failure")),d(!0)},L=()=>{x(r.jsxs(r.Fragment,{children:[r.jsx(U.default,{icon:"checkmark"}),C("source_selector.messages.success")]})),d(!0)},P=({clientX:f,clientY:D,target:k})=>{if(!M||a)return;const{tagName:N,clientWidth:W,clientHeight:q}=k;if(N.toLowerCase()!=="img")return;const{left:$,top:v}=k.getBoundingClientRect(),g=O({x:f-$,y:q-D+v},W,q,n);if(g){if(s.includes(g))return;i&&i(s.concat(g)),L()}else w()},T=()=>{d(!1)},{day:B,hour:F}=Z(o,c),R=ee(o,c,a),V=n.filter(({id:f})=>s.includes(f));return r.jsxs(E.default,{ratio:1,className:j,children:[!a&&r.jsx(J.default,{onMessageChangeCallback:T,isVisible:I,children:y}),r.jsx(G.BackgroundBlinker,{images:R,activeIndex:c,blinkCallback:u,loadedCallback:()=>_(!1),onClickCallback:P,extraControls:o.length>0&&!a&&r.jsx(K.default,{day:B,hour:F}),interval:400,...l,children:r.jsx(Y.default,{sources:V,width:e,height:t})}),!M&&r.jsx(H.default,{})]})};S.displayName="Widgets.SourceSelector";exports.default=S;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),h=require("react"),z=require("react-i18next"),E=require("../../layout/AspectRatio/index.cjs"),H=require("../../atomic/Loader/index.cjs"),X=require("@rubin-epo/epo-react-lib/IconComposer"),Y=require("./SourceMap/index.cjs"),m=require("./utils.cjs"),G=require("./styles.cjs"),J=require("./Message/Message.cjs"),K=require("../../atomic/ElapsedTime/ElapsedTime.cjs"),Q=e=>e&&e.__esModule?e:{default:e},U=Q(X),Z=(e,s)=>{var r;const n={day:0,hour:0},t=e[s];if(!t)return n;const o=(t==null?void 0:t.date)-((r=e[0])==null?void 0:r.date);return o?{day:Math.round(o)||0,hour:Math.round(24/o%24)||0}:n},A=(e,s,n)=>Math.pow(e.x-s.x,2)+Math.pow(e.y-s.y,2)<=Math.pow(n,2),O=(e,s,n,t)=>{var o;if(t)return(o=t.find(({x:r,y:u,radius:c,type:l})=>A(e,{x:m.toDecimalPercent(r)*s,y:m.toDecimalPercent(u)*n},m.getRadius(l,c)*s)))==null?void 0:o.id},ee=(e,s,n)=>n?e[s]?[e[s].image]:[]:e.map(({image:t})=>t),S=({width:e=600,height:s=600,selectedSource:n=[],sources:t,alerts:o=[],activeAlertIndex:r=0,alertChangeCallback:u,selectionCallback:c,blinkConfig:l,isDisplayOnly:a=!1,isLoading:b,className:j})=>{const[p,_]=h.useState(!0),[y,x]=h.useState(),[I,d]=h.useState(!1),{t:C}=z.useTranslation(),M=!p&&!b,w=()=>{x(C("source_selector.messages.failure")),d(!0)},L=()=>{x(i.jsxs(i.Fragment,{children:[i.jsx(U.default,{icon:"checkmark"}),C("source_selector.messages.success")]})),d(!0)},P=({clientX:f,clientY:D,target:k})=>{if(!M||a)return;const{tagName:N,clientWidth:W,clientHeight:q}=k;if(N.toLowerCase()!=="img")return;const{left:$,top:v}=k.getBoundingClientRect(),g=t?O({x:f-$,y:q-D+v},W,q,t):null;if(g){if(n.includes(g))return;c&&c(n.concat(g)),L()}else w()},T=()=>{d(!1)},{day:B,hour:F}=Z(o,r),R=ee(o,r,a),V=t?t.filter(({id:f})=>n.includes(f)):[];return i.jsxs(E.default,{ratio:1,className:j,children:[!a&&i.jsx(J.default,{onMessageChangeCallback:T,isVisible:I,children:y}),i.jsx(G.BackgroundBlinker,{images:R,activeIndex:r,blinkCallback:u,loadedCallback:()=>_(!1),onClickCallback:P,extraControls:o.length>0&&!a&&i.jsx(K.default,{day:B,hour:F}),interval:400,...l,children:i.jsx(Y.default,{sources:V,width:e,height:s})}),!M&&i.jsx(H.default,{})]})};S.displayName="Widgets.SourceSelector";exports.default=S;
@@ -9,7 +9,7 @@ interface BlinkConfig {
9
9
  interface SourceSelectorProps {
10
10
  width?: number;
11
11
  height?: number;
12
- sources: Source[];
12
+ sources?: Source[] | null;
13
13
  alerts: Alert[];
14
14
  selectedSource?: string[];
15
15
  activeAlertIndex?: number;
@@ -10,76 +10,77 @@ import { getRadius as K, toDecimalPercent as S } from "./utils.js";
10
10
  import { BackgroundBlinker as Q } from "./styles.js";
11
11
  import U from "./Message/Message.js";
12
12
  import Z from "../../atomic/ElapsedTime/ElapsedTime.js";
13
- const $ = (e, o) => {
13
+ const $ = (o, t) => {
14
14
  var n;
15
- const t = { day: 0, hour: 0 }, s = e[o];
16
- if (!s) return t;
17
- const r = (s == null ? void 0 : s.date) - ((n = e[0]) == null ? void 0 : n.date);
18
- return r ? {
19
- day: Math.round(r) || 0,
20
- hour: Math.round(24 / r % 24) || 0
21
- } : t;
22
- }, v = (e, o, t) => Math.pow(e.x - o.x, 2) + Math.pow(e.y - o.y, 2) <= Math.pow(t, 2), O = (e, o, t, s) => {
23
- var r;
24
- return (r = s.find(({ x: n, y: l, radius: c, type: d }) => v(
25
- e,
26
- {
27
- x: S(n) * o,
28
- y: S(l) * t
29
- },
30
- K(d, c) * o
31
- ))) == null ? void 0 : r.id;
32
- }, ee = (e, o, t) => t ? e[o] ? [e[o].image] : [] : e.map(({ image: s }) => s), oe = ({
33
- width: e = 600,
34
- height: o = 600,
35
- selectedSource: t = [],
36
- sources: s,
37
- alerts: r = [],
15
+ const r = { day: 0, hour: 0 }, e = o[t];
16
+ if (!e) return r;
17
+ const s = (e == null ? void 0 : e.date) - ((n = o[0]) == null ? void 0 : n.date);
18
+ return s ? {
19
+ day: Math.round(s) || 0,
20
+ hour: Math.round(24 / s % 24) || 0
21
+ } : r;
22
+ }, v = (o, t, r) => Math.pow(o.x - t.x, 2) + Math.pow(o.y - t.y, 2) <= Math.pow(r, 2), O = (o, t, r, e) => {
23
+ var s;
24
+ if (e)
25
+ return (s = e.find(({ x: n, y: l, radius: a, type: d }) => v(
26
+ o,
27
+ {
28
+ x: S(n) * t,
29
+ y: S(l) * r
30
+ },
31
+ K(d, a) * t
32
+ ))) == null ? void 0 : s.id;
33
+ }, ee = (o, t, r) => r ? o[t] ? [o[t].image] : [] : o.map(({ image: e }) => e), oe = ({
34
+ width: o = 600,
35
+ height: t = 600,
36
+ selectedSource: r = [],
37
+ sources: e,
38
+ alerts: s = [],
38
39
  activeAlertIndex: n = 0,
39
40
  alertChangeCallback: l,
40
- selectionCallback: c,
41
+ selectionCallback: a,
41
42
  blinkConfig: d,
42
- isDisplayOnly: a = !1,
43
+ isDisplayOnly: c = !1,
43
44
  isLoading: x,
44
45
  className: w
45
46
  }) => {
46
- const [y, L] = g(!0), [I, h] = g(), [B, u] = g(!1), { t: p } = q(), C = !y && !x, F = () => {
47
- h(p("source_selector.messages.failure")), u(!0);
47
+ const [y, L] = g(!0), [I, h] = g(), [B, m] = g(!1), { t: p } = q(), C = !y && !x, F = () => {
48
+ h(p("source_selector.messages.failure")), m(!0);
48
49
  }, R = () => {
49
50
  h(
50
51
  /* @__PURE__ */ b(Y, { children: [
51
52
  /* @__PURE__ */ i(G, { icon: "checkmark" }),
52
53
  p("source_selector.messages.success")
53
54
  ] })
54
- ), u(!0);
55
+ ), m(!0);
55
56
  }, T = ({
56
- clientX: m,
57
+ clientX: u,
57
58
  clientY: _,
58
59
  target: k
59
60
  }) => {
60
- if (!C || a) return;
61
+ if (!C || c) return;
61
62
  const {
62
63
  tagName: z,
63
64
  clientWidth: E,
64
65
  clientHeight: M
65
66
  } = k;
66
67
  if (z.toLowerCase() !== "img") return;
67
- const { left: H, top: X } = k.getBoundingClientRect(), f = O(
68
- { x: m - H, y: M - _ + X },
68
+ const { left: H, top: X } = k.getBoundingClientRect(), f = e ? O(
69
+ { x: u - H, y: M - _ + X },
69
70
  E,
70
71
  M,
71
- s
72
- );
72
+ e
73
+ ) : null;
73
74
  if (f) {
74
- if (t.includes(f)) return;
75
- c && c(t.concat(f)), R();
75
+ if (r.includes(f)) return;
76
+ a && a(r.concat(f)), R();
76
77
  } else
77
78
  F();
78
79
  }, V = () => {
79
- u(!1);
80
- }, { day: j, hour: N } = $(r, n), P = ee(r, n, a), W = s.filter(({ id: m }) => t.includes(m));
80
+ m(!1);
81
+ }, { day: j, hour: N } = $(s, n), P = ee(s, n, c), W = e ? e.filter(({ id: u }) => r.includes(u)) : [];
81
82
  return /* @__PURE__ */ b(A, { ratio: 1, className: w, children: [
82
- !a && /* @__PURE__ */ i(
83
+ !c && /* @__PURE__ */ i(
83
84
  U,
84
85
  {
85
86
  onMessageChangeCallback: V,
@@ -95,10 +96,10 @@ const $ = (e, o) => {
95
96
  blinkCallback: l,
96
97
  loadedCallback: () => L(!1),
97
98
  onClickCallback: T,
98
- extraControls: r.length > 0 && !a && /* @__PURE__ */ i(Z, { day: j, hour: N }),
99
+ extraControls: s.length > 0 && !c && /* @__PURE__ */ i(Z, { day: j, hour: N }),
99
100
  interval: 400,
100
101
  ...d,
101
- children: /* @__PURE__ */ i(J, { sources: W, width: e, height: o })
102
+ children: /* @__PURE__ */ i(J, { sources: W, width: o, height: t })
102
103
  }
103
104
  ),
104
105
  !C && /* @__PURE__ */ i(D, {})
@@ -1,5 +1,6 @@
1
1
  import { default as SourceSelector } from './SourceSelector';
2
2
 
3
+ export { default as MovingSourceSelector } from './MovingSourceSelector';
3
4
  export { default as Message } from './Message';
4
- export { default as SelectionList } from './SelectionList';
5
+ export { default as SelectionList } from '../../atomic/SelectionList';
5
6
  export default SourceSelector;
@@ -1,4 +1,5 @@
1
1
  import { SourceDataset } from '../../../types/astro';
2
2
 
3
+ export declare const movingData: SourceDataset;
3
4
  export declare const biggerData: SourceDataset;
4
5
  export declare const moreImages: never[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubin-epo/epo-widget-lib",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Rubin Observatory Education & Public Outreach team React scientific and educational widgets.",
5
5
  "author": "Rubin EPO",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
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("../../../atomic/Button/patterns/Reset.cjs"),l=({className:n,onRemoveCallback:c,sources:t=[]})=>{const{t:r}=u.useTranslation();return e.jsxs(s.SelectionWrapper,{children:[t.length>0&&e.jsx(s.SelectionList,{className:n,children:t.map(({type:o,id:i})=>e.jsxs(s.DescriptionWrapper,{children:[e.jsx("dt",{children:r("source_selector.selected_source",{type:r(`source_selector.sources.${o}`)})}),e.jsx("dd",{children:i})]},i))}),e.jsx(a.default,{isDisabled:t.length<1,onResetCallback:c})]})};l.displayName="Widgets.SelectionList";exports.default=l;
@@ -1,31 +0,0 @@
1
- "use client";
2
- import { jsxs as s, 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 "../../../atomic/Button/patterns/Reset.js";
6
- const u = ({
7
- className: o,
8
- onRemoveCallback: l,
9
- sources: t = []
10
- }) => {
11
- const { t: r } = c();
12
- return /* @__PURE__ */ s(a, { children: [
13
- t.length > 0 && /* @__PURE__ */ e(p, { className: o, children: t.map(({ type: n, id: i }) => /* @__PURE__ */ s(d, { children: [
14
- /* @__PURE__ */ e("dt", { children: r("source_selector.selected_source", {
15
- type: r(`source_selector.sources.${n}`)
16
- }) }),
17
- /* @__PURE__ */ e("dd", { children: i })
18
- ] }, i)) }),
19
- /* @__PURE__ */ e(
20
- m,
21
- {
22
- isDisabled: t.length < 1,
23
- onResetCallback: l
24
- }
25
- )
26
- ] });
27
- };
28
- u.displayName = "Widgets.SelectionList";
29
- export {
30
- u as default
31
- };