@rubin-epo/epo-widget-lib 0.8.1 → 0.9.1

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.
Files changed (129) hide show
  1. package/dist/Charts.cjs +1 -1
  2. package/dist/Charts.js +12 -8
  3. package/dist/ColorTool.cjs +1 -1
  4. package/dist/ColorTool.js +62 -59
  5. package/dist/LightCurvePlot.cjs +1 -0
  6. package/dist/LightCurvePlot.d.ts +1 -0
  7. package/dist/LightCurvePlot.js +6 -0
  8. package/dist/SourceSelector.cjs +1 -1
  9. package/dist/SourceSelector.d.ts +2 -0
  10. package/dist/SourceSelector.js +8 -8
  11. package/dist/SupernovaThreeVector.js +4 -4
  12. package/dist/atomic/Button/patterns/Reset.js +9 -9
  13. package/dist/atomic/LiveRegion/index.cjs +1 -0
  14. package/dist/atomic/LiveRegion/index.d.ts +5 -0
  15. package/dist/atomic/LiveRegion/index.js +10 -0
  16. package/dist/charts/Base/index.cjs +1 -1
  17. package/dist/charts/Base/index.d.ts +3 -5
  18. package/dist/charts/Base/index.js +40 -24
  19. package/dist/charts/Base/styles.cjs +18 -7
  20. package/dist/charts/Base/styles.d.ts +272 -0
  21. package/dist/charts/Base/styles.js +18 -6
  22. package/dist/charts/ForeignObject/index.cjs +1 -0
  23. package/dist/charts/ForeignObject/index.d.ts +5 -0
  24. package/dist/charts/ForeignObject/index.js +18 -0
  25. package/dist/charts/Tooltip/index.cjs +1 -1
  26. package/dist/charts/Tooltip/index.d.ts +2 -2
  27. package/dist/charts/Tooltip/index.js +20 -22
  28. package/dist/charts/Tooltip/styles.cjs +5 -3
  29. package/dist/charts/Tooltip/styles.d.ts +7 -0
  30. package/dist/charts/Tooltip/styles.js +9 -5
  31. package/dist/charts/Viewport/index.cjs +1 -0
  32. package/dist/charts/Viewport/index.d.ts +11 -0
  33. package/dist/charts/Viewport/index.js +26 -0
  34. package/dist/charts/XAxis/index.cjs +1 -1
  35. package/dist/charts/XAxis/index.js +21 -21
  36. package/dist/charts/YAxis/index.cjs +1 -1
  37. package/dist/charts/YAxis/index.js +19 -19
  38. package/dist/charts/hooks/useAxis.cjs +1 -0
  39. package/dist/charts/hooks/useAxis.d.ts +16 -0
  40. package/dist/charts/hooks/useAxis.js +29 -0
  41. package/dist/charts/index.d.ts +2 -0
  42. package/dist/hooks/usePrevious.cjs +1 -0
  43. package/dist/hooks/usePrevious.d.ts +1 -0
  44. package/dist/hooks/usePrevious.js +11 -0
  45. package/dist/lib/helpers.d.ts +2 -0
  46. package/dist/lib/helpers.test.d.ts +1 -0
  47. package/dist/lib/utils.cjs +1 -1
  48. package/dist/lib/utils.d.ts +5 -1
  49. package/dist/lib/utils.js +17 -12
  50. package/dist/localeStrings/en/epo-widget-lib.json +30 -0
  51. package/dist/widgets/ColorTool/Actions/index.js +9 -9
  52. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.cjs +1 -1
  53. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.d.ts +3 -0
  54. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.js +42 -66
  55. package/dist/widgets/ColorTool/ImageComposite/styles.cjs +5 -7
  56. package/dist/widgets/ColorTool/ImageComposite/styles.js +9 -9
  57. package/dist/widgets/ColorTool/hooks/useFilteredImages.cjs +1 -0
  58. package/dist/widgets/ColorTool/hooks/useFilteredImages.d.ts +8 -0
  59. package/dist/widgets/ColorTool/hooks/useFilteredImages.js +33 -0
  60. package/dist/widgets/LightCurvePlot/A11Y/LightCurveLabel/index.cjs +1 -0
  61. package/dist/widgets/LightCurvePlot/A11Y/LightCurveLabel/index.d.ts +11 -0
  62. package/dist/widgets/LightCurvePlot/A11Y/LightCurveLabel/index.js +38 -0
  63. package/dist/widgets/LightCurvePlot/A11Y/LightCurveLabel/styles.cjs +9 -0
  64. package/dist/widgets/LightCurvePlot/A11Y/LightCurveLabel/styles.d.ts +275 -0
  65. package/dist/widgets/LightCurvePlot/A11Y/LightCurveLabel/styles.js +14 -0
  66. package/dist/widgets/LightCurvePlot/DM15Display/index.cjs +1 -0
  67. package/dist/widgets/LightCurvePlot/DM15Display/index.d.ts +15 -0
  68. package/dist/widgets/LightCurvePlot/DM15Display/index.js +40 -0
  69. package/dist/widgets/LightCurvePlot/DM15Display/styles.cjs +12 -0
  70. package/dist/widgets/{ColorTool/ImageComposite → LightCurvePlot/DM15Display}/styles.d.ts +2 -2
  71. package/dist/widgets/LightCurvePlot/DM15Display/styles.js +18 -0
  72. package/dist/widgets/LightCurvePlot/LightCurve/index.cjs +1 -0
  73. package/dist/widgets/LightCurvePlot/LightCurve/index.d.ts +12 -0
  74. package/dist/widgets/LightCurvePlot/LightCurve/index.js +29 -0
  75. package/dist/widgets/LightCurvePlot/MagnitudeSlider/index.cjs +1 -0
  76. package/dist/widgets/LightCurvePlot/MagnitudeSlider/index.d.ts +11 -0
  77. package/dist/widgets/LightCurvePlot/MagnitudeSlider/index.js +54 -0
  78. package/dist/widgets/LightCurvePlot/MagnitudeSlider/styles.cjs +42 -0
  79. package/dist/widgets/LightCurvePlot/MagnitudeSlider/styles.js +51 -0
  80. package/dist/widgets/LightCurvePlot/PlotWithCurve/index.cjs +1 -0
  81. package/dist/widgets/LightCurvePlot/PlotWithCurve/index.d.ts +13 -0
  82. package/dist/widgets/LightCurvePlot/PlotWithCurve/index.js +134 -0
  83. package/dist/widgets/LightCurvePlot/PlotWithCurve/styles.cjs +29 -0
  84. package/dist/widgets/LightCurvePlot/PlotWithCurve/styles.d.ts +1378 -0
  85. package/dist/widgets/LightCurvePlot/PlotWithCurve/styles.js +41 -0
  86. package/dist/widgets/LightCurvePlot/PlotWithoutCurve/index.cjs +1 -0
  87. package/dist/widgets/LightCurvePlot/PlotWithoutCurve/index.d.ts +9 -0
  88. package/dist/widgets/LightCurvePlot/PlotWithoutCurve/index.js +20 -0
  89. package/dist/widgets/LightCurvePlot/Point/index.cjs +1 -0
  90. package/dist/widgets/LightCurvePlot/Point/index.d.ts +11 -0
  91. package/dist/widgets/LightCurvePlot/Point/index.js +68 -0
  92. package/dist/widgets/LightCurvePlot/ScatterPlot/index.cjs +1 -0
  93. package/dist/widgets/LightCurvePlot/ScatterPlot/index.d.ts +11 -0
  94. package/dist/widgets/LightCurvePlot/ScatterPlot/index.js +158 -0
  95. package/dist/widgets/LightCurvePlot/ScatterPlot/styles.cjs +30 -0
  96. package/dist/widgets/LightCurvePlot/ScatterPlot/styles.d.ts +288 -0
  97. package/dist/widgets/LightCurvePlot/ScatterPlot/styles.js +38 -0
  98. package/dist/widgets/LightCurvePlot/defaults.cjs +1 -0
  99. package/dist/widgets/LightCurvePlot/defaults.d.ts +19 -0
  100. package/dist/widgets/LightCurvePlot/defaults.js +21 -0
  101. package/dist/widgets/LightCurvePlot/helpers.cjs +1 -0
  102. package/dist/widgets/LightCurvePlot/helpers.d.ts +23 -0
  103. package/dist/widgets/LightCurvePlot/helpers.js +23 -0
  104. package/dist/widgets/LightCurvePlot/helpers.test.d.ts +1 -0
  105. package/dist/widgets/LightCurvePlot/index.d.ts +2 -0
  106. package/dist/widgets/SourceSelector/SourceSelector.cjs +1 -1
  107. package/dist/widgets/SourceSelector/SourceSelector.d.ts +2 -2
  108. package/dist/widgets/SourceSelector/SourceSelector.js +28 -28
  109. package/dist/widgets/SourceSelector/index.d.ts +2 -1
  110. package/dist/widgets/SupernovaThreeVector/Histogram/index.cjs +1 -1
  111. package/dist/widgets/SupernovaThreeVector/Histogram/index.js +35 -35
  112. package/dist/widgets/SupernovaThreeVector/LiveLabel/index.cjs +1 -1
  113. package/dist/widgets/SupernovaThreeVector/LiveLabel/index.js +15 -15
  114. package/package.json +2 -1
  115. package/dist/hooks/useImage.cjs +0 -1
  116. package/dist/hooks/useImage.d.ts +0 -10
  117. package/dist/hooks/useImage.js +0 -31
  118. package/dist/widgets/ColorTool/CompositeRender/index.cjs +0 -1
  119. package/dist/widgets/ColorTool/CompositeRender/index.d.ts +0 -9
  120. package/dist/widgets/ColorTool/CompositeRender/index.js +0 -16
  121. package/dist/widgets/ColorTool/CompositeRender/styles.cjs +0 -3
  122. package/dist/widgets/ColorTool/CompositeRender/styles.d.ts +0 -274
  123. package/dist/widgets/ColorTool/CompositeRender/styles.js +0 -8
  124. package/dist/widgets/ColorTool/OffscreenFilter/index.cjs +0 -1
  125. package/dist/widgets/ColorTool/OffscreenFilter/index.d.ts +0 -15
  126. package/dist/widgets/ColorTool/OffscreenFilter/index.js +0 -27
  127. /package/dist/{widgets/SupernovaThreeVector/LiveLabel → atomic/LiveRegion}/styles.cjs +0 -0
  128. /package/dist/{widgets/SupernovaThreeVector/LiveLabel → atomic/LiveRegion}/styles.d.ts +0 -0
  129. /package/dist/{widgets/SupernovaThreeVector/LiveLabel → atomic/LiveRegion}/styles.js +0 -0
@@ -1,23 +1,23 @@
1
- import { jsxs as h, Fragment as A, jsx as s } from "react/jsx-runtime";
1
+ import { jsxs as p, Fragment as X, jsx as s } from "react/jsx-runtime";
2
2
  import { ticks as x } from "d3-array";
3
- import { BaseLine as M, Tick as j, XLabel as k } from "../styles.js";
4
- const p = ({
3
+ import { BaseLine as M, Tick as j, XLabel as F } from "../styles.js";
4
+ const u = ({
5
5
  xDomain: r = [0, 1],
6
- xScale: i = (a) => a,
6
+ xScale: i = (c) => c,
7
7
  y: t = 0,
8
- ticks: o = 0,
9
- labelRender: c,
10
- labelledById: u,
11
- margin: m,
8
+ ticks: n = 0,
9
+ labelRender: a,
10
+ labelledById: m,
11
+ margin: y,
12
12
  tickHeight: d = 5,
13
- showBaseline: b = !0,
14
- className: X
13
+ showBaseline: A = !0,
14
+ className: b
15
15
  }) => {
16
16
  if (r.length < 2)
17
17
  return console.error("Failed to render: invalid domain", r), null;
18
- const f = { ...{ top: 0, right: 0, bottom: 0, left: 0 }, ...m }, y = x(r[0], r[1], o);
19
- return /* @__PURE__ */ h(A, { children: [
20
- b && /* @__PURE__ */ s(
18
+ const f = { ...{ top: 0, right: 0, bottom: 0, left: 0 }, ...y }, g = Array.isArray(n) ? n : x(r[0], r[1], n);
19
+ return /* @__PURE__ */ p(X, { children: [
20
+ A && /* @__PURE__ */ s(
21
21
  M,
22
22
  {
23
23
  x1: i(r[0]) - f.left,
@@ -26,19 +26,19 @@ const p = ({
26
26
  y2: t
27
27
  }
28
28
  ),
29
- o > 0 && /* @__PURE__ */ s("g", { role: "list", "aria-labelledby": u, className: X, children: y.map((e, g) => {
29
+ g.length > 0 && /* @__PURE__ */ s("g", { role: "list", "aria-labelledby": m, className: b, children: g.map((e, h) => {
30
30
  if (e >= r[1])
31
31
  return null;
32
- const n = t + d, l = i(e);
33
- return /* @__PURE__ */ h("g", { role: "listitem", children: [
34
- d > 0 && /* @__PURE__ */ s(j, { x1: l, x2: l, y1: t, y2: n }),
35
- c ? c(e, l, n, g) : /* @__PURE__ */ s(k, { x: l, y: n, children: e })
36
- ] }, g);
32
+ const o = t + d, l = i(e);
33
+ return /* @__PURE__ */ p("g", { role: "listitem", children: [
34
+ d > 0 && /* @__PURE__ */ s(j, { x1: l, x2: l, y1: t, y2: o }),
35
+ a ? a(e, l, o, h) : /* @__PURE__ */ s(F, { x: l, y: o, children: e })
36
+ ] }, h);
37
37
  }) })
38
38
  ] });
39
39
  };
40
- p.displayName = "Charts.XAxis";
41
- const C = p;
40
+ u.displayName = "Charts.XAxis";
41
+ const C = u;
42
42
  export {
43
43
  C as default
44
44
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),M=require("d3-array"),o=require("../styles.cjs"),b=({yDomain:t=[0,1],yScale:l=u=>u,x:r=0,margin:j,ticks:a=0,labelRender:c,labelledById:f,showBaseline:h=!0,tickLength:d=5,className:p})=>{if(t.length<2)return console.error("Failed to render: invalid domain",t),null;const x={...{top:0,right:0,bottom:0,left:0},...j},A=M.ticks(t[0],t[1],a);return e.jsxs(e.Fragment,{children:[h&&e.jsx(o.BaseLine,{x1:r,x2:r,y1:l(t[0])+x.top,y2:l(t[1])-x.bottom}),a>0&&e.jsx("g",{role:"list","aria-labelledby":f,className:p,children:A.map((i,g)=>{const s=l(i),n=r-d;return e.jsxs("g",{role:"listitem",children:[d>0&&e.jsx(o.Tick,{x1:n,x2:r,y1:s,y2:s}),c?c(i,n,s,g):e.jsx(o.YLabel,{x:n,y:s,children:i})]},g)})})]})};b.displayName="Charts.YAxis";const Y=b;exports.default=Y;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),y=require("d3-array"),a=require("../styles.cjs"),j=({yDomain:r=[0,1],yScale:l=c=>c,x:t=0,margin:f,ticks:i=0,labelRender:d,labelledById:h,showBaseline:A=!0,tickLength:u=5,className:p})=>{if(r.length<2)return console.error("Failed to render: invalid domain",r),null;const x={...{top:0,right:0,bottom:0,left:0},...f},g=Array.isArray(i)?i:y.ticks(r[0],r[1],i);return e.jsxs(e.Fragment,{children:[A&&e.jsx(a.BaseLine,{x1:t,x2:t,y1:l(r[0])+x.top,y2:l(r[1])-x.bottom}),g.length>0&&e.jsx("g",{role:"list","aria-labelledby":h,className:p,children:g.map((n,b)=>{const s=l(n),o=t-u;return e.jsxs("g",{role:"listitem",children:[u>0&&e.jsx(a.Tick,{x1:o,x2:t,y1:s,y2:s}),d?d(n,o,s,b):e.jsx(a.YLabel,{x:o,y:s,children:n})]},b)})})]})};j.displayName="Charts.YAxis";const M=j;exports.default=M;
@@ -1,42 +1,42 @@
1
- import { jsxs as p, Fragment as A, jsx as e } from "react/jsx-runtime";
1
+ import { jsxs as p, Fragment as Y, jsx as s } from "react/jsx-runtime";
2
2
  import { ticks as M } from "d3-array";
3
- import { BaseLine as j, Tick as k, YLabel as F } from "../styles.js";
3
+ import { BaseLine as j, Tick as y, YLabel as F } from "../styles.js";
4
4
  const x = ({
5
5
  yDomain: r = [0, 1],
6
- yScale: i = (d) => d,
6
+ yScale: l = (c) => c,
7
7
  x: t = 0,
8
- margin: g,
9
- ticks: n = 0,
8
+ margin: h,
9
+ ticks: i = 0,
10
10
  labelRender: a,
11
11
  labelledById: b,
12
- showBaseline: h = !0,
13
- tickLength: c = 5,
14
- className: u
12
+ showBaseline: u = !0,
13
+ tickLength: d = 5,
14
+ className: A
15
15
  }) => {
16
16
  if (r.length < 2)
17
17
  return console.error("Failed to render: invalid domain", r), null;
18
- const f = { ...{ top: 0, right: 0, bottom: 0, left: 0 }, ...g }, Y = M(r[0], r[1], n);
19
- return /* @__PURE__ */ p(A, { children: [
20
- h && /* @__PURE__ */ e(
18
+ const f = { ...{ top: 0, right: 0, bottom: 0, left: 0 }, ...h }, g = Array.isArray(i) ? i : M(r[0], r[1], i);
19
+ return /* @__PURE__ */ p(Y, { children: [
20
+ u && /* @__PURE__ */ s(
21
21
  j,
22
22
  {
23
23
  x1: t,
24
24
  x2: t,
25
- y1: i(r[0]) + f.top,
26
- y2: i(r[1]) - f.bottom
25
+ y1: l(r[0]) + f.top,
26
+ y2: l(r[1]) - f.bottom
27
27
  }
28
28
  ),
29
- n > 0 && /* @__PURE__ */ e("g", { role: "list", "aria-labelledby": b, className: u, children: Y.map((l, m) => {
30
- const s = i(l), o = t - c;
29
+ g.length > 0 && /* @__PURE__ */ s("g", { role: "list", "aria-labelledby": b, className: A, children: g.map((o, m) => {
30
+ const e = l(o), n = t - d;
31
31
  return /* @__PURE__ */ p("g", { role: "listitem", children: [
32
- c > 0 && /* @__PURE__ */ e(k, { x1: o, x2: t, y1: s, y2: s }),
33
- a ? a(l, o, s, m) : /* @__PURE__ */ e(F, { x: o, y: s, children: l })
32
+ d > 0 && /* @__PURE__ */ s(y, { x1: n, x2: t, y1: e, y2: e }),
33
+ a ? a(o, n, e, m) : /* @__PURE__ */ s(F, { x: n, y: e, children: o })
34
34
  ] }, m);
35
35
  }) })
36
36
  ] });
37
37
  };
38
38
  x.displayName = "Charts.YAxis";
39
- const N = x;
39
+ const L = x;
40
40
  export {
41
- N as default
41
+ L as default
42
42
  };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react"),i=require("d3-array"),M=require("../../lib/utils.cjs"),g={linear:M.getLinearScale},b=({min:t,max:r,step:s,range:o,scale:u="linear",scaleOptions:l})=>{const n=c.useMemo(()=>Math.ceil((r-t+1)/10)*10/s,[t,r,s]),e=c.useMemo(()=>i.nice(t,r,n),[t,r,n]),a=i.range(e[0],e[1],s),d=c.useCallback(g[u](e,o,l),[e,o,u]);return[e,a,d]};exports.default=b;
@@ -0,0 +1,16 @@
1
+ import { Domain, Scale, ScaleFunction } from '../../charts/types';
2
+ interface UseAxisProps {
3
+ min: number;
4
+ max: number;
5
+ step: number;
6
+ scale?: Scale;
7
+ scaleOptions?: any;
8
+ range: Array<number>;
9
+ }
10
+ type Axis = [Domain, Array<number>, ScaleFunction];
11
+ /**
12
+ * Creates an axis with ticks defined by a min, max, and desired step.
13
+ * @returns [domain, ticks, scale]
14
+ */
15
+ declare const useAxis: ({ min, max, step, range: scaleRange, scale: scaleType, scaleOptions, }: UseAxisProps) => Axis;
16
+ export default useAxis;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { useMemo as i, useCallback as f } from "react";
3
+ import { nice as k, range as d } from "d3-array";
4
+ import { getLinearScale as g } from "../../lib/utils.js";
5
+ const m = {
6
+ linear: g
7
+ }, h = ({
8
+ min: t,
9
+ max: e,
10
+ step: c,
11
+ range: r,
12
+ scale: s = "linear",
13
+ scaleOptions: a
14
+ }) => {
15
+ const n = i(
16
+ () => Math.ceil((e - t + 1) / 10) * 10 / c,
17
+ [t, e, c]
18
+ ), o = i(
19
+ () => k(t, e, n),
20
+ [t, e, n]
21
+ ), l = d(o[0], o[1], c), u = f(
22
+ m[s](o, r, a),
23
+ [o, r, s]
24
+ );
25
+ return [o, l, u];
26
+ };
27
+ export {
28
+ h as default
29
+ };
@@ -6,3 +6,5 @@ export { default as Points } from "./Points";
6
6
  export { default as Tooltip } from "./Tooltip";
7
7
  export { default as ClippingContainer } from "./ClippingContainer";
8
8
  export { default as Bars } from "./Bars";
9
+ export { default as Viewport } from "./Viewport";
10
+ export { default as ForeignObject } from "./ForeignObject";
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react");function u(e){const t=r.useRef();return r.useEffect(()=>{t.current=e},[e]),t.current}exports.default=u;
@@ -0,0 +1 @@
1
+ export default function usePrevious<T = any>(value: T): T | undefined;
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { useRef as t, useEffect as u } from "react";
3
+ function n(e) {
4
+ const r = t();
5
+ return u(() => {
6
+ r.current = e;
7
+ }, [e]), r.current;
8
+ }
9
+ export {
10
+ n as default
11
+ };
@@ -0,0 +1,2 @@
1
+ export declare const timestampFromMJD: (mjd: number) => number;
2
+ export declare const mjdFromTimestamp: (timestamp: number, pre?: number) => number;
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(t,e)=>{switch(!0){case t>e:return 0;case t<0:return e;default:return t}},i=(t,e,r)=>t>=e&&t<=r,l=(t=[],e=[])=>{const r=t[0]<e[0]?t:e,n=r===t?e:t;return r[1]<n[0]?null:[n[0],r[1]<n[1]?r[1]:n[1]]},o=(t=[0,1],e=[0,1],r=!1)=>n=>{const s=t[1]-t[0];if(s===0)return(e[0]+e[1])/2;let c=(n-t[0])/s;return r&&(c=Math.min(Math.max(c,0),1)),c*(e[1]-e[0])+e[0]};exports.between=i;exports.getClampedArrayIndex=u;exports.getLinearScale=o;exports.intersection=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=(t,e)=>{switch(!0){case t>e:return 0;case t<0:return e;default:return t}},a=(t,e,r)=>t>=e&&t<=r,f=(t=[],e=[])=>{const r=t[0]<e[0]?t:e,n=r===t?e:t;return r[1]<n[0]?null:[n[0],r[1]<n[1]?r[1]:n[1]]},m=(t=[0,1],e=[0,1],r)=>{const n={clamp:!1,fractionDigits:2},{clamp:i,fractionDigits:o}={...n,...r};return u=>{const s=t[1]-t[0];if(s===0)return(e[0]+e[1])/2;let c=(u-t[0])/s;return i&&(c=Math.min(Math.max(c,0),1)),Number((c*(e[1]-e[0])+e[0]).toFixed(o))}};exports.between=a;exports.getClampedArrayIndex=l;exports.getLinearScale=m;exports.intersection=f;
@@ -20,4 +20,8 @@ export declare const intersection: (a?: number[], b?: number[]) => number[] | nu
20
20
  * @param clamp should values outside the domain be clamped to the range
21
21
  * @returns (domainValue: number) => rangeValue: number
22
22
  */
23
- export declare const getLinearScale: (domain?: number[], range?: number[], clamp?: boolean) => (domainValue: number) => number;
23
+ export declare const getLinearScale: (domain?: number[], range?: number[], options?: {
24
+ clamp?: boolean;
25
+ fractionDigits?: number;
26
+ }) => (domainValue: number) => number;
27
+ export declare const precision: (number: number, precision: number) => number;
package/dist/lib/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- const u = (t, e) => {
1
+ const l = (t, e) => {
2
2
  switch (!0) {
3
3
  case t > e:
4
4
  return 0;
@@ -7,19 +7,24 @@ const u = (t, e) => {
7
7
  default:
8
8
  return t;
9
9
  }
10
- }, o = (t, e, r) => t >= e && t <= r, l = (t = [], e = []) => {
10
+ }, f = (t, e, r) => t >= e && t <= r, a = (t = [], e = []) => {
11
11
  const r = t[0] < e[0] ? t : e, n = r === t ? e : t;
12
12
  return r[1] < n[0] ? null : [n[0], r[1] < n[1] ? r[1] : n[1]];
13
- }, f = (t = [0, 1], e = [0, 1], r = !1) => (n) => {
14
- const s = t[1] - t[0];
15
- if (s === 0)
16
- return (e[0] + e[1]) / 2;
17
- let c = (n - t[0]) / s;
18
- return r && (c = Math.min(Math.max(c, 0), 1)), c * (e[1] - e[0]) + e[0];
13
+ }, m = (t = [0, 1], e = [0, 1], r) => {
14
+ const n = { clamp: !1, fractionDigits: 2 }, { clamp: u, fractionDigits: i } = { ...n, ...r };
15
+ return (o) => {
16
+ const s = t[1] - t[0];
17
+ if (s === 0)
18
+ return (e[0] + e[1]) / 2;
19
+ let c = (o - t[0]) / s;
20
+ return u && (c = Math.min(Math.max(c, 0), 1)), Number(
21
+ (c * (e[1] - e[0]) + e[0]).toFixed(i)
22
+ );
23
+ };
19
24
  };
20
25
  export {
21
- o as between,
22
- u as getClampedArrayIndex,
23
- f as getLinearScale,
24
- l as intersection
26
+ f as between,
27
+ l as getClampedArrayIndex,
28
+ m as getLinearScale,
29
+ a as intersection
25
30
  };
@@ -100,5 +100,35 @@
100
100
  "user_supernova_count_one": "{{count}} of your supernovae is visible near {{coords}}.",
101
101
  "user_supernova_count_other": "{{count}} of your supernovae are visible near {{coords}}."
102
102
  }
103
+ },
104
+ "light_curve": {
105
+ "deltaM15": {
106
+ "label": "Delta m 15:"
107
+ },
108
+ "curve": {
109
+ "controls": {
110
+ "gaussian_width": "Gaussian Width",
111
+ "y_offset": "Y Offset"
112
+ },
113
+ "description_above": "Mean distance from observations is {{residual}}, your peak is above the brightest measurement of {{brightest}}",
114
+ "description_below": "Mean distance from observations is {{residual}}, your peak is below the brightest measurement of {{brightest}}"
115
+ },
116
+ "magnitude_slider": {
117
+ "label": "Estimate the apparent magnitude",
118
+ "value_above": "Apparent magnitude is {{magnitude}}, {{distance}} higher than the peak of the light curve.",
119
+ "value_below": "Apparent magnitude is {{magnitude}}, {{distance}} lower than the peak of the light curve.",
120
+ "value_equal": "Apparent magnitude is {{magnitude}}, equal to the peak of the light curve."
121
+ },
122
+ "plot": {
123
+ "x_label": "Days",
124
+ "y_label": "Apparent Magnitude (m)",
125
+ "plot_label": "Supernovae magnitude before and after peak magnitude",
126
+ "point_label_before_one": "Apparent Magnitude: {{magnitude}} {{count}} day before peak",
127
+ "point_label_before_other": "Apparent Magnitude: {{magnitude}} {{count}} days before peak",
128
+ "point_label_peak": "Apparent Magnitude: {{magnitude}} at peak",
129
+ "point_label_after_one": "Apparent Magnitude: {{magnitude}} {{count}} day after peak",
130
+ "point_label_after_other": "Apparent Magnitude: {{magnitude}} {{count}} days after peak",
131
+ "tooltip": "Apparent Magnitude: {{magnitude}}"
132
+ }
103
133
  }
104
134
  }
@@ -6,22 +6,22 @@ import d from "./Export/index.js";
6
6
  import { Actions as A } from "./styles.js";
7
7
  import { areActionsActive as x, getBrightnessValue as h } from "../lib/utils.js";
8
8
  const b = (r) => r.map((s) => {
9
- const { defaultValue: t, min: o, max: n } = s, e = t || 1;
9
+ const { defaultValue: t, min: e, max: n } = s, o = t || 1;
10
10
  return {
11
11
  ...s,
12
12
  active: !1,
13
13
  color: "",
14
- brightness: h(o, n, e),
15
- value: e
14
+ brightness: h(e, n, o),
15
+ value: o
16
16
  };
17
17
  }), c = ({
18
18
  actions: r,
19
19
  isDisabled: s,
20
20
  selectedData: t,
21
- selectionCallback: o,
21
+ selectionCallback: e,
22
22
  canvas: n
23
23
  }) => {
24
- const { t: e } = p(), { name: m, filters: u } = t, a = s || !x(t);
24
+ const { t: o } = p(), { name: m, filters: u } = t, a = s || !x(t);
25
25
  return /* @__PURE__ */ l(A, { children: r.map((i) => {
26
26
  switch (i) {
27
27
  case "reset":
@@ -29,7 +29,7 @@ const b = (r) => r.map((s) => {
29
29
  f,
30
30
  {
31
31
  isDisabled: a,
32
- onResetCallback: () => o && o({
32
+ onResetCallback: () => e && e({
33
33
  ...t,
34
34
  filters: b(u)
35
35
  })
@@ -43,7 +43,7 @@ const b = (r) => r.map((s) => {
43
43
  isDisabled: a,
44
44
  canvas: n,
45
45
  filename: m,
46
- children: e("colorTool.actions.export")
46
+ children: o("colorTool.actions.export")
47
47
  },
48
48
  i
49
49
  );
@@ -55,7 +55,7 @@ const b = (r) => r.map((s) => {
55
55
  }) });
56
56
  };
57
57
  c.displayName = "Widgets.ColorTool.Actions";
58
- const $ = c;
58
+ const j = c;
59
59
  export {
60
- $ as default
60
+ j as default
61
61
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),o=require("react"),k=require("@rubin-epo/epo-react-lib/CircularLoader"),A=require("../OffscreenFilter/index.cjs"),m=require("./styles.cjs"),F=require("../lib/utils.cjs"),M=require("../CompositeRender/index.cjs"),R=e=>e&&e.__esModule?e:{default:e},D=R(k),C=o.forwardRef(({filters:e,width:i=600,height:l=600,selectedObjectName:r,className:p,children:y},b)=>{const c=o.useRef([]),[f,x]=o.useState(r),[a,u]=o.useState(0),d=F.isFilterActive(e),L=e.filter(t=>!t.isDisabled).length,g=a<L;r!==f&&(x(r),u(0));const j=o.useCallback(()=>u(t=>t+1),[a,e]),q=(t,n)=>{c.current[t]=n};return s.jsxs(m.ImageContainer,{className:p,style:{"--image-container-opacity":a&&d?1:.1},children:[!a&&d&&s.jsx(D.default,{isVisible:g}),s.jsxs(m.LoadingContainer,{style:{"--loading-opacity":g?0:1},children:[e&&e.map((t,n)=>{const{label:_,image:v,color:I,brightness:h}=t;return s.jsx(A.default,{onChangeCallback:S=>q(n,S),url:v,color:I,width:i,height:l,filters:{brightness:h,contrast:1.3},onLoadCallback:j},_)}),s.jsx(M.default,{layers:c.current,renderLayers:e.map(({active:t})=>t),width:i,height:l,ref:b})]}),y]})});C.displayName="Widgets.ColorTool.ImageComposite";const P=C;exports.default=P;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),m=require("react"),I=require("../lib/utils.cjs"),j=require("../hooks/useFilteredImages.cjs"),R=require("../lib/canvas.cjs"),r=require("./styles.cjs"),g=m.forwardRef(({filters:c,width:e=600,height:s=600,selectedObjectName:i,className:d,children:p,isDisplayOnly:v,images:x},o)=>{var u;const[y,C]=m.useState(i),l=I.isFilterActive(c);i!==y&&C(i);const[q,t]=j.default({images:x,filters:c}),n=(u=o==null?void 0:o.current)==null?void 0:u.getContext("2d");return n&&(n.clearRect(0,0,e,s),R.mergeCanvases(n,q,e,s)),a.jsxs(r.ImageContainer,{style:{aspectRatio:`${e} / ${s}`,maxWidth:v?`${e}px`:void 0,"--image-container-opacity":!t&&l?1:.1},className:d,children:[t&&l&&a.jsx(r.Loader,{isVisible:t}),a.jsx(r.Image,{style:{"--loading-opacity":t?0:1},ref:o,role:"img",hidden:t,width:e,height:s}),p]})});g.displayName="Widgets.ColorTool.ImageComposite";const $=g;exports.default=$;
@@ -1,10 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { ImageFilter } from "../ColorTool";
3
+ import { ImageShape } from "@rubin-epo/epo-react-lib/Image";
3
4
  interface ImageCompositeProps {
4
5
  filters: ImageFilter[];
6
+ images: Array<ImageShape>;
5
7
  width: number;
6
8
  height: number;
7
9
  selectedObjectName: string;
10
+ isDisplayOnly?: boolean;
8
11
  className?: string;
9
12
  }
10
13
  declare const ImageComposite: import("react").ForwardRefExoticComponent<ImageCompositeProps & {
@@ -1,82 +1,58 @@
1
1
  "use client";
2
- import { jsxs as d, jsx as n } from "react/jsx-runtime";
3
- import { forwardRef as j, useRef as D, useState as g, useCallback as O } from "react";
4
- import P from "@rubin-epo/epo-react-lib/CircularLoader";
5
- import S from "../OffscreenFilter/index.js";
6
- import { ImageContainer as T, LoadingContainer as V } from "./styles.js";
7
- import { isFilterActive as W } from "../lib/utils.js";
8
- import $ from "../CompositeRender/index.js";
9
- const C = j(
2
+ import { jsxs as y, jsx as c } from "react/jsx-runtime";
3
+ import { forwardRef as I, useState as f } from "react";
4
+ import { isFilterActive as $ } from "../lib/utils.js";
5
+ import A from "../hooks/useFilteredImages.js";
6
+ import { mergeCanvases as R } from "../lib/canvas.js";
7
+ import { ImageContainer as j, Loader as F, Image as W } from "./styles.js";
8
+ const p = I(
10
9
  ({
11
- filters: o,
12
- width: s = 600,
13
- height: i = 600,
14
- selectedObjectName: t,
15
- className: f,
16
- children: u
17
- }, y) => {
18
- const l = D([]), [b, L] = g(t), [r, m] = g(0), c = W(o), I = o.filter((e) => !e.isDisabled).length, p = r < I;
19
- t !== b && (L(t), m(0));
20
- const h = O(
21
- () => m((e) => e + 1),
22
- [r, o]
23
- ), v = (e, a) => {
24
- l.current[e] = a;
25
- };
26
- return /* @__PURE__ */ d(
27
- T,
10
+ filters: r,
11
+ width: o = 600,
12
+ height: e = 600,
13
+ selectedObjectName: s,
14
+ className: l,
15
+ children: g,
16
+ isDisplayOnly: d,
17
+ images: x
18
+ }, i) => {
19
+ var n;
20
+ const [C, u] = f(s), a = $(r);
21
+ s !== C && u(s);
22
+ const [v, t] = A({
23
+ images: x,
24
+ filters: r
25
+ }), m = (n = i == null ? void 0 : i.current) == null ? void 0 : n.getContext("2d");
26
+ return m && (m.clearRect(0, 0, o, e), R(m, v, o, e)), /* @__PURE__ */ y(
27
+ j,
28
28
  {
29
- className: f,
30
29
  style: {
31
- "--image-container-opacity": r && c ? 1 : 0.1
30
+ aspectRatio: `${o} / ${e}`,
31
+ maxWidth: d ? `${o}px` : void 0,
32
+ "--image-container-opacity": !t && a ? 1 : 0.1
32
33
  },
34
+ className: l,
33
35
  children: [
34
- !r && c && /* @__PURE__ */ n(P, { isVisible: p }),
35
- /* @__PURE__ */ d(
36
- V,
36
+ t && a && /* @__PURE__ */ c(F, { isVisible: t }),
37
+ /* @__PURE__ */ c(
38
+ W,
37
39
  {
38
- style: { "--loading-opacity": p ? 0 : 1 },
39
- children: [
40
- o && o.map((e, a) => {
41
- const { label: F, image: k, color: x, brightness: A } = e;
42
- return /* @__PURE__ */ n(
43
- S,
44
- {
45
- onChangeCallback: (R) => v(a, R),
46
- url: k,
47
- color: x,
48
- width: s,
49
- height: i,
50
- filters: {
51
- brightness: A,
52
- contrast: 1.3
53
- },
54
- onLoadCallback: h
55
- },
56
- F
57
- );
58
- }),
59
- /* @__PURE__ */ n(
60
- $,
61
- {
62
- layers: l.current,
63
- renderLayers: o.map(({ active: e }) => e),
64
- width: s,
65
- height: i,
66
- ref: y
67
- }
68
- )
69
- ]
40
+ style: { "--loading-opacity": t ? 0 : 1 },
41
+ ref: i,
42
+ role: "img",
43
+ hidden: t,
44
+ width: o,
45
+ height: e
70
46
  }
71
47
  ),
72
- u
48
+ g
73
49
  ]
74
50
  }
75
51
  );
76
52
  }
77
53
  );
78
- C.displayName = "Widgets.ColorTool.ImageComposite";
79
- const J = C;
54
+ p.displayName = "Widgets.ColorTool.ImageComposite";
55
+ const V = p;
80
56
  export {
81
- J as default
57
+ V as default
82
58
  };
@@ -1,18 +1,16 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("styled-components"),i=t=>t&&t.__esModule?t:{default:t},e=i(a),o=e.default.div`
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("styled-components"),i=require("@rubin-epo/epo-react-lib/CircularLoader"),t=e=>e&&e.__esModule?e:{default:e},a=t(o),r=t(i),n=a.default.div`
2
2
  display: flex;
3
3
  justify-content: center;
4
4
  align-items: center;
5
5
  position: relative;
6
- aspect-ratio: 1 / 1;
7
6
  grid-area: image;
8
7
  background-color: rgba(0, 0, 0, var(--image-container-opacity, 0.1));
9
8
  transition: background-color ease var(--DURATION, 0.2s);
10
- `,n=e.default.div`
11
9
  width: 100%;
12
- height: 100%;
10
+ `,s=a.default.canvas`
13
11
  opacity: var(--loading-opacity, 0);
14
12
  transition: opacity ease var(--DURATION_SLOW, 0.4s);
13
+ width: 100%;
14
+ `,c=a.default(r.default)`
15
15
  position: absolute;
16
- top: 0;
17
- left: 0;
18
- `;exports.ImageContainer=o;exports.LoadingContainer=n;
16
+ `;exports.Image=s;exports.ImageContainer=n;exports.Loader=c;
@@ -1,24 +1,24 @@
1
1
  "use client";
2
- import t from "styled-components";
3
- const a = t.div`
2
+ import a from "styled-components";
3
+ import o from "@rubin-epo/epo-react-lib/CircularLoader";
4
+ const e = a.div`
4
5
  display: flex;
5
6
  justify-content: center;
6
7
  align-items: center;
7
8
  position: relative;
8
- aspect-ratio: 1 / 1;
9
9
  grid-area: image;
10
10
  background-color: rgba(0, 0, 0, var(--image-container-opacity, 0.1));
11
11
  transition: background-color ease var(--DURATION, 0.2s);
12
- `, o = t.div`
13
12
  width: 100%;
14
- height: 100%;
13
+ `, r = a.canvas`
15
14
  opacity: var(--loading-opacity, 0);
16
15
  transition: opacity ease var(--DURATION_SLOW, 0.4s);
16
+ width: 100%;
17
+ `, n = a(o)`
17
18
  position: absolute;
18
- top: 0;
19
- left: 0;
20
19
  `;
21
20
  export {
22
- a as ImageContainer,
23
- o as LoadingContainer
21
+ r as Image,
22
+ e as ImageContainer,
23
+ n as Loader
24
24
  };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react"),_=require("lodash/isEqual"),q=require("../../../hooks/usePrevious.cjs"),f=require("../lib/canvas.cjs"),w=t=>t&&t.__esModule?t:{default:t},S=w(_),b=({images:t,filters:i})=>{const g=q.default(t),[v,d]=l.useState(0),[n,m]=l.useState(),I=n==null?void 0:n.some(({complete:s})=>!s),u=v!==t.length&&I;return l.useLayoutEffect(()=>{S.default(g,t)||(d(0),m(t.map(({url:s,width:o,height:c})=>{const e=new Image(o,c);return e.onload=()=>{d(a=>a+1)},e.src=s,e})))},[t]),u?[[],!!u]:[[...n||[]].map((s,o)=>{if(!i[o].active)return;const c=document.createElement("canvas"),e=c.getContext("2d");if(e){const{width:a,height:r}=s,{color:h="transparent",brightness:p}=i[o];e.canvas.width=a,e.canvas.height=r,e.clearRect(0,0,a,r),e.filter=f.getFilters({brightness:p,contrast:1.3}),e.drawImage(s,0,0,a,r),f.updateColor(e,h,a,r)}return c}).filter(s=>!!s),!!u]},y=b;exports.default=y;
@@ -0,0 +1,8 @@
1
+ import { ImageShape } from "@rubin-epo/epo-react-lib/Image";
2
+ import { ImageFilter } from "../ColorTool";
3
+ interface useFilteredImagesProps {
4
+ images: Array<ImageShape>;
5
+ filters: Array<ImageFilter>;
6
+ }
7
+ declare const useFilteredImages: ({ images, filters, }: useFilteredImagesProps) => [Array<HTMLCanvasElement>, boolean];
8
+ export default useFilteredImages;
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { useState as d, useLayoutEffect as h } from "react";
3
+ import w from "lodash/isEqual";
4
+ import x from "../../../hooks/usePrevious.js";
5
+ import { getFilters as F, updateColor as L } from "../lib/canvas.js";
6
+ const y = ({
7
+ images: s,
8
+ filters: u
9
+ }) => {
10
+ const l = x(s), [f, m] = d(0), [a, g] = d(), p = a == null ? void 0 : a.some(({ complete: e }) => !e), i = f !== s.length && p;
11
+ return h(() => {
12
+ w(l, s) || (m(0), g(
13
+ s.map(({ url: e, width: n, height: r }) => {
14
+ const t = new Image(n, r);
15
+ return t.onload = () => {
16
+ m((o) => o + 1);
17
+ }, t.src = e, t;
18
+ })
19
+ ));
20
+ }, [s]), i ? [[], !!i] : [[...a || []].map((e, n) => {
21
+ if (!u[n].active)
22
+ return;
23
+ const r = document.createElement("canvas"), t = r.getContext("2d");
24
+ if (t) {
25
+ const { width: o, height: c } = e, { color: v = "transparent", brightness: I } = u[n];
26
+ t.canvas.width = o, t.canvas.height = c, t.clearRect(0, 0, o, c), t.filter = F({ brightness: I, contrast: 1.3 }), t.drawImage(e, 0, 0, o, c), L(t, v, o, c);
27
+ }
28
+ return r;
29
+ }).filter((e) => !!e), !!i];
30
+ }, R = y;
31
+ export {
32
+ R as default
33
+ };