@rubin-epo/epo-widget-lib 1.0.6 → 1.0.7
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.
- package/dist/IsochronePlot.cjs +1 -1
- package/dist/IsochronePlot.js +121 -114
- package/package.json +1 -1
package/dist/IsochronePlot.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),M=require("react"),Q=require("react-i18next"),U=require("use-resize-observer"),$=require("@rubin-epo/epo-react-lib/styles"),X=require("./layout/Controls/index.cjs"),Y=require("./charts/ScatterPlot/index.cjs"),Z=require("./atomic/Button/patterns/Reset.cjs");require("./atomic/PlotWrapper/index.cjs");const ee=require("./charts/Readout/index.cjs"),te=require("./charts/PathFromPoints/index.cjs"),g=require("./lib/utils.cjs"),se=require("./widgets/IsochronePlot/Controls/index.cjs"),n=require("./widgets/IsochronePlot/defaults.cjs"),ie=require("./widgets/IsochronePlot/A11Y/CurveFit.cjs"),K=require("./widgets/IsochronePlot/helpers.cjs"),re=require("./atomic/PlotWrapper/styles.cjs"),ne=e=>e&&e.__esModule?e:{default:e},oe=ne(U),ae=e=>e?e<parseFloat($.token("BREAK_PHABLET_MIN"))?n.default.pointRadius.md:e<parseFloat($.token("BREAK_LARGE_TABLET"))?n.default.pointRadius.sm:n.default.pointRadius.lg:n.default.pointRadius.lg,O=(e,o,i=2)=>{if(i<0)return"";const r=e.toFixed(i);return o.includes(r)?r:O(e,o,i-1)},le=(e,o,i,r)=>{const m=O(e,Object.keys(r)),l=r[m];return l?l.map(({x:p,y:x})=>({x:o(p),y:i(x)})):[]},ue=({data:e,value:o,ageLibrary:i,isDisplayOnly:r=!1,isLoading:m,xAxis:l,yAxis:p,name:x,onChangeCallback:h})=>{const{ref:z,width:B}=oe.default(),{t:b,i18n:{language:v}}=Q.useTranslation(),[E,H]=M.useState(!0),L=M.useId(),u=!m&&!E,S={top:0,right:0,bottom:20,left:20},{width:q,height:y}=n.default,{ages:A={}}=i,a=Object.keys(A).sort((s,f)=>parseFloat(s)-parseFloat(f)).map(parseFloat),V=g.mergeWithDefaults(l,{...n.default.xAxis,label:b("isochrone_plot.plot.x_label")}),F=g.mergeWithDefaults(p,{...n.default.yAxis,label:b("isochrone_plot.plot.y_label")}),c={age:{min:a.length>0?Math.min(...a):0,max:a.length>0?Math.max(...a):0,step:.05},distance:{min:0,max:F.min+1,step:.05}},D={age:a.length>0?g.middle(a):0,distance:(c.distance.max-c.distance.min)/2+c.distance.min},{age:d,distance:_}=g.mergeWithDefaults(o,D),w=ae(B),j={age:s=>K.ageToGyrs(s).toLocaleString(v,{minimumFractionDigits:3,maximumFractionDigits:3}),distance:s=>K.distanceToLyrs(s).toLocaleString(v,{maximumFractionDigits:0})},W={age:j.age(d),distance:j.distance(_)},G=t.jsx(re.PlotWrapper,{ref:z,children:t.jsx(Y.default,{renderer:"canvas",title:x,onLoadedCallback:()=>H(!1),data:{label:"Star Cluster",points:e.map(s=>({...s,radius:w,stroke:"rgba(18,114,108,0.5)",fill:"rgba(18,114,108,0.25)"}))},plotChildren:({Data:s,xScale:f,yScale:R,yStart:C,yEnd:k,xStart:I,xEnd:N,yDomain:J})=>{const P=le(d,f,R,A),T=R(_+J[1]);return t.jsxs(t.Fragment,{children:[s,d&&t.jsx(te.default,{points:P,svgProps:{strokeWidth:2,transform:`translate(0,${T})`}}),u&&t.jsx(ee.default,{viewport:{x:I,y:k,outerHeight:C-k,outerWidth:N-I,innerWidth:q,innerHeight:y},position:"center right",forIds:L,forScreenreaders:t.jsx(ie.default,{points:e,value:W,isochrone:P,offset:T,xScale:f,yScale:R,width:q,height:y}),children:b("isochrone_plot.output",{...W})})]})},width:q,height:y,xAxis:V,yAxis:F,margins:S})});return t.jsx(X.default,{ratio:{portrait:2/3,landscape:3/2},widget:G,controls:t.jsx(se.default,{isDisabled:!u,value:{age:d,distance:_},localizers:j,configs:c,onChangeCallback:h}),actions:t.jsx(Z.default,{isDisabled:!u,onResetCallback:()=>{h&&h(D)}}),isLoading:!u,isDisplayOnly:r,controlsId:L})};exports.default=ue;
|
package/dist/IsochronePlot.js
CHANGED
|
@@ -1,176 +1,183 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import it from "./atomic/Button/patterns/Reset.js";
|
|
2
|
+
import { jsx as e, jsxs as q, Fragment as J } from "react/jsx-runtime";
|
|
3
|
+
import { useState as Q, useId as U } from "react";
|
|
4
|
+
import { useTranslation as X } from "react-i18next";
|
|
5
|
+
import Y from "use-resize-observer";
|
|
6
|
+
import { token as j } from "@rubin-epo/epo-react-lib/styles";
|
|
7
|
+
import Z from "./layout/Controls/index.js";
|
|
8
|
+
import tt from "./charts/ScatterPlot/index.js";
|
|
9
|
+
import ot from "./atomic/Button/patterns/Reset.js";
|
|
11
10
|
import "./atomic/PlotWrapper/index.js";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { mergeWithDefaults as
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { ageToGyrs as
|
|
19
|
-
import { PlotWrapper as
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
import et from "./charts/Readout/index.js";
|
|
12
|
+
import rt from "./charts/PathFromPoints/index.js";
|
|
13
|
+
import { mergeWithDefaults as A, middle as it } from "./lib/utils.js";
|
|
14
|
+
import st from "./widgets/IsochronePlot/Controls/index.js";
|
|
15
|
+
import s from "./widgets/IsochronePlot/defaults.js";
|
|
16
|
+
import nt from "./widgets/IsochronePlot/A11Y/CurveFit.js";
|
|
17
|
+
import { ageToGyrs as at, distanceToLyrs as lt } from "./widgets/IsochronePlot/helpers.js";
|
|
18
|
+
import { PlotWrapper as mt } from "./atomic/PlotWrapper/styles.js";
|
|
19
|
+
const ct = (t) => t ? t < parseFloat(j("BREAK_PHABLET_MIN")) ? s.pointRadius.md : t < parseFloat(j("BREAK_LARGE_TABLET")) ? s.pointRadius.sm : s.pointRadius.lg : s.pointRadius.lg, E = (t, n, r = 2) => {
|
|
20
|
+
if (r < 0)
|
|
21
|
+
return "";
|
|
22
|
+
const i = t.toFixed(r);
|
|
23
|
+
return n.includes(i) ? i : E(t, n, r - 1);
|
|
24
|
+
}, dt = (t, n, r, i) => {
|
|
25
|
+
const u = E(t, Object.keys(i)), l = i[u];
|
|
26
|
+
return l ? l.map(({ x: g, y: f }) => ({ x: n(g), y: r(f) })) : [];
|
|
27
|
+
}, Dt = ({
|
|
28
|
+
data: t,
|
|
29
|
+
value: n,
|
|
30
|
+
ageLibrary: r,
|
|
31
|
+
isDisplayOnly: i = !1,
|
|
32
|
+
isLoading: u,
|
|
33
|
+
xAxis: l,
|
|
34
|
+
yAxis: g,
|
|
35
|
+
name: f,
|
|
36
|
+
onChangeCallback: h
|
|
30
37
|
}) => {
|
|
31
|
-
const { ref:
|
|
32
|
-
t:
|
|
33
|
-
i18n: { language:
|
|
34
|
-
} =
|
|
35
|
-
(
|
|
36
|
-
).map(parseFloat), V =
|
|
37
|
-
...
|
|
38
|
-
label:
|
|
39
|
-
}),
|
|
40
|
-
...
|
|
41
|
-
label:
|
|
42
|
-
}),
|
|
38
|
+
const { ref: z, width: C } = Y(), {
|
|
39
|
+
t: x,
|
|
40
|
+
i18n: { language: v }
|
|
41
|
+
} = X(), [H, M] = Q(!0), P = U(), m = !u && !H, O = { top: 0, right: 0, bottom: 20, left: 20 }, { width: b, height: y } = s, { ages: _ = {} } = r, a = Object.keys(_).sort(
|
|
42
|
+
(o, p) => parseFloat(o) - parseFloat(p)
|
|
43
|
+
).map(parseFloat), V = A(l, {
|
|
44
|
+
...s.xAxis,
|
|
45
|
+
label: x("isochrone_plot.plot.x_label")
|
|
46
|
+
}), W = A(g, {
|
|
47
|
+
...s.yAxis,
|
|
48
|
+
label: x("isochrone_plot.plot.y_label")
|
|
49
|
+
}), c = {
|
|
43
50
|
age: {
|
|
44
|
-
min:
|
|
45
|
-
max:
|
|
46
|
-
step:
|
|
51
|
+
min: a.length > 0 ? Math.min(...a) : 0,
|
|
52
|
+
max: a.length > 0 ? Math.max(...a) : 0,
|
|
53
|
+
step: 0.05
|
|
47
54
|
},
|
|
48
|
-
distance: { min: 0, max:
|
|
49
|
-
},
|
|
50
|
-
age:
|
|
51
|
-
distance: (
|
|
52
|
-
}, { age:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
), w =
|
|
56
|
-
age: (
|
|
55
|
+
distance: { min: 0, max: W.min + 1, step: 0.05 }
|
|
56
|
+
}, k = {
|
|
57
|
+
age: a.length > 0 ? it(a) : 0,
|
|
58
|
+
distance: (c.distance.max - c.distance.min) / 2 + c.distance.min
|
|
59
|
+
}, { age: d, distance: F } = A(
|
|
60
|
+
n,
|
|
61
|
+
k
|
|
62
|
+
), w = ct(C), L = {
|
|
63
|
+
age: (o) => at(o).toLocaleString(v, {
|
|
57
64
|
minimumFractionDigits: 3,
|
|
58
65
|
maximumFractionDigits: 3
|
|
59
66
|
}),
|
|
60
|
-
distance: (
|
|
67
|
+
distance: (o) => lt(o).toLocaleString(v, {
|
|
61
68
|
maximumFractionDigits: 0
|
|
62
69
|
})
|
|
63
|
-
},
|
|
64
|
-
age:
|
|
65
|
-
distance:
|
|
66
|
-
}, G = /* @__PURE__ */ e(
|
|
67
|
-
|
|
70
|
+
}, B = {
|
|
71
|
+
age: L.age(d),
|
|
72
|
+
distance: L.distance(F)
|
|
73
|
+
}, G = /* @__PURE__ */ e(mt, { ref: z, children: /* @__PURE__ */ e(
|
|
74
|
+
tt,
|
|
68
75
|
{
|
|
69
76
|
renderer: "canvas",
|
|
70
|
-
title:
|
|
71
|
-
onLoadedCallback: () =>
|
|
77
|
+
title: f,
|
|
78
|
+
onLoadedCallback: () => M(!1),
|
|
72
79
|
data: {
|
|
73
80
|
label: "Star Cluster",
|
|
74
|
-
points:
|
|
75
|
-
...
|
|
81
|
+
points: t.map((o) => ({
|
|
82
|
+
...o,
|
|
76
83
|
radius: w,
|
|
77
84
|
stroke: "rgba(18,114,108,0.5)",
|
|
78
85
|
fill: "rgba(18,114,108,0.25)"
|
|
79
86
|
}))
|
|
80
87
|
},
|
|
81
88
|
plotChildren: ({
|
|
82
|
-
Data:
|
|
83
|
-
xScale:
|
|
84
|
-
yScale:
|
|
85
|
-
yStart:
|
|
86
|
-
yEnd:
|
|
87
|
-
xStart:
|
|
88
|
-
xEnd:
|
|
89
|
-
yDomain:
|
|
89
|
+
Data: o,
|
|
90
|
+
xScale: p,
|
|
91
|
+
yScale: R,
|
|
92
|
+
yStart: S,
|
|
93
|
+
yEnd: D,
|
|
94
|
+
xStart: I,
|
|
95
|
+
xEnd: N,
|
|
96
|
+
yDomain: $
|
|
90
97
|
}) => {
|
|
91
|
-
const
|
|
92
|
-
return /* @__PURE__ */ J
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
const T = dt(d, p, R, _), K = R(F + $[1]);
|
|
99
|
+
return /* @__PURE__ */ q(J, { children: [
|
|
100
|
+
o,
|
|
101
|
+
d && /* @__PURE__ */ e(
|
|
102
|
+
rt,
|
|
96
103
|
{
|
|
97
|
-
points:
|
|
104
|
+
points: T,
|
|
98
105
|
svgProps: {
|
|
99
106
|
strokeWidth: 2,
|
|
100
|
-
transform: `translate(0,${
|
|
107
|
+
transform: `translate(0,${K})`
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
110
|
),
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
m && /* @__PURE__ */ e(
|
|
112
|
+
et,
|
|
106
113
|
{
|
|
107
114
|
viewport: {
|
|
108
|
-
x:
|
|
109
|
-
y:
|
|
110
|
-
outerHeight:
|
|
111
|
-
outerWidth:
|
|
112
|
-
innerWidth:
|
|
113
|
-
innerHeight:
|
|
115
|
+
x: I,
|
|
116
|
+
y: D,
|
|
117
|
+
outerHeight: S - D,
|
|
118
|
+
outerWidth: N - I,
|
|
119
|
+
innerWidth: b,
|
|
120
|
+
innerHeight: y
|
|
114
121
|
},
|
|
115
122
|
position: "center right",
|
|
116
|
-
forIds:
|
|
123
|
+
forIds: P,
|
|
117
124
|
forScreenreaders: /* @__PURE__ */ e(
|
|
118
|
-
|
|
125
|
+
nt,
|
|
119
126
|
{
|
|
120
|
-
points:
|
|
121
|
-
value:
|
|
122
|
-
isochrone:
|
|
123
|
-
offset:
|
|
124
|
-
xScale:
|
|
125
|
-
yScale:
|
|
126
|
-
width:
|
|
127
|
-
height:
|
|
127
|
+
points: t,
|
|
128
|
+
value: B,
|
|
129
|
+
isochrone: T,
|
|
130
|
+
offset: K,
|
|
131
|
+
xScale: p,
|
|
132
|
+
yScale: R,
|
|
133
|
+
width: b,
|
|
134
|
+
height: y
|
|
128
135
|
}
|
|
129
136
|
),
|
|
130
|
-
children:
|
|
131
|
-
...
|
|
137
|
+
children: x("isochrone_plot.output", {
|
|
138
|
+
...B
|
|
132
139
|
})
|
|
133
140
|
}
|
|
134
141
|
)
|
|
135
142
|
] });
|
|
136
143
|
},
|
|
137
|
-
width:
|
|
138
|
-
height:
|
|
144
|
+
width: b,
|
|
145
|
+
height: y,
|
|
139
146
|
xAxis: V,
|
|
140
|
-
yAxis:
|
|
141
|
-
margins:
|
|
147
|
+
yAxis: W,
|
|
148
|
+
margins: O
|
|
142
149
|
}
|
|
143
150
|
) });
|
|
144
151
|
return /* @__PURE__ */ e(
|
|
145
|
-
|
|
152
|
+
Z,
|
|
146
153
|
{
|
|
147
154
|
ratio: { portrait: 2 / 3, landscape: 3 / 2 },
|
|
148
155
|
widget: G,
|
|
149
156
|
controls: /* @__PURE__ */ e(
|
|
150
|
-
|
|
157
|
+
st,
|
|
151
158
|
{
|
|
152
|
-
isDisabled: !
|
|
153
|
-
value: { age:
|
|
154
|
-
localizers:
|
|
155
|
-
configs:
|
|
156
|
-
onChangeCallback:
|
|
159
|
+
isDisabled: !m,
|
|
160
|
+
value: { age: d, distance: F },
|
|
161
|
+
localizers: L,
|
|
162
|
+
configs: c,
|
|
163
|
+
onChangeCallback: h
|
|
157
164
|
}
|
|
158
165
|
),
|
|
159
166
|
actions: /* @__PURE__ */ e(
|
|
160
|
-
|
|
167
|
+
ot,
|
|
161
168
|
{
|
|
162
|
-
isDisabled: !
|
|
169
|
+
isDisabled: !m,
|
|
163
170
|
onResetCallback: () => {
|
|
164
|
-
|
|
171
|
+
h && h(k);
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
174
|
),
|
|
168
|
-
isLoading: !
|
|
169
|
-
isDisplayOnly:
|
|
170
|
-
controlsId:
|
|
175
|
+
isLoading: !m,
|
|
176
|
+
isDisplayOnly: i,
|
|
177
|
+
controlsId: P
|
|
171
178
|
}
|
|
172
179
|
);
|
|
173
180
|
};
|
|
174
181
|
export {
|
|
175
|
-
|
|
182
|
+
Dt as default
|
|
176
183
|
};
|
package/package.json
CHANGED