@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.
@@ -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:M=!1,isLoading:$,xAxis:k,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=!$&&!O,S={top:0,right:0,bottom:20,left:20},{width:g,height:f}=r.default,{ages:_={}}=T,i=Object.keys(_).sort((s,l)=>parseFloat(s)-parseFloat(l)).map(parseFloat),V=u.mergeWithDefaults(k,{...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:i.length>0?Math.min(...i):0,max:i.length>0?Math.max(...i):0,step:ue.default(i[1]-i[0],1)||.5},distance:{min:0,max:b.min+1,step:.05}},R={age:i.length>0?u.middle(i):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:s=>W.ageToGyrs(s).toLocaleString(h,{minimumFractionDigits:3,maximumFractionDigits:3}),distance:s=>W.distanceToLyrs(s).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(s=>({...s,radius:w,stroke:"rgba(18,114,108,0.5)",fill:"rgba(18,114,108,0.25)"}))},plotChildren:({Data:s,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:[s,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:M,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,176 +1,183 @@
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, o = Object.keys(F).sort(
35
- (t, m) => parseFloat(t) - 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: o.length > 0 ? Math.min(...o) : 0,
45
- max: o.length > 0 ? Math.max(...o) : 0,
46
- step: tt(o[1] - o[0], 1) || 0.5
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: R.min + 1, step: 0.05 }
49
- }, A = {
50
- age: o.length > 0 ? nt(o) : 0,
51
- distance: (n.distance.max - n.distance.min) / 2 + n.distance.min
52
- }, { age: a, distance: u } = h(
53
- B,
54
- A
55
- ), w = dt(z), g = {
56
- age: (t) => lt(t).toLocaleString(x, {
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: (t) => ct(t).toLocaleString(x, {
67
+ distance: (o) => lt(o).toLocaleString(v, {
61
68
  maximumFractionDigits: 0
62
69
  })
63
- }, L = {
64
- age: g.age(a),
65
- distance: g.distance(u)
66
- }, G = /* @__PURE__ */ e(pt, { ref: j, children: /* @__PURE__ */ e(
67
- 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,
68
75
  {
69
76
  renderer: "canvas",
70
- title: K,
71
- onLoadedCallback: () => H(!1),
77
+ title: f,
78
+ onLoadedCallback: () => M(!1),
72
79
  data: {
73
80
  label: "Star Cluster",
74
- points: r.map((t) => ({
75
- ...t,
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: t,
83
- xScale: m,
84
- yScale: f,
85
- yStart: O,
86
- yEnd: P,
87
- xStart: _,
88
- xEnd: S,
89
- yDomain: N
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 v = (F[a.toFixed(1)] || []).map(({ x: $, y: q }) => ({ x: m($), y: f(q) })) || [], y = f(u + N[1]);
92
- return /* @__PURE__ */ J(Q, { children: [
93
- t,
94
- a && /* @__PURE__ */ e(
95
- st,
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: v,
104
+ points: T,
98
105
  svgProps: {
99
106
  strokeWidth: 2,
100
- transform: `translate(0,${y})`
107
+ transform: `translate(0,${K})`
101
108
  }
102
109
  }
103
110
  ),
104
- s && /* @__PURE__ */ e(
105
- rt,
111
+ m && /* @__PURE__ */ e(
112
+ et,
106
113
  {
107
114
  viewport: {
108
- x: _,
109
- y: P,
110
- outerHeight: O - P,
111
- outerWidth: S - _,
112
- innerWidth: p,
113
- innerHeight: d
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: b,
123
+ forIds: P,
117
124
  forScreenreaders: /* @__PURE__ */ e(
118
- mt,
125
+ nt,
119
126
  {
120
- points: r,
121
- value: L,
122
- isochrone: v,
123
- offset: y,
124
- xScale: m,
125
- yScale: f,
126
- width: p,
127
- 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
128
135
  }
129
136
  ),
130
- children: c("isochrone_plot.output", {
131
- ...L
137
+ children: x("isochrone_plot.output", {
138
+ ...B
132
139
  })
133
140
  }
134
141
  )
135
142
  ] });
136
143
  },
137
- width: p,
138
- height: d,
144
+ width: b,
145
+ height: y,
139
146
  xAxis: V,
140
- yAxis: R,
141
- margins: M
147
+ yAxis: W,
148
+ margins: O
142
149
  }
143
150
  ) });
144
151
  return /* @__PURE__ */ e(
145
- ot,
152
+ Z,
146
153
  {
147
154
  ratio: { portrait: 2 / 3, landscape: 3 / 2 },
148
155
  widget: G,
149
156
  controls: /* @__PURE__ */ e(
150
- at,
157
+ st,
151
158
  {
152
- isDisabled: !s,
153
- value: { age: a, distance: u },
154
- localizers: g,
155
- configs: n,
156
- onChangeCallback: l
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
- it,
167
+ ot,
161
168
  {
162
- isDisabled: !s,
169
+ isDisabled: !m,
163
170
  onResetCallback: () => {
164
- l && l(A);
171
+ h && h(k);
165
172
  }
166
173
  }
167
174
  ),
168
- isLoading: !s,
169
- isDisplayOnly: I,
170
- controlsId: b
175
+ isLoading: !m,
176
+ isDisplayOnly: i,
177
+ controlsId: P
171
178
  }
172
179
  );
173
180
  };
174
181
  export {
175
- kt as default
182
+ Dt as default
176
183
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubin-epo/epo-widget-lib",
3
- "version": "1.0.6",
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",