@rubin-epo/epo-widget-lib 1.0.3 → 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"),
|
|
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
|
|
3
|
-
import { useId as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { range as
|
|
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
|
|
9
|
-
import
|
|
10
|
-
import { useAlertsAsPoints as
|
|
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
|
|
13
|
-
import { DM15Display as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { mergeWithDefaults as
|
|
19
|
-
const
|
|
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:
|
|
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:
|
|
28
|
+
userMagnitude: _,
|
|
29
29
|
onUserMagnitudeChangeCallback: n,
|
|
30
30
|
onGaussianChangeCallback: l,
|
|
31
31
|
onYOffsetChangeCallback: p,
|
|
32
|
-
className:
|
|
32
|
+
className: F,
|
|
33
33
|
isDisplayOnly: g,
|
|
34
|
-
...
|
|
34
|
+
...H
|
|
35
35
|
}) => {
|
|
36
|
-
const { t: v } =
|
|
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 =
|
|
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 =
|
|
42
|
-
|
|
41
|
+
}, b = X(0, m, s), q = /* @__PURE__ */ t(
|
|
42
|
+
J,
|
|
43
43
|
{
|
|
44
44
|
slider: /* @__PURE__ */ t(
|
|
45
|
-
|
|
45
|
+
O,
|
|
46
46
|
{
|
|
47
|
-
magnitude:
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
yStart: W,
|
|
58
|
+
yDomain: $,
|
|
59
|
+
xStart: P,
|
|
60
|
+
xEnd: z,
|
|
61
|
+
yStart: L,
|
|
63
62
|
yEnd: u,
|
|
64
|
-
Data:
|
|
65
|
-
}) => /* @__PURE__ */
|
|
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:
|
|
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
|
-
|
|
77
|
+
E,
|
|
79
78
|
/* @__PURE__ */ t(
|
|
80
|
-
|
|
79
|
+
U,
|
|
81
80
|
{
|
|
82
|
-
points:
|
|
83
|
-
x: o(
|
|
84
|
-
y: e(
|
|
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(
|
|
86
|
+
transform: `translate(0,${e($[1] - s)})`,
|
|
87
|
+
strokeLinecap: "round"
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
),
|
|
91
91
|
/* @__PURE__ */ t(
|
|
92
|
-
|
|
92
|
+
C,
|
|
93
93
|
{
|
|
94
|
-
x:
|
|
94
|
+
x: P,
|
|
95
95
|
y: u,
|
|
96
|
-
outerHeight:
|
|
97
|
-
outerWidth:
|
|
96
|
+
outerHeight: L - u,
|
|
97
|
+
outerWidth: z - P,
|
|
98
98
|
innerWidth: c,
|
|
99
99
|
innerHeight: h,
|
|
100
|
-
children: /* @__PURE__ */ t(
|
|
100
|
+
children: /* @__PURE__ */ t(S, { gaussianWidth: m })
|
|
101
101
|
}
|
|
102
102
|
)
|
|
103
103
|
] }),
|
|
104
|
-
...
|
|
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
|
-
|
|
113
|
+
G,
|
|
114
114
|
{
|
|
115
|
-
className:
|
|
115
|
+
className: F,
|
|
116
116
|
isDisplayOnly: g,
|
|
117
117
|
ratio: { landscape: 3 / 2, portrait: 2 / 3 },
|
|
118
|
-
widget:
|
|
119
|
-
controls: /* @__PURE__ */
|
|
118
|
+
widget: q,
|
|
119
|
+
controls: /* @__PURE__ */ W(a, { children: [
|
|
120
120
|
/* @__PURE__ */ t(
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
+
K,
|
|
160
160
|
{
|
|
161
|
-
controlledById:
|
|
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:
|
|
169
|
+
actions: /* @__PURE__ */ t(k, { onResetCallback: j })
|
|
170
170
|
}
|
|
171
171
|
) });
|
|
172
172
|
};
|
|
173
|
-
|
|
174
|
-
const
|
|
173
|
+
I.displayName = "Widgets.LightCurve";
|
|
174
|
+
const vt = I;
|
|
175
175
|
export {
|
|
176
|
-
|
|
176
|
+
vt as default
|
|
177
177
|
};
|
package/package.json
CHANGED