@rubin-epo/epo-widget-lib 1.0.2 → 1.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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),E=require("react"),N=require("react-i18next"),J=require("d3-array"),K=require("@rubin-epo/epo-react-lib/HorizontalSlider"),t=require("../defaults.cjs"),O=require("../Plot/index.cjs"),Q=require("./A11Y/LightCurveLabel/index.cjs"),c=require("../helpers.cjs"),S=require("../../../atomic/Button/patterns/Reset.cjs"),V=require("./MagnitudeSlider/index.cjs"),X=require("./styles.cjs"),Z=require("../../../charts/Viewport/index.cjs"),k=require("../../../layout/Controls/index.cjs"),$=require("../../../atomic/ControlLabel/index.cjs"),G=require("../../../charts/PathFromPoints/index.cjs"),U=require("../../../lib/utils.cjs"),Y=r=>r&&r.__esModule?r:{default:r},A=Y(K),D=({gaussianWidth:r=t.default.gaussianWidth,yOffset:l=t.default.yOffset,alerts:I,peakMjd:P,yMin:f,yMax:x,width:m=t.default.width,height:p=t.default.height,userMagnitude:W,onUserMagnitudeChangeCallback:n,onGaussianChangeCallback:o,onYOffsetChangeCallback:d,className:F,isDisplayOnly:q,...H})=>{const{t:j}=N.useTranslation(),u=U.mergeWithDefaults({min:f,max:x},t.default.yAxis),g=(u.max-u.min)/2+u.min,h=c.useAlertsAsPoints(I,P),R=E.useId(),w=()=>{n&&n(g),d&&d(t.default.yOffset),o&&o(t.default.gaussianWidth)},v=c.estimateMagnitudeWithOffset(0,r,l),B=e.jsx(O.default,{slider:e.jsx(V.default,{magnitude:W||g,onMagnitudeChangeCallback:s=>n&&n(s),disabled:q,yMin:u.min-u.step/2,yMax:u.max+u.step/2,estimatedPeak:v}),plotChildren:({xScale:s,yScale:i,xDomain:y,yDomain:L,xStart:_,xEnd:z,yStart:M,yEnd:a,Data:T})=>e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:s(0),y:a,width:s(15)-s(0),height:M-a,stroke:"var(--neutral60,##6A6E6E)",strokeDasharray:6,fill:"var(--neutral20,#DCE0E3)"}),T,e.jsx(G.default,{points:J.range(y[0],y[1],.5).map(b=>({x:s(b),y:i(c.estimateMagnitude(b,r))})),svgProps:{transform:`translate(0,${i(L[1]-l)})`}}),e.jsx(Z.default,{x:_,y:a,outerHeight:M-a,outerWidth:z-_,innerWidth:m,innerHeight:p,children:e.jsx(X.DM15Display,{gaussianWidth:r})})]}),...H,data:h,width:m,height:p,yMin:f,yMax:x});return e.jsx(e.Fragment,{children:e.jsx(k.default,{className:F,isDisplayOnly:q,ratio:{landscape:3/2,portrait:2/3},widget:B,controls:e.jsxs(e.Fragment,{children:[e.jsx($.default,{label:j("light_curve.curve.controls.gaussian_width"),input:s=>e.jsx(A.default,{labelledbyId:s,color:"var(--turquoise85, #12726D)",min:t.default.gaussianMin,max:t.default.gaussianMax,step:t.default.gaussianStep,value:r,onChangeCallback:i=>typeof i=="number"&&o&&o(i)}),labelBy:!0}),e.jsx($.default,{label:j("light_curve.curve.controls.y_offset"),input:s=>e.jsx(A.default,{labelledbyId:s,color:"var(--turquoise85, #12726D)",min:t.default.yOffsetMin,max:t.default.yOffsetMax,step:t.default.yOffsetStep,value:l,onChangeCallback:i=>typeof i=="number"&&d&&d(i)}),labelBy:!0}),e.jsx(Q.default,{controlledById:R,data:h,gaussianWidth:r,yOffset:l,estimatedPeak:v})]}),actions:e.jsx(S.default,{onResetCallback:w})})})};D.displayName="Widgets.LightCurve";const C=D;exports.default=C;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),T=require("react"),E=require("react-i18next"),N=require("d3-array"),J=require("@rubin-epo/epo-react-lib/HorizontalSlider"),t=require("../defaults.cjs"),K=require("../Plot/index.cjs"),O=require("./A11Y/LightCurveLabel/index.cjs"),c=require("../helpers.cjs"),Q=require("../../../atomic/Button/patterns/Reset.cjs"),S=require("./MagnitudeSlider/index.cjs"),V=require("./styles.cjs"),X=require("../../../charts/Viewport/index.cjs"),Z=require("../../../layout/Controls/index.cjs"),b=require("../../../atomic/ControlLabel/index.cjs"),k=require("../../../charts/PathFromPoints/index.cjs"),G=require("../../../lib/utils.cjs"),U=r=>r&&r.__esModule?r:{default:r},$=U(J),D=({gaussianWidth:r=t.default.gaussianWidth,yOffset:n=t.default.yOffset,alerts:A,peakMjd:I,yMin:f,yMax:x,width:m=t.default.width,height:p=t.default.height,userMagnitude:P,onUserMagnitudeChangeCallback:l,onGaussianChangeCallback:o,onYOffsetChangeCallback:d,className:W,isDisplayOnly:q,...F})=>{const{t:j}=E.useTranslation(),u=G.mergeWithDefaults({min:f,max:x},t.default.yAxis),g=(u.max-u.min)/2+u.min,h=c.useAlertsAsPoints(A,I),H=T.useId(),L=()=>{l&&l(g),d&&d(t.default.yOffset),o&&o(t.default.gaussianWidth)},v=c.estimateMagnitudeWithOffset(0,r,n),R=e.jsx(K.default,{slider:e.jsx(S.default,{magnitude:P||g,onMagnitudeChangeCallback:s=>l&&l(s),disabled:q,yMin:u.min-u.step/2,yMax:u.max+u.step/2,estimatedPeak:v}),plotChildren:({xScale:s,yScale:i,yDomain:w,xStart:y,xEnd:B,yStart:_,yEnd:a,Data:z})=>e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:s(0),y:a,width:s(15)-s(0),height:_-a,stroke:"var(--neutral60,##6A6E6E)",strokeDasharray:6,fill:"var(--neutral20,#DCE0E3)"}),z,e.jsx(k.default,{points:N.range(-10,40,.5).map(M=>({x:s(M),y:i(c.estimateMagnitude(M,r))})),svgProps:{transform:`translate(0,${i(w[1]-n)})`,strokeLinecap:"round"}}),e.jsx(X.default,{x:y,y:a,outerHeight:_-a,outerWidth:B-y,innerWidth:m,innerHeight:p,children:e.jsx(V.DM15Display,{gaussianWidth:r})})]}),...F,data:h,width:m,height:p,yMin:f,yMax:x});return e.jsx(e.Fragment,{children:e.jsx(Z.default,{className:W,isDisplayOnly:q,ratio:{landscape:3/2,portrait:2/3},widget:R,controls:e.jsxs(e.Fragment,{children:[e.jsx(b.default,{label:j("light_curve.curve.controls.gaussian_width"),input:s=>e.jsx($.default,{labelledbyId:s,color:"var(--turquoise85, #12726D)",min:t.default.gaussianMin,max:t.default.gaussianMax,step:t.default.gaussianStep,value:r,onChangeCallback:i=>typeof i=="number"&&o&&o(i)}),labelBy:!0}),e.jsx(b.default,{label:j("light_curve.curve.controls.y_offset"),input:s=>e.jsx($.default,{labelledbyId:s,color:"var(--turquoise85, #12726D)",min:t.default.yOffsetMin,max:t.default.yOffsetMax,step:t.default.yOffsetStep,value:n,onChangeCallback:i=>typeof i=="number"&&d&&d(i)}),labelBy:!0}),e.jsx(O.default,{controlledById:H,data:h,gaussianWidth:r,yOffset:n,estimatedPeak:v})]}),actions:e.jsx(Q.default,{onResetCallback:L})})})};D.displayName="Widgets.LightCurve";const Y=D;exports.default=Y;
@@ -1,50 +1,50 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as A, Fragment as a } from "react/jsx-runtime";
3
- import { useId as T } from "react";
4
- import { useTranslation as V } from "react-i18next";
5
- import { range as J } from "d3-array";
2
+ import { jsx as t, jsxs as W, Fragment as a } from "react/jsx-runtime";
3
+ import { useId as N } from "react";
4
+ import { useTranslation as T } from "react-i18next";
5
+ import { range as V } from "d3-array";
6
6
  import D from "@rubin-epo/epo-react-lib/HorizontalSlider";
7
7
  import r from "../defaults.js";
8
- import K from "../Plot/index.js";
9
- import Q from "./A11Y/LightCurveLabel/index.js";
10
- import { useAlertsAsPoints as X, estimateMagnitudeWithOffset as Z, estimateMagnitude as O } from "../helpers.js";
8
+ import J from "../Plot/index.js";
9
+ import K from "./A11Y/LightCurveLabel/index.js";
10
+ import { useAlertsAsPoints as Q, estimateMagnitudeWithOffset as X, estimateMagnitude as Z } from "../helpers.js";
11
11
  import k from "../../../atomic/Button/patterns/Reset.js";
12
- import S from "./MagnitudeSlider/index.js";
13
- import { DM15Display as C } from "./styles.js";
14
- import G from "../../../charts/Viewport/index.js";
15
- import U from "../../../layout/Controls/index.js";
16
- import I from "../../../atomic/ControlLabel/index.js";
17
- import Y from "../../../charts/PathFromPoints/index.js";
18
- import { mergeWithDefaults as tt } from "../../../lib/utils.js";
19
- const w = ({
12
+ import O from "./MagnitudeSlider/index.js";
13
+ import { DM15Display as S } from "./styles.js";
14
+ import C from "../../../charts/Viewport/index.js";
15
+ import G from "../../../layout/Controls/index.js";
16
+ import A from "../../../atomic/ControlLabel/index.js";
17
+ import U from "../../../charts/PathFromPoints/index.js";
18
+ import { mergeWithDefaults as Y } from "../../../lib/utils.js";
19
+ const I = ({
20
20
  gaussianWidth: m = r.gaussianWidth,
21
21
  yOffset: s = r.yOffset,
22
- alerts: B,
23
- peakMjd: _,
22
+ alerts: w,
23
+ peakMjd: B,
24
24
  yMin: d,
25
25
  yMax: f,
26
26
  width: c = r.width,
27
27
  height: h = r.height,
28
- userMagnitude: F,
28
+ userMagnitude: _,
29
29
  onUserMagnitudeChangeCallback: n,
30
30
  onGaussianChangeCallback: l,
31
31
  onYOffsetChangeCallback: p,
32
- className: H,
32
+ className: F,
33
33
  isDisplayOnly: g,
34
- ...R
34
+ ...H
35
35
  }) => {
36
- const { t: v } = V(), i = tt(
36
+ const { t: v } = T(), i = Y(
37
37
  { min: d, max: f },
38
38
  r.yAxis
39
- ), y = (i.max - i.min) / 2 + i.min, x = X(B, _), j = T(), q = () => {
39
+ ), y = (i.max - i.min) / 2 + i.min, x = Q(w, B), R = N(), j = () => {
40
40
  n && n(y), p && p(r.yOffset), l && l(r.gaussianWidth);
41
- }, b = Z(0, m, s), $ = /* @__PURE__ */ t(
42
- K,
41
+ }, b = X(0, m, s), q = /* @__PURE__ */ t(
42
+ J,
43
43
  {
44
44
  slider: /* @__PURE__ */ t(
45
- S,
45
+ O,
46
46
  {
47
- magnitude: F || y,
47
+ magnitude: _ || y,
48
48
  onMagnitudeChangeCallback: (o) => n && n(o),
49
49
  disabled: g,
50
50
  yMin: i.min - i.step / 2,
@@ -55,53 +55,53 @@ const w = ({
55
55
  plotChildren: ({
56
56
  xScale: o,
57
57
  yScale: e,
58
- xDomain: P,
59
- yDomain: z,
60
- xStart: M,
61
- xEnd: E,
62
- yStart: W,
58
+ yDomain: $,
59
+ xStart: P,
60
+ xEnd: z,
61
+ yStart: L,
63
62
  yEnd: u,
64
- Data: N
65
- }) => /* @__PURE__ */ A(a, { children: [
63
+ Data: E
64
+ }) => /* @__PURE__ */ W(a, { children: [
66
65
  /* @__PURE__ */ t(
67
66
  "rect",
68
67
  {
69
68
  x: o(0),
70
69
  y: u,
71
70
  width: o(15) - o(0),
72
- height: W - u,
71
+ height: L - u,
73
72
  stroke: "var(--neutral60,##6A6E6E)",
74
73
  strokeDasharray: 6,
75
74
  fill: "var(--neutral20,#DCE0E3)"
76
75
  }
77
76
  ),
78
- N,
77
+ E,
79
78
  /* @__PURE__ */ t(
80
- Y,
79
+ U,
81
80
  {
82
- points: J(P[0], P[1], 0.5).map((L) => ({
83
- x: o(L),
84
- y: e(O(L, m))
81
+ points: V(-10, 40, 0.5).map((M) => ({
82
+ x: o(M),
83
+ y: e(Z(M, m))
85
84
  })),
86
85
  svgProps: {
87
- transform: `translate(0,${e(z[1] - s)})`
86
+ transform: `translate(0,${e($[1] - s)})`,
87
+ strokeLinecap: "round"
88
88
  }
89
89
  }
90
90
  ),
91
91
  /* @__PURE__ */ t(
92
- G,
92
+ C,
93
93
  {
94
- x: M,
94
+ x: P,
95
95
  y: u,
96
- outerHeight: W - u,
97
- outerWidth: E - M,
96
+ outerHeight: L - u,
97
+ outerWidth: z - P,
98
98
  innerWidth: c,
99
99
  innerHeight: h,
100
- children: /* @__PURE__ */ t(C, { gaussianWidth: m })
100
+ children: /* @__PURE__ */ t(S, { gaussianWidth: m })
101
101
  }
102
102
  )
103
103
  ] }),
104
- ...R,
104
+ ...H,
105
105
  data: x,
106
106
  width: c,
107
107
  height: h,
@@ -110,15 +110,15 @@ const w = ({
110
110
  }
111
111
  );
112
112
  return /* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(
113
- U,
113
+ G,
114
114
  {
115
- className: H,
115
+ className: F,
116
116
  isDisplayOnly: g,
117
117
  ratio: { landscape: 3 / 2, portrait: 2 / 3 },
118
- widget: $,
119
- controls: /* @__PURE__ */ A(a, { children: [
118
+ widget: q,
119
+ controls: /* @__PURE__ */ W(a, { children: [
120
120
  /* @__PURE__ */ t(
121
- I,
121
+ A,
122
122
  {
123
123
  label: v("light_curve.curve.controls.gaussian_width"),
124
124
  input: (o) => /* @__PURE__ */ t(
@@ -137,7 +137,7 @@ const w = ({
137
137
  }
138
138
  ),
139
139
  /* @__PURE__ */ t(
140
- I,
140
+ A,
141
141
  {
142
142
  label: v("light_curve.curve.controls.y_offset"),
143
143
  input: (o) => /* @__PURE__ */ t(
@@ -156,9 +156,9 @@ const w = ({
156
156
  }
157
157
  ),
158
158
  /* @__PURE__ */ t(
159
- Q,
159
+ K,
160
160
  {
161
- controlledById: j,
161
+ controlledById: R,
162
162
  data: x,
163
163
  gaussianWidth: m,
164
164
  yOffset: s,
@@ -166,12 +166,12 @@ const w = ({
166
166
  }
167
167
  )
168
168
  ] }),
169
- actions: /* @__PURE__ */ t(k, { onResetCallback: q })
169
+ actions: /* @__PURE__ */ t(k, { onResetCallback: j })
170
170
  }
171
171
  ) });
172
172
  };
173
- w.displayName = "Widgets.LightCurve";
174
- const yt = w;
173
+ I.displayName = "Widgets.LightCurve";
174
+ const vt = I;
175
175
  export {
176
- yt as default
176
+ vt as default
177
177
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),h=require("react"),E=require("react-i18next"),H=require("../../layout/AspectRatio/index.cjs"),X=require("../../atomic/Loader/index.cjs"),Y=require("@rubin-epo/epo-react-lib/IconComposer"),G=require("./SourceMap/index.cjs"),m=require("./utils.cjs"),J=require("./styles.cjs"),K=require("./Message/Message.cjs"),Q=require("../../atomic/ElapsedTime/ElapsedTime.cjs"),U=e=>e&&e.__esModule?e:{default:e},Z=U(Y),A=(e,n)=>{var r;const s={day:0,hour:0},o=e[n];if(!o)return s;const t=(o==null?void 0:o.date)-((r=e[0])==null?void 0:r.date);return t?{day:Math.round(t)||0,hour:Math.round(24/t%24)||0}:s},O=(e,n,s)=>Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)<=Math.pow(s,2),ee=(e,n,s,o)=>{var t;return(t=o.find(({x:r,y:l,radius:a,type:d})=>O(e,{x:m.toDecimalPercent(r)*n,y:m.toDecimalPercent(l)*s},m.getRadius(d,a)*n)))==null?void 0:t.id},j=({width:e=600,height:n=600,selectedSource:s=[],sources:o,alerts:t=[],activeAlertIndex:r=0,alertChangeCallback:l,selectionCallback:a,blinkConfig:d,isDisplayOnly:u=!1,isLoading:p,className:b})=>{var S;const[_,y]=h.useState(!0),[I,x]=h.useState(),[w,f]=h.useState(!1),{t:C}=E.useTranslation(),M=!_&&!p,L=()=>{x(C("source_selector.messages.failure")),f(!0)},P=()=>{x(c.jsxs(c.Fragment,{children:[c.jsx(Z.default,{icon:"checkmark"}),C("source_selector.messages.success")]})),f(!0)},T=({clientX:i,clientY:v,target:k})=>{if(!M||u)return;const{tagName:D,clientWidth:N,clientHeight:q}=k;if(D.toLowerCase()!=="img")return;const{left:W,top:z}=k.getBoundingClientRect(),g=ee({x:i-W,y:q-v+z},N,q,o);if(g){if(s.includes(g))return;a&&a(s.concat(g)),P()}else L()},B=()=>{f(!1)},{day:F,hour:R}=A(t,r),V=u?[(S=t[r])==null?void 0:S.image]:t.map(({image:i})=>i),$=o.filter(({id:i})=>s.includes(i));return c.jsxs(H.default,{ratio:1,className:b,children:[!u&&c.jsx(K.default,{onMessageChangeCallback:B,isVisible:w,children:I}),c.jsx(J.BackgroundBlinker,{images:V,activeIndex:r,blinkCallback:l,loadedCallback:()=>y(!1),onClickCallback:T,extraControls:t.length>0&&!u&&c.jsx(Q.default,{day:F,hour:R}),interval:400,...d,children:c.jsx(G.default,{sources:$,width:e,height:n})}),!M&&c.jsx(X.default,{})]})};j.displayName="Widgets.SourceSelector";const te=j;exports.default=te;
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),q=({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:$,target:S})=>{if(!M||a)return;const{tagName:D,clientWidth:N,clientHeight:k}=S;if(D.toLowerCase()!=="img")return;const{left:W,top:v}=S.getBoundingClientRect(),g=O({x:f-W,y:k-$+v},N,k,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,{})]})};q.displayName="Widgets.SourceSelector";const te=q;exports.default=te;
@@ -1,116 +1,115 @@
1
1
  "use client";
2
- import { jsxs as b, jsx as i, Fragment as q } from "react/jsx-runtime";
2
+ import { jsxs as S, jsx as i, Fragment as $ } from "react/jsx-runtime";
3
3
  import { useState as g } from "react";
4
- import { useTranslation as v } from "react-i18next";
4
+ import { useTranslation as q } from "react-i18next";
5
5
  import A from "../../layout/AspectRatio/index.js";
6
6
  import D from "../../atomic/Loader/index.js";
7
7
  import G from "@rubin-epo/epo-react-lib/IconComposer";
8
8
  import J from "./SourceMap/index.js";
9
- import { getRadius as K, toDecimalPercent as x } from "./utils.js";
9
+ import { getRadius as K, toDecimalPercent as b } 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 O = (t, s) => {
13
+ const v = (e, o) => {
14
14
  var n;
15
- const o = { day: 0, hour: 0 }, r = t[s];
16
- if (!r)
17
- return o;
18
- const e = (r == null ? void 0 : r.date) - ((n = t[0]) == null ? void 0 : n.date);
19
- return e ? {
20
- day: Math.round(e) || 0,
21
- hour: Math.round(24 / e % 24) || 0
22
- } : o;
23
- }, ee = (t, s, o) => Math.pow(t.x - s.x, 2) + Math.pow(t.y - s.y, 2) <= Math.pow(o, 2), oe = (t, s, o, r) => {
24
- var e;
25
- return (e = r.find(({ x: n, y: d, radius: a, type: u }) => ee(
26
- t,
15
+ const t = { day: 0, hour: 0 }, s = e[o];
16
+ if (!s)
17
+ return t;
18
+ const r = (s == null ? void 0 : s.date) - ((n = e[0]) == null ? void 0 : n.date);
19
+ return r ? {
20
+ day: Math.round(r) || 0,
21
+ hour: Math.round(24 / r % 24) || 0
22
+ } : t;
23
+ }, O = (e, o, t) => Math.pow(e.x - o.x, 2) + Math.pow(e.y - o.y, 2) <= Math.pow(t, 2), ee = (e, o, t, s) => {
24
+ var r;
25
+ return (r = s.find(({ x: n, y: l, radius: c, type: d }) => O(
26
+ e,
27
27
  {
28
- x: x(n) * s,
29
- y: x(d) * o
28
+ x: b(n) * o,
29
+ y: b(l) * t
30
30
  },
31
- K(u, a) * s
32
- ))) == null ? void 0 : e.id;
33
- }, w = ({
34
- width: t = 600,
35
- height: s = 600,
36
- selectedSource: o = [],
37
- sources: r,
38
- alerts: e = [],
31
+ K(d, c) * o
32
+ ))) == null ? void 0 : r.id;
33
+ }, oe = (e, o, t) => t ? e[o] ? [e[o].image] : [] : e.map(({ image: s }) => s), x = ({
34
+ width: e = 600,
35
+ height: o = 600,
36
+ selectedSource: t = [],
37
+ sources: s,
38
+ alerts: r = [],
39
39
  activeAlertIndex: n = 0,
40
- alertChangeCallback: d,
41
- selectionCallback: a,
42
- blinkConfig: u,
43
- isDisplayOnly: l = !1,
44
- isLoading: y,
45
- className: L
40
+ alertChangeCallback: l,
41
+ selectionCallback: c,
42
+ blinkConfig: d,
43
+ isDisplayOnly: a = !1,
44
+ isLoading: w,
45
+ className: y
46
46
  }) => {
47
- var M;
48
- const [I, B] = g(!0), [F, h] = g(), [R, m] = g(!1), { t: p } = v(), C = !I && !y, T = () => {
49
- h(p("source_selector.messages.failure")), m(!0);
50
- }, V = () => {
47
+ const [L, I] = g(!0), [B, h] = g(), [F, u] = g(!1), { t: p } = q(), C = !L && !w, R = () => {
48
+ h(p("source_selector.messages.failure")), u(!0);
49
+ }, T = () => {
51
50
  h(
52
- /* @__PURE__ */ b(q, { children: [
51
+ /* @__PURE__ */ S($, { children: [
53
52
  /* @__PURE__ */ i(G, { icon: "checkmark" }),
54
53
  p("source_selector.messages.success")
55
54
  ] })
56
- ), m(!0);
57
- }, j = ({
58
- clientX: c,
59
- clientY: E,
55
+ ), u(!0);
56
+ }, V = ({
57
+ clientX: m,
58
+ clientY: z,
60
59
  target: k
61
60
  }) => {
62
- if (!C || l)
61
+ if (!C || a)
63
62
  return;
64
63
  const {
65
- tagName: H,
66
- clientWidth: X,
67
- clientHeight: S
64
+ tagName: E,
65
+ clientWidth: H,
66
+ clientHeight: M
68
67
  } = k;
69
- if (H.toLowerCase() !== "img")
68
+ if (E.toLowerCase() !== "img")
70
69
  return;
71
- const { left: Y, top: $ } = k.getBoundingClientRect(), f = oe(
72
- { x: c - Y, y: S - E + $ },
73
- X,
74
- S,
75
- r
70
+ const { left: X, top: Y } = k.getBoundingClientRect(), f = ee(
71
+ { x: m - X, y: M - z + Y },
72
+ H,
73
+ M,
74
+ s
76
75
  );
77
76
  if (f) {
78
- if (o.includes(f))
77
+ if (t.includes(f))
79
78
  return;
80
- a && a(o.concat(f)), V();
79
+ c && c(t.concat(f)), T();
81
80
  } else
82
- T();
83
- }, N = () => {
84
- m(!1);
85
- }, { day: P, hour: W } = O(e, n), _ = l ? [(M = e[n]) == null ? void 0 : M.image] : e.map(({ image: c }) => c), z = r.filter(({ id: c }) => o.includes(c));
86
- return /* @__PURE__ */ b(A, { ratio: 1, className: L, children: [
87
- !l && /* @__PURE__ */ i(
81
+ R();
82
+ }, j = () => {
83
+ u(!1);
84
+ }, { day: N, hour: P } = v(r, n), W = oe(r, n, a), _ = s.filter(({ id: m }) => t.includes(m));
85
+ return /* @__PURE__ */ S(A, { ratio: 1, className: y, children: [
86
+ !a && /* @__PURE__ */ i(
88
87
  U,
89
88
  {
90
- onMessageChangeCallback: N,
91
- isVisible: R,
92
- children: F
89
+ onMessageChangeCallback: j,
90
+ isVisible: F,
91
+ children: B
93
92
  }
94
93
  ),
95
94
  /* @__PURE__ */ i(
96
95
  Q,
97
96
  {
98
- images: _,
97
+ images: W,
99
98
  activeIndex: n,
100
- blinkCallback: d,
101
- loadedCallback: () => B(!1),
102
- onClickCallback: j,
103
- extraControls: e.length > 0 && !l && /* @__PURE__ */ i(Z, { day: P, hour: W }),
99
+ blinkCallback: l,
100
+ loadedCallback: () => I(!1),
101
+ onClickCallback: V,
102
+ extraControls: r.length > 0 && !a && /* @__PURE__ */ i(Z, { day: N, hour: P }),
104
103
  interval: 400,
105
- ...u,
106
- children: /* @__PURE__ */ i(J, { sources: z, width: t, height: s })
104
+ ...d,
105
+ children: /* @__PURE__ */ i(J, { sources: _, width: e, height: o })
107
106
  }
108
107
  ),
109
108
  !C && /* @__PURE__ */ i(D, {})
110
109
  ] });
111
110
  };
112
- w.displayName = "Widgets.SourceSelector";
113
- const ge = w;
111
+ x.displayName = "Widgets.SourceSelector";
112
+ const ge = x;
114
113
  export {
115
114
  ge as default
116
115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubin-epo/epo-widget-lib",
3
- "version": "1.0.2",
3
+ "version": "1.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",