@rubin-epo/epo-widget-lib 1.0.2 → 1.0.3

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 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.3",
4
4
  "description": "Rubin Observatory Education & Public Outreach team React scientific and educational widgets.",
5
5
  "author": "Rubin EPO",
6
6
  "license": "MIT",