@rubin-epo/epo-widget-lib 0.8.0 → 0.8.1

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 n=require("react/jsx-runtime"),B=require("react"),O=require("react-i18next"),l=require("d3-array"),z=require("@rubin-epo/epo-react-lib/HorizontalSlider"),d=require("./lib/utils.cjs"),E=require("./widgets/SupernovaThreeVector/LiveLabel/index.cjs"),i=require("./widgets/SupernovaThreeVector/styles.cjs"),N=t=>t&&t.__esModule?t:{default:t},P=N(z),k=({histogramData:t,userData:q,binnedImages:_,step:u=100})=>{const{t:C}=O.useTranslation(),r={top:30,bottom:30,left:50,right:0},x="skyMapDescription",o=600,m=o/1.6,R=[r.left,o-r.right],T=[m-r.bottom,r.top],b=6,p=7,y=0,L=l.max(t,e=>e.value)||Math.max(...t.map(({value:e})=>e)),a=l.min(t,e=>e.bin)||0,c=l.max(t,e=>e.bin)||Math.max(...t.map(({bin:e})=>e)),g=l.nice(a,c,b),S=l.nice(y,L||y,p),f=d.getLinearScale(g,R),I=d.getLinearScale(S,T),[s,j]=B.useState([a,c]),v=15,$=`calc(${r.left/o*100}% - ${v}px)`,V=`calc(${(1-f(c)/o)*100}% - ${v}px)`,h=t.map(({bin:e})=>d.between(e,s[0],s[1])),M=q.filter(({distance:e})=>d.between(e,s[0],s[1]+u)),A=t.reduce((e,{value:H},w)=>h[w]?e+H:e,0);return n.jsxs(i.ThreeVectorContainer,{children:[n.jsxs(i.ThreeVectorLayout,{children:[n.jsx(i.HistogramContainer,{children:n.jsx(i.Histogram,{data:t,activeRange:s,xDomain:g,yDomain:S,xScale:f,yScale:I,yTicks:p,xTicks:b,step:u,margin:r,width:o,height:m})}),n.jsx(i.SliderContainer,{style:{paddingInlineStart:$,paddingInlineEnd:V},children:n.jsx(P.default,{min:a,max:c,step:u,value:s,ariaValuetext:({valueNow:e})=>C("supernova_three_vector.slider.valueLabel",{value:e}),label:"distanceSlider",color:"var(--turquoise85,#12726D)",minLabel:`${a} kpc`,maxLabel:`${c} kpc`,onChangeCallback:e=>Array.isArray(e)&&j(e)})}),n.jsx(i.SkymapContainer,{children:n.jsx(i.Skymap,{objects:M,images:_,describedById:x,visibleImages:h})}),n.jsx(i.ResetButton,{onResetCallback:()=>j([a,c])})]}),n.jsx(E.default,{id:x,objects:M,min:s[0],max:s[1]+u,supernovaCount:A})]})};k.displayName="Widgets.SupernovaThreeVector";exports.default=k;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),B=require("react"),O=require("react-i18next"),l=require("d3-array"),z=require("@rubin-epo/epo-react-lib/HorizontalSlider"),d=require("./lib/utils.cjs"),E=require("./widgets/SupernovaThreeVector/LiveLabel/index.cjs"),r=require("./widgets/SupernovaThreeVector/styles.cjs"),N=t=>t&&t.__esModule?t:{default:t},P=N(z),k=({histogramData:t,userData:C,binnedImages:T,step:u=100})=>{const{t:x}=O.useTranslation(),i={top:30,bottom:30,left:50,right:0},m="skyMapDescription",o=600,p=o/1.6,q=[i.left,o-i.right],R=[p-i.bottom,i.top],b=6,h=7,v=0,L=l.max(t,e=>e.value)||Math.max(...t.map(({value:e})=>e)),a=l.min(t,e=>e.bin)||0,c=l.max(t,e=>e.bin)||Math.max(...t.map(({bin:e})=>e)),y=l.nice(a,c,b),g=l.nice(v,L||v,h),j=d.getLinearScale(y,q),I=d.getLinearScale(g,R),[s,S]=B.useState([a,c]),f=15,$=`calc(${i.left/o*100}% - ${f}px)`,V=`calc(${(1-j(c)/o)*100}% - ${f}px)`,_=t.map(({bin:e})=>d.between(e,s[0],s[1])),M=C.filter(({distance:e})=>d.between(e,s[0],s[1]+u)),A=t.reduce((e,{value:H},w)=>_[w]?e+H:e,0);return n.jsxs(r.ThreeVectorContainer,{children:[n.jsxs(r.ThreeVectorLayout,{children:[n.jsxs(r.HistogramContainer,{children:[n.jsx(r.ChartTitle,{children:x("supernova_three_vector.histogram.title")}),n.jsx(r.Histogram,{data:t,activeRange:s,xDomain:y,yDomain:g,xScale:j,yScale:I,yTicks:h,xTicks:b,step:u,margin:i,width:o,height:p})]}),n.jsx(r.SliderContainer,{style:{paddingInlineStart:$,paddingInlineEnd:V},children:n.jsx(P.default,{min:a,max:c,step:u,value:s,ariaValuetext:({valueNow:e})=>x("supernova_three_vector.slider.valueLabel",{value:e}),label:"distanceSlider",color:"var(--turquoise85,#12726D)",minLabel:`${a} kpc`,maxLabel:`${c} kpc`,onChangeCallback:e=>Array.isArray(e)&&S(e)})}),n.jsxs(r.SkymapContainer,{children:[n.jsx(r.ChartTitle,{children:x("supernova_three_vector.skymap.title")}),n.jsx(r.Skymap,{objects:M,images:T,describedById:m,visibleImages:_})]}),n.jsx(r.ResetButton,{onResetCallback:()=>S([a,c])})]}),n.jsx(E.default,{id:m,objects:M,min:s[0],max:s[1]+u,supernovaCount:A})]})};k.displayName="Widgets.SupernovaThreeVector";exports.default=k;
@@ -1,100 +1,106 @@
1
1
  "use client";
2
- import { jsxs as S, jsx as o } from "react/jsx-runtime";
3
- import { useState as q } from "react";
4
- import { useTranslation as z } from "react-i18next";
5
- import { max as k, min as E, nice as M } from "d3-array";
6
- import N from "@rubin-epo/epo-react-lib/HorizontalSlider";
7
- import { between as C, getLinearScale as L } from "./lib/utils.js";
8
- import U from "./widgets/SupernovaThreeVector/LiveLabel/index.js";
9
- import { ThreeVectorContainer as W, ThreeVectorLayout as F, HistogramContainer as G, Histogram as J, SliderContainer as K, SkymapContainer as P, Skymap as Q, ResetButton as X } from "./widgets/SupernovaThreeVector/styles.js";
10
- const Y = ({
11
- histogramData: n,
12
- userData: R,
13
- binnedImages: T,
2
+ import { jsxs as l, jsx as r } from "react/jsx-runtime";
3
+ import { useState as z } from "react";
4
+ import { useTranslation as E } from "react-i18next";
5
+ import { max as C, min as N, nice as M } from "d3-array";
6
+ import U from "@rubin-epo/epo-react-lib/HorizontalSlider";
7
+ import { between as L, getLinearScale as T } from "./lib/utils.js";
8
+ import W from "./widgets/SupernovaThreeVector/LiveLabel/index.js";
9
+ import { ThreeVectorContainer as F, ThreeVectorLayout as G, HistogramContainer as J, ChartTitle as R, Histogram as K, SliderContainer as P, SkymapContainer as Q, Skymap as X, ResetButton as Y } from "./widgets/SupernovaThreeVector/styles.js";
10
+ const Z = ({
11
+ histogramData: t,
12
+ userData: _,
13
+ binnedImages: $,
14
14
  step: s = 100
15
15
  }) => {
16
- const { t: $ } = z(), i = {
16
+ const { t: m } = E(), i = {
17
17
  top: 30,
18
18
  bottom: 30,
19
19
  left: 50,
20
20
  right: 0
21
- }, l = "skyMapDescription", c = 600, m = c / 1.6, j = [i.left, c - i.right], I = [m - i.bottom, i.top], d = 6, p = 7, u = 0, V = k(n, (e) => e.value) || Math.max(...n.map(({ value: e }) => e)), a = E(n, (e) => e.bin) || 0, r = k(n, (e) => e.bin) || Math.max(...n.map(({ bin: e }) => e)), x = M(a, r, d), b = M(u, V || u, p), f = L(x, j), A = L(b, I), [t, y] = q([a, r]), v = 15, B = `calc(${i.left / c * 100}% - ${v}px)`, H = `calc(${(1 - f(r) / c) * 100}% - ${v}px)`, g = n.map(
22
- ({ bin: e }) => C(e, t[0], t[1])
23
- ), h = R.filter(
24
- ({ distance: e }) => C(e, t[0], t[1] + s)
25
- ), w = n.reduce((e, { value: O }, _) => g[_] ? e + O : e, 0);
26
- return /* @__PURE__ */ S(W, { children: [
27
- /* @__PURE__ */ S(F, { children: [
28
- /* @__PURE__ */ o(G, { children: /* @__PURE__ */ o(
29
- J,
30
- {
31
- data: n,
32
- activeRange: t,
33
- xDomain: x,
34
- yDomain: b,
35
- xScale: f,
36
- yScale: A,
37
- yTicks: p,
38
- xTicks: d,
39
- step: s,
40
- margin: i,
41
- width: c,
42
- height: m
43
- }
44
- ) }),
45
- /* @__PURE__ */ o(
46
- K,
21
+ }, d = "skyMapDescription", c = 600, p = c / 1.6, j = [i.left, c - i.right], I = [p - i.bottom, i.top], u = 6, x = 7, b = 0, V = C(t, (e) => e.value) || Math.max(...t.map(({ value: e }) => e)), a = N(t, (e) => e.bin) || 0, o = C(t, (e) => e.bin) || Math.max(...t.map(({ bin: e }) => e)), h = M(a, o, u), v = M(b, V || b, x), f = T(h, j), A = T(v, I), [n, y] = z([a, o]), g = 15, B = `calc(${i.left / c * 100}% - ${g}px)`, H = `calc(${(1 - f(o) / c) * 100}% - ${g}px)`, S = t.map(
22
+ ({ bin: e }) => L(e, n[0], n[1])
23
+ ), k = _.filter(
24
+ ({ distance: e }) => L(e, n[0], n[1] + s)
25
+ ), w = t.reduce((e, { value: O }, q) => S[q] ? e + O : e, 0);
26
+ return /* @__PURE__ */ l(F, { children: [
27
+ /* @__PURE__ */ l(G, { children: [
28
+ /* @__PURE__ */ l(J, { children: [
29
+ /* @__PURE__ */ r(R, { children: m("supernova_three_vector.histogram.title") }),
30
+ /* @__PURE__ */ r(
31
+ K,
32
+ {
33
+ data: t,
34
+ activeRange: n,
35
+ xDomain: h,
36
+ yDomain: v,
37
+ xScale: f,
38
+ yScale: A,
39
+ yTicks: x,
40
+ xTicks: u,
41
+ step: s,
42
+ margin: i,
43
+ width: c,
44
+ height: p
45
+ }
46
+ )
47
+ ] }),
48
+ /* @__PURE__ */ r(
49
+ P,
47
50
  {
48
51
  style: {
49
52
  paddingInlineStart: B,
50
53
  paddingInlineEnd: H
51
54
  },
52
- children: /* @__PURE__ */ o(
53
- N,
55
+ children: /* @__PURE__ */ r(
56
+ U,
54
57
  {
55
58
  min: a,
56
- max: r,
59
+ max: o,
57
60
  step: s,
58
- value: t,
59
- ariaValuetext: ({ valueNow: e }) => $("supernova_three_vector.slider.valueLabel", { value: e }),
61
+ value: n,
62
+ ariaValuetext: ({ valueNow: e }) => m("supernova_three_vector.slider.valueLabel", { value: e }),
60
63
  label: "distanceSlider",
61
64
  color: "var(--turquoise85,#12726D)",
62
65
  minLabel: `${a} kpc`,
63
- maxLabel: `${r} kpc`,
66
+ maxLabel: `${o} kpc`,
64
67
  onChangeCallback: (e) => Array.isArray(e) && y(e)
65
68
  }
66
69
  )
67
70
  }
68
71
  ),
69
- /* @__PURE__ */ o(P, { children: /* @__PURE__ */ o(
70
- Q,
71
- {
72
- objects: h,
73
- images: T,
74
- describedById: l,
75
- visibleImages: g
76
- }
77
- ) }),
78
- /* @__PURE__ */ o(
79
- X,
72
+ /* @__PURE__ */ l(Q, { children: [
73
+ /* @__PURE__ */ r(R, { children: m("supernova_three_vector.skymap.title") }),
74
+ /* @__PURE__ */ r(
75
+ X,
76
+ {
77
+ objects: k,
78
+ images: $,
79
+ describedById: d,
80
+ visibleImages: S
81
+ }
82
+ )
83
+ ] }),
84
+ /* @__PURE__ */ r(
85
+ Y,
80
86
  {
81
- onResetCallback: () => y([a, r])
87
+ onResetCallback: () => y([a, o])
82
88
  }
83
89
  )
84
90
  ] }),
85
- /* @__PURE__ */ o(
86
- U,
91
+ /* @__PURE__ */ r(
92
+ W,
87
93
  {
88
- id: l,
89
- objects: h,
90
- min: t[0],
91
- max: t[1] + s,
94
+ id: d,
95
+ objects: k,
96
+ min: n[0],
97
+ max: n[1] + s,
92
98
  supernovaCount: w
93
99
  }
94
100
  )
95
101
  ] });
96
102
  };
97
- Y.displayName = "Widgets.SupernovaThreeVector";
103
+ Z.displayName = "Widgets.SupernovaThreeVector";
98
104
  export {
99
- Y as default
105
+ Z as default
100
106
  };
@@ -82,6 +82,7 @@
82
82
  },
83
83
  "supernova_three_vector": {
84
84
  "histogram": {
85
+ "title": "Supernova Distances",
85
86
  "x_label": "Distance [kpc]",
86
87
  "bar_label_one": "{{binMin}} to {{binMax}} kiloparsecs: {{count}} supernova",
87
88
  "bar_label_other": "{{binMin}} to {{binMax}} kiloparsecs: {{count}} supernovae"
@@ -91,6 +92,7 @@
91
92
  "valueLabel": "{{value}} kiloparsecs"
92
93
  },
93
94
  "skymap": {
95
+ "title": "Supernova Distribution",
94
96
  "description": "$t(supernova_three_vector.skymap.supernova_count, {\"count\": {{supernovaCount}}, \"min\": {{min}}, \"max\": {{max}}}) $t(supernova_three_vector.skymap.user_supernova_count, {\"count\": {{userObjectCount}}})",
95
97
  "supernova_count_one": "Sky map projection showing {{count}} supernova between the distances of {{min}} and {{max}} kiloparsecs.",
96
98
  "supernova_count_other": "Sky map projection showing {{count}} supernovae between the distances of {{min}} and {{max}} kiloparsecs.",
@@ -1,7 +1,8 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("styled-components"),e=require("@rubin-epo/epo-react-lib/styles"),r=require("../../atomic/Button/patterns/Reset.cjs"),o=require("./Histogram/index.cjs"),a=require("./Skymap/index.cjs"),s=n=>n&&n.__esModule?n:{default:n},t=s(i),d=t.default.div`
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("styled-components"),t=require("@rubin-epo/epo-react-lib/styles"),r=require("../../atomic/Button/patterns/Reset.cjs"),a=require("./Histogram/index.cjs"),o=require("./Skymap/index.cjs"),s=n=>n&&n.__esModule?n:{default:n},e=s(i),d=e.default.div`
2
2
  container-type: inline-size;
3
- `,m=t.default.div`
4
- align-items: center;
3
+ `,c=e.default.div`
4
+ --three-vector-gap: calc(var(--PADDING_SMALL, 20px) / 2);
5
+
5
6
  display: grid;
6
7
  grid-template-columns: 1fr;
7
8
  grid-template-rows: min-content 1fr min-content min-content;
@@ -10,9 +11,9 @@
10
11
  "histogram"
11
12
  "slider"
12
13
  "reset";
13
- gap: calc(var(--PADDING_SMALL, 20px) / 2);
14
+ gap: var(--three-vector-gap);
14
15
 
15
- @container (min-width: ${e.token("BREAK_PHABLET_MIN")}) {
16
+ @container (min-width: ${t.token("BREAK_PHABLET_MIN")}) {
16
17
  grid-template-columns: 1fr 1fr;
17
18
  grid-template-rows: 1fr min-content min-content;
18
19
  grid-template-areas:
@@ -21,58 +22,67 @@
21
22
  "reset reset";
22
23
  }
23
24
 
24
- @container (min-width: ${e.token("BREAK_TABLET_MIN")}) {
25
- gap: var(--PADDING_SMALL, 20px);
25
+ @container (min-width: ${t.token("BREAK_TABLET_MIN")}) {
26
+ --three-vector-gap: var(--PADDING_SMALL, 20px);
27
+ gap: var(--three-vector-gap);
26
28
  }
27
- `,c=t.default.div`
29
+ `,l=e.default.div`
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: var(--three-vector-gap);
28
33
  container-type: inline-size;
29
34
  grid-area: histogram;
30
- `,l=t.default(o.default)`
35
+ `,m=e.default(a.default)`
31
36
  font-size: 2.25em;
32
37
 
33
38
  @container (
34
- min-width: ${e.token("BREAK_MOBILE")}
39
+ min-width: ${t.token("BREAK_MOBILE")}
35
40
  ) {
36
41
  font-size: 1.5em;
37
42
  }
38
43
 
39
44
  @container (
40
- min-width: ${e.token("BREAK_PHABLET_MIN")}
45
+ min-width: ${t.token("BREAK_PHABLET_MIN")}
41
46
  ) {
42
47
  font-size: 1.25em;
43
48
  }
44
49
 
45
50
  @container (
46
- min-width: ${e.token("BREAK_LARGE_TABLET_MIN")}
51
+ min-width: ${t.token("BREAK_LARGE_TABLET_MIN")}
47
52
  ) {
48
53
  font-size: 1em;
49
54
  }
50
- `,u=t.default.div`
55
+ `,f=e.default.div`
51
56
  grid-area: slider;
52
- `,f=t.default(r.default)`
57
+ `,p=e.default(r.default)`
53
58
  grid-area: reset;
54
- `,g=t.default.div`
59
+ `,u=e.default.div`
60
+ display: flex;
61
+ flex-direction: column;
62
+ gap: var(--three-vector-gap);
55
63
  container-type: inline-size;
56
64
  grid-area: skymap;
57
- `,p=t.default(a.default)`
65
+ `,g=e.default(o.default)`
58
66
  max-width: 100%;
59
67
  font-size: 2.25em;
60
68
 
61
69
  @container (
62
- min-width: ${e.token("BREAK_MOBILE")}
70
+ min-width: ${t.token("BREAK_MOBILE")}
63
71
  ) {
64
72
  font-size: 1.5em;
65
73
  }
66
74
 
67
75
  @container (
68
- min-width: ${e.token("BREAK_PHABLET_MIN")}
76
+ min-width: ${t.token("BREAK_PHABLET_MIN")}
69
77
  ) {
70
78
  font-size: 1.25em;
71
79
  }
72
80
 
73
81
  @container (
74
- min-width: ${e.token("BREAK_LARGE_TABLET_MIN")}
82
+ min-width: ${t.token("BREAK_LARGE_TABLET_MIN")}
75
83
  ) {
76
84
  font-size: 1em;
77
85
  }
78
- `;exports.Histogram=l;exports.HistogramContainer=c;exports.ResetButton=f;exports.Skymap=p;exports.SkymapContainer=g;exports.SliderContainer=u;exports.ThreeVectorContainer=d;exports.ThreeVectorLayout=m;
86
+ `,h=e.default.h4`
87
+ margin: 0;
88
+ `;exports.ChartTitle=h;exports.Histogram=m;exports.HistogramContainer=l;exports.ResetButton=p;exports.Skymap=g;exports.SkymapContainer=u;exports.SliderContainer=f;exports.ThreeVectorContainer=d;exports.ThreeVectorLayout=c;
@@ -2,12 +2,13 @@
2
2
  import e from "styled-components";
3
3
  import { token as t } from "@rubin-epo/epo-react-lib/styles";
4
4
  import i from "../../atomic/Button/patterns/Reset.js";
5
- import n from "./Histogram/index.js";
6
- import r from "./Skymap/index.js";
7
- const d = e.div`
5
+ import r from "./Histogram/index.js";
6
+ import n from "./Skymap/index.js";
7
+ const p = e.div`
8
8
  container-type: inline-size;
9
- `, p = e.div`
10
- align-items: center;
9
+ `, d = e.div`
10
+ --three-vector-gap: calc(var(--PADDING_SMALL, 20px) / 2);
11
+
11
12
  display: grid;
12
13
  grid-template-columns: 1fr;
13
14
  grid-template-rows: min-content 1fr min-content min-content;
@@ -16,7 +17,7 @@ const d = e.div`
16
17
  "histogram"
17
18
  "slider"
18
19
  "reset";
19
- gap: calc(var(--PADDING_SMALL, 20px) / 2);
20
+ gap: var(--three-vector-gap);
20
21
 
21
22
  @container (min-width: ${t("BREAK_PHABLET_MIN")}) {
22
23
  grid-template-columns: 1fr 1fr;
@@ -28,12 +29,16 @@ const d = e.div`
28
29
  }
29
30
 
30
31
  @container (min-width: ${t("BREAK_TABLET_MIN")}) {
31
- gap: var(--PADDING_SMALL, 20px);
32
+ --three-vector-gap: var(--PADDING_SMALL, 20px);
33
+ gap: var(--three-vector-gap);
32
34
  }
33
35
  `, g = e.div`
36
+ display: flex;
37
+ flex-direction: column;
38
+ gap: var(--three-vector-gap);
34
39
  container-type: inline-size;
35
40
  grid-area: histogram;
36
- `, l = e(n)`
41
+ `, l = e(r)`
37
42
  font-size: 2.25em;
38
43
 
39
44
  @container (
@@ -53,14 +58,17 @@ const d = e.div`
53
58
  ) {
54
59
  font-size: 1em;
55
60
  }
56
- `, A = e.div`
61
+ `, f = e.div`
57
62
  grid-area: slider;
58
- `, B = e(i)`
63
+ `, h = e(i)`
59
64
  grid-area: reset;
60
- `, f = e.div`
65
+ `, A = e.div`
66
+ display: flex;
67
+ flex-direction: column;
68
+ gap: var(--three-vector-gap);
61
69
  container-type: inline-size;
62
70
  grid-area: skymap;
63
- `, E = e(r)`
71
+ `, B = e(n)`
64
72
  max-width: 100%;
65
73
  font-size: 2.25em;
66
74
 
@@ -81,14 +89,17 @@ const d = e.div`
81
89
  ) {
82
90
  font-size: 1em;
83
91
  }
92
+ `, E = e.h4`
93
+ margin: 0;
84
94
  `;
85
95
  export {
96
+ E as ChartTitle,
86
97
  l as Histogram,
87
98
  g as HistogramContainer,
88
- B as ResetButton,
89
- E as Skymap,
90
- f as SkymapContainer,
91
- A as SliderContainer,
92
- d as ThreeVectorContainer,
93
- p as ThreeVectorLayout
99
+ h as ResetButton,
100
+ B as Skymap,
101
+ A as SkymapContainer,
102
+ f as SliderContainer,
103
+ p as ThreeVectorContainer,
104
+ d as ThreeVectorLayout
94
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubin-epo/epo-widget-lib",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Rubin Observatory Education & Public Outreach team React scientific and educational widgets.",
5
5
  "author": "Rubin EPO",
6
6
  "license": "MIT",