@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"),
|
|
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
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { max as
|
|
6
|
-
import
|
|
7
|
-
import { between as
|
|
8
|
-
import
|
|
9
|
-
import { ThreeVectorContainer as
|
|
10
|
-
const
|
|
11
|
-
histogramData:
|
|
12
|
-
userData:
|
|
13
|
-
binnedImages:
|
|
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:
|
|
16
|
+
const { t: m } = E(), i = {
|
|
17
17
|
top: 30,
|
|
18
18
|
bottom: 30,
|
|
19
19
|
left: 50,
|
|
20
20
|
right: 0
|
|
21
|
-
},
|
|
22
|
-
({ bin: e }) =>
|
|
23
|
-
),
|
|
24
|
-
({ distance: e }) =>
|
|
25
|
-
), w =
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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__ */
|
|
53
|
-
|
|
55
|
+
children: /* @__PURE__ */ r(
|
|
56
|
+
U,
|
|
54
57
|
{
|
|
55
58
|
min: a,
|
|
56
|
-
max:
|
|
59
|
+
max: o,
|
|
57
60
|
step: s,
|
|
58
|
-
value:
|
|
59
|
-
ariaValuetext: ({ valueNow: 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: `${
|
|
66
|
+
maxLabel: `${o} kpc`,
|
|
64
67
|
onChangeCallback: (e) => Array.isArray(e) && y(e)
|
|
65
68
|
}
|
|
66
69
|
)
|
|
67
70
|
}
|
|
68
71
|
),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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,
|
|
87
|
+
onResetCallback: () => y([a, o])
|
|
82
88
|
}
|
|
83
89
|
)
|
|
84
90
|
] }),
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
91
|
+
/* @__PURE__ */ r(
|
|
92
|
+
W,
|
|
87
93
|
{
|
|
88
|
-
id:
|
|
89
|
-
objects:
|
|
90
|
-
min:
|
|
91
|
-
max:
|
|
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
|
-
|
|
103
|
+
Z.displayName = "Widgets.SupernovaThreeVector";
|
|
98
104
|
export {
|
|
99
|
-
|
|
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"),
|
|
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
|
-
`,
|
|
4
|
-
|
|
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:
|
|
14
|
+
gap: var(--three-vector-gap);
|
|
14
15
|
|
|
15
|
-
@container (min-width: ${
|
|
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: ${
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
35
|
+
`,m=e.default(a.default)`
|
|
31
36
|
font-size: 2.25em;
|
|
32
37
|
|
|
33
38
|
@container (
|
|
34
|
-
min-width: ${
|
|
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: ${
|
|
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: ${
|
|
51
|
+
min-width: ${t.token("BREAK_LARGE_TABLET_MIN")}
|
|
47
52
|
) {
|
|
48
53
|
font-size: 1em;
|
|
49
54
|
}
|
|
50
|
-
`,
|
|
55
|
+
`,f=e.default.div`
|
|
51
56
|
grid-area: slider;
|
|
52
|
-
`,
|
|
57
|
+
`,p=e.default(r.default)`
|
|
53
58
|
grid-area: reset;
|
|
54
|
-
`,
|
|
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
|
-
`,
|
|
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: ${
|
|
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: ${
|
|
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: ${
|
|
82
|
+
min-width: ${t.token("BREAK_LARGE_TABLET_MIN")}
|
|
75
83
|
) {
|
|
76
84
|
font-size: 1em;
|
|
77
85
|
}
|
|
78
|
-
|
|
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
|
|
6
|
-
import
|
|
7
|
-
const
|
|
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
|
-
`,
|
|
10
|
-
|
|
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:
|
|
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(
|
|
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
|
-
`,
|
|
61
|
+
`, f = e.div`
|
|
57
62
|
grid-area: slider;
|
|
58
|
-
`,
|
|
63
|
+
`, h = e(i)`
|
|
59
64
|
grid-area: reset;
|
|
60
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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