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