@rubin-epo/epo-widget-lib 0.10.3 → 0.10.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 strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("../../lib/utils.cjs"),a=require("d3-array"),k={linear:d.getLinearScale},M=(s,t,e)=>s>t?-Math.abs(e):Math.abs(e),h=(s,t)=>s.map((e,n)=>n===0?e-t:e+t),p=({min:s,max:t,step:e,ticks:n=5,range:o,scale:i="linear",scaleOptions:u})=>{const c=(typeof e=="number"?Math.floor(Math.abs((t-s)/e)):void 0)||n,l=(typeof e=="number"?M(s,t,e):a.tickStep(s,t,n))/2,r=h(a.nice(s,t,c),l),m=a.ticks(r[0],r[1],c),b=k[i](r,o,u);return[r,m,b]};exports.default=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("../../lib/utils.cjs"),a=require("d3-array"),b={linear:m.getLinearScale},d=(n,e,t)=>n>e?-Math.abs(t):Math.abs(t),M=(n,e)=>n.map((t,r)=>r===0?t-e:t+e),h=({min:n,max:e,step:t,ticks:r=5,range:o,scale:u="linear",scaleOptions:i})=>{const c=(typeof t=="number"?Math.floor(Math.abs((e-n)/t)):void 0)||r,l=(typeof t=="number"?d(n,e,t):a.tickStep(n,e,r))/2,s=M([n,e],l);return[s,a.ticks(n,e,c),b[u](s,o,i)]};exports.default=h;
@@ -14,5 +14,5 @@ type Axis = [Domain, Array<number>, ScaleFunction];
14
14
  * Creates an axis with ticks defined by a min, max, and desired step or number of ticks.
15
15
  * @returns [domain, ticks, scale]
16
16
  */
17
- declare const useAxis: ({ min: start, max: stop, step: configStep, ticks: configTicks, range: configRange, scale: configScale, scaleOptions, }: UseAxisProps) => Axis;
17
+ declare const useAxis: ({ min: start, max: stop, step: configStep, ticks: configTicks, range, scale, scaleOptions, }: UseAxisProps) => Axis;
18
18
  export default useAxis;
@@ -1,19 +1,23 @@
1
- import { getLinearScale as p } from "../../lib/utils.js";
2
- import { tickStep as k, nice as b, ticks as h } from "d3-array";
3
- const f = {
4
- linear: p
5
- }, M = (a, e, t) => a > e ? -Math.abs(t) : Math.abs(t), d = (a, e) => a.map((t, n) => n === 0 ? t - e : t + e), F = ({
6
- min: a,
7
- max: e,
8
- step: t,
9
- ticks: n = 5,
1
+ import { getLinearScale as u } from "../../lib/utils.js";
2
+ import { tickStep as l, ticks as p } from "d3-array";
3
+ const b = {
4
+ linear: u
5
+ }, h = (n, t, e) => n > t ? -Math.abs(e) : Math.abs(e), k = (n, t) => n.map((e, a) => a === 0 ? e - t : e + t), S = ({
6
+ min: n,
7
+ max: t,
8
+ step: e,
9
+ ticks: a = 5,
10
10
  range: r,
11
- scale: c = "linear",
12
- scaleOptions: i
11
+ scale: s = "linear",
12
+ scaleOptions: m
13
13
  }) => {
14
- const o = (typeof t == "number" ? Math.floor(Math.abs((e - a) / t)) : void 0) || n, m = (typeof t == "number" ? M(a, e, t) : k(a, e, n)) / 2, s = d(b(a, e, o), m), l = h(s[0], s[1], o), u = f[c](s, r, i);
15
- return [s, l, u];
14
+ const c = (typeof e == "number" ? Math.floor(Math.abs((t - n) / e)) : void 0) || a, i = (typeof e == "number" ? h(n, t, e) : l(n, t, a)) / 2, o = k([n, t], i);
15
+ return [
16
+ o,
17
+ p(n, t, c),
18
+ b[s](o, r, m)
19
+ ];
16
20
  };
17
21
  export {
18
- F as default
22
+ S as default
19
23
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -128,7 +128,7 @@
128
128
  "point_label_peak": "Apparent Magnitude: {{magnitude}} at peak",
129
129
  "point_label_after_one": "Apparent Magnitude: {{magnitude}} {{count}} day after peak",
130
130
  "point_label_after_other": "Apparent Magnitude: {{magnitude}} {{count}} days after peak",
131
- "tooltip": "Apparent Magnitude: {{magnitude}}"
131
+ "tooltip": "m: {{magnitude}}"
132
132
  }
133
133
  },
134
134
  "isochrone_plot": {
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),M=require("react-i18next"),y=require("d3-array"),k=require("../../../charts/ScatterPlot/index.cjs");require("../../../atomic/PlotWrapper/index.cjs");const x=require("../../../lib/utils.cjs"),u=require("../defaults.cjs"),v=require("./styles.cjs"),C=require("../../../atomic/PlotWrapper/styles.cjs"),E=(i,c,p)=>{const o={};return Object.keys(i).forEach(e=>{const a=e==="top"||e==="bottom"?p:c,n=`${e.charAt(0).toUpperCase()}${e.slice(1)}`;o[`padding${n}`]=`${i[e]/a*100}%`}),o},A=({data:i,activeAlertId:c,xMin:p,xMax:o,yMin:d,yMax:e,width:a=u.default.width,height:n=u.default.height,name:j,slider:g,className:q,plotChildren:h})=>{const{t:l,i18n:{language:W}}=M.useTranslation(),D=x.mergeWithDefaults({min:y.min(i,({x:t})=>t),max:y.max(i,({x:t})=>t)},u.default.xAxis),P=x.mergeWithDefaults({min:p,max:o,label:l("light_curve.plot.x_label")},{...D,label:l("isochrone_plot.plot.x_label")}),r=x.mergeWithDefaults({min:d,max:e,label:l("light_curve.plot.y_label")},{...u.default.yAxis,label:l("isochrone_plot.plot.y_label")}),b={top:10,right:10,bottom:25,left:40};return s.jsxs(C.PlotWrapper,{className:q,children:[s.jsx(k.default,{width:a,height:n,margins:b,activePointId:c,title:j,xAxis:{...P,ticks:6},yAxis:{...r,step:r.min<r.max?Math.abs(r.step):r.step},data:{label:l("light_curve.plot.plot_label"),points:i},tooltip:({y:t})=>l("light_curve.plot.tooltip",{magnitude:t.toLocaleString(W,{minimumFractionDigits:2,maximumFractionDigits:2})}),plotChildren:({xScale:t,yStart:f,yEnd:m,Data:_,...$})=>s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:t(0),y:m,width:t(15)-t(0),height:f-m,stroke:"var(--neutral60,##6A6E6E)",strokeDasharray:6,fill:"var(--neutral20,#DCE0E3)"}),_,h&&h({xScale:t,yStart:f,yEnd:m,Data:_,...$})]})}),g&&s.jsx(v.SliderOuterWrapper,{children:s.jsx(v.SliderInnerWrapper,{style:{...E(b,a,n)},children:g})})]})};A.displayName="Widgets.LightCurve.Plot";const F=A;exports.default=F;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),M=require("react-i18next"),y=require("d3-array"),C=require("../../../charts/ScatterPlot/index.cjs");require("../../../atomic/PlotWrapper/index.cjs");const x=require("../../../lib/utils.cjs"),u=require("../defaults.cjs"),v=require("./styles.cjs"),E=require("../../../atomic/PlotWrapper/styles.cjs"),F=(l,c,p)=>{const o={};return Object.keys(l).forEach(e=>{const a=e==="top"||e==="bottom"?p:c,n=`${e.charAt(0).toUpperCase()}${e.slice(1)}`;o[`padding${n}`]=`${l[e]/a*100}%`}),o},A=({data:l,activeAlertId:c,xMin:p,xMax:o,yMin:d,yMax:e,width:a=u.default.width,height:n=u.default.height,name:j,slider:g,className:q,plotChildren:h})=>{const{t:i,i18n:{language:W}}=M.useTranslation(),D=x.mergeWithDefaults({min:y.min(l,({x:t})=>t),max:y.max(l,({x:t})=>t)},u.default.xAxis),P=x.mergeWithDefaults({min:p,max:o,label:i("light_curve.plot.x_label")},{...D,label:i("isochrone_plot.plot.x_label")}),r=x.mergeWithDefaults({min:d,max:e,label:i("light_curve.plot.y_label")},{...u.default.yAxis,label:i("isochrone_plot.plot.y_label")}),b={top:10,right:10,bottom:25,left:40};return s.jsxs(E.PlotWrapper,{className:q,children:[s.jsx(C.default,{width:a,height:n,margins:b,activePointId:c,title:j,xAxis:{...P},yAxis:{...r,step:r.min<r.max?Math.abs(r.step):r.step},data:{label:i("light_curve.plot.plot_label"),points:l},tooltip:({y:t})=>i("light_curve.plot.tooltip",{magnitude:t.toLocaleString(W,{minimumFractionDigits:2,maximumFractionDigits:2})}),plotChildren:({xScale:t,yStart:f,yEnd:m,Data:_,...$})=>s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:t(0),y:m,width:t(15)-t(0),height:f-m,stroke:"var(--neutral60,##6A6E6E)",strokeDasharray:6,fill:"var(--neutral20,#DCE0E3)"}),_,h&&h({xScale:t,yStart:f,yEnd:m,Data:_,...$})]})}),g&&s.jsx(v.SliderOuterWrapper,{children:s.jsx(v.SliderInnerWrapper,{style:{...F(b,a,n)},children:g})})]})};A.displayName="Widgets.LightCurve.Plot";const I=A;exports.default=I;
@@ -1,21 +1,21 @@
1
1
  "use client";
2
- import { jsxs as A, jsx as n, Fragment as k } from "react/jsx-runtime";
3
- import { useTranslation as C } from "react-i18next";
4
- import { min as E, max as F } from "d3-array";
2
+ import { jsxs as A, jsx as n, Fragment as C } from "react/jsx-runtime";
3
+ import { useTranslation as E } from "react-i18next";
4
+ import { min as F, max as k } from "d3-array";
5
5
  import I from "../../../charts/ScatterPlot/index.js";
6
6
  import "../../../atomic/PlotWrapper/index.js";
7
7
  import { mergeWithDefaults as u } from "../../../lib/utils.js";
8
8
  import m from "../defaults.js";
9
9
  import { SliderOuterWrapper as L, SliderInnerWrapper as M } from "./styles.js";
10
10
  import { PlotWrapper as N } from "../../../atomic/PlotWrapper/styles.js";
11
- const O = (i, p, c) => {
11
+ const O = (e, p, c) => {
12
12
  const l = {};
13
- return Object.keys(i).forEach((o) => {
13
+ return Object.keys(e).forEach((o) => {
14
14
  const s = o === "top" || o === "bottom" ? c : p, a = `${o.charAt(0).toUpperCase()}${o.slice(1)}`;
15
- l[`padding${a}`] = `${i[o] / s * 100}%`;
15
+ l[`padding${a}`] = `${e[o] / s * 100}%`;
16
16
  }), l;
17
17
  }, v = ({
18
- data: i,
18
+ data: e,
19
19
  activeAlertId: p,
20
20
  xMin: c,
21
21
  xMax: l,
@@ -29,25 +29,25 @@ const O = (i, p, c) => {
29
29
  plotChildren: f
30
30
  }) => {
31
31
  const {
32
- t: e,
32
+ t: i,
33
33
  i18n: { language: W }
34
- } = C(), $ = u(
34
+ } = E(), $ = u(
35
35
  {
36
- min: E(i, ({ x: t }) => t),
37
- max: F(i, ({ x: t }) => t)
36
+ min: F(e, ({ x: t }) => t),
37
+ max: k(e, ({ x: t }) => t)
38
38
  },
39
39
  m.xAxis
40
40
  ), D = u(
41
- { min: c, max: l, label: e("light_curve.plot.x_label") },
41
+ { min: c, max: l, label: i("light_curve.plot.x_label") },
42
42
  {
43
43
  ...$,
44
- label: e("isochrone_plot.plot.x_label")
44
+ label: i("isochrone_plot.plot.x_label")
45
45
  }
46
46
  ), r = u(
47
- { min: x, max: o, label: e("light_curve.plot.y_label") },
47
+ { min: x, max: o, label: i("light_curve.plot.y_label") },
48
48
  {
49
49
  ...m.yAxis,
50
- label: e("isochrone_plot.plot.y_label")
50
+ label: i("isochrone_plot.plot.y_label")
51
51
  }
52
52
  ), b = {
53
53
  top: 10,
@@ -65,24 +65,23 @@ const O = (i, p, c) => {
65
65
  activePointId: p,
66
66
  title: y,
67
67
  xAxis: {
68
- ...D,
69
- ticks: 6
68
+ ...D
70
69
  },
71
70
  yAxis: {
72
71
  ...r,
73
72
  step: r.min < r.max ? Math.abs(r.step) : r.step
74
73
  },
75
74
  data: {
76
- label: e("light_curve.plot.plot_label"),
77
- points: i
75
+ label: i("light_curve.plot.plot_label"),
76
+ points: e
78
77
  },
79
- tooltip: ({ y: t }) => e("light_curve.plot.tooltip", {
78
+ tooltip: ({ y: t }) => i("light_curve.plot.tooltip", {
80
79
  magnitude: t.toLocaleString(W, {
81
80
  minimumFractionDigits: 2,
82
81
  maximumFractionDigits: 2
83
82
  })
84
83
  }),
85
- plotChildren: ({ xScale: t, yStart: d, yEnd: h, Data: _, ...j }) => /* @__PURE__ */ A(k, { children: [
84
+ plotChildren: ({ xScale: t, yStart: d, yEnd: h, Data: _, ...j }) => /* @__PURE__ */ A(C, { children: [
86
85
  /* @__PURE__ */ n(
87
86
  "rect",
88
87
  {
@@ -1,9 +1,9 @@
1
1
  import { FunctionComponent } from 'react';
2
- import { Alert } from '../../../types/astro';
2
+ import { BaseAlert } from '../../../types/astro';
3
3
  import { PlotProps } from '../Plot';
4
4
 
5
5
  export interface PlotWithoutCurveProps extends Omit<PlotProps, "data"> {
6
- alerts: Array<Alert>;
6
+ alerts: Array<BaseAlert>;
7
7
  peakMjd: number;
8
8
  }
9
9
  declare const PlotWithoutCurve: FunctionComponent<PlotWithoutCurveProps>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={xAxis:{min:-10,max:50,step:10},yAxis:{min:20,max:14,step:-.5},width:600,height:600,gaussianMin:-4,gaussianMax:4,gaussianStep:.01,gaussianWidth:-2,yOffsetMin:-50,yOffsetMax:50,yOffsetStep:.1,yOffset:-2},s=e;exports.default=s;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s={xAxis:{min:-10,max:50,ticks:6},yAxis:{min:20,max:14,step:-.5},width:600,height:600,gaussianMin:-4,gaussianMax:4,gaussianStep:.01,gaussianWidth:-2,yOffsetMin:-50,yOffsetMax:50,yOffsetStep:.1,yOffset:-2},e=s;exports.default=e;
@@ -2,7 +2,7 @@ declare const defaults: {
2
2
  xAxis: {
3
3
  min: number;
4
4
  max: number;
5
- step: number;
5
+ ticks: number;
6
6
  };
7
7
  yAxis: {
8
8
  min: number;
@@ -1,5 +1,5 @@
1
1
  const s = {
2
- xAxis: { min: -10, max: 50, step: 10 },
2
+ xAxis: { min: -10, max: 50, ticks: 6 },
3
3
  yAxis: { min: 20, max: 14, step: -0.5 },
4
4
  width: 600,
5
5
  height: 600,
@@ -1,8 +1,8 @@
1
- import { Alert } from '../../types/astro';
1
+ import { BaseAlert } from '../../types/astro';
2
2
  import { PlotPoint, Point } from '../../types/charts';
3
3
 
4
4
  export declare const daysSincePeak: (current: number, peak: number) => number;
5
- export declare const useAlertsAsPoints: (alerts: Array<Alert>, phaseCorrection: number) => Array<PlotPoint>;
5
+ export declare const useAlertsAsPoints: (alerts: Array<BaseAlert>, phaseCorrection: number) => Array<PlotPoint>;
6
6
  export declare const gaussianBump: (x: number, gaussianWidth: number) => number;
7
7
  export declare const exponentialRise: (x: number, magnitude: number) => number;
8
8
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubin-epo/epo-widget-lib",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "Rubin Observatory Education & Public Outreach team React scientific and educational widgets.",
5
5
  "author": "Rubin EPO",
6
6
  "license": "MIT",