@rubin-epo/epo-widget-lib 0.5.1-alpha.1 → 0.6.0

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 (108) hide show
  1. package/dist/CameraFilter.d.ts +3 -0
  2. package/dist/ColorTool.cjs +1 -1
  3. package/dist/ColorTool.d.ts +3 -0
  4. package/dist/ColorTool.js +115 -79
  5. package/dist/FilterTool.d.ts +3 -0
  6. package/dist/SourceSelector.d.ts +3 -0
  7. package/dist/{types/cjs/atomic/PlaybackControl/styles.d.cts → atomic/PlaybackControl/styles.d.ts} +1 -1
  8. package/dist/hooks/useImage.cjs +1 -0
  9. package/dist/hooks/useImage.d.ts +10 -0
  10. package/dist/hooks/useImage.js +30 -0
  11. package/dist/lib/reimg.cjs +1 -0
  12. package/dist/lib/reimg.d.ts +7 -0
  13. package/dist/lib/reimg.js +60 -0
  14. package/dist/widgets/ColorTool/Actions/Export/index.cjs +1 -0
  15. package/dist/widgets/ColorTool/Actions/Export/index.d.ts +12 -0
  16. package/dist/widgets/ColorTool/Actions/Export/index.js +36 -0
  17. package/dist/widgets/ColorTool/Actions/Reset/index.cjs +1 -0
  18. package/dist/widgets/ColorTool/Actions/Reset/index.d.ts +9 -0
  19. package/dist/widgets/ColorTool/Actions/Reset/index.js +39 -0
  20. package/dist/widgets/ColorTool/Actions/index.cjs +1 -0
  21. package/dist/widgets/ColorTool/Actions/index.d.ts +13 -0
  22. package/dist/widgets/ColorTool/Actions/index.js +55 -0
  23. package/dist/widgets/ColorTool/Actions/styles.cjs +5 -0
  24. package/dist/widgets/ColorTool/Actions/styles.d.ts +272 -0
  25. package/dist/widgets/ColorTool/Actions/styles.js +9 -0
  26. package/dist/{types/cjs/widgets/ColorTool/ColorTool.d.cts → widgets/ColorTool/ColorTool.d.ts} +11 -5
  27. package/dist/widgets/ColorTool/FilterControls/FilterControls.cjs +1 -1
  28. package/dist/widgets/ColorTool/FilterControls/FilterControls.js +43 -41
  29. package/dist/widgets/ColorTool/FilterControls/styles.cjs +58 -0
  30. package/dist/widgets/ColorTool/FilterControls/styles.d.ts +956 -0
  31. package/dist/widgets/ColorTool/FilterControls/styles.js +67 -0
  32. package/dist/widgets/ColorTool/FilterImage/FilterImage.cjs +1 -1
  33. package/dist/widgets/ColorTool/FilterImage/FilterImage.d.ts +16 -0
  34. package/dist/widgets/ColorTool/FilterImage/FilterImage.js +40 -31
  35. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.cjs +1 -1
  36. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.d.ts +12 -0
  37. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.js +54 -29
  38. package/dist/widgets/ColorTool/ImageComposite/styles.cjs +19 -0
  39. package/dist/widgets/ColorTool/ImageComposite/styles.d.ts +544 -0
  40. package/dist/widgets/ColorTool/ImageComposite/styles.js +24 -0
  41. package/dist/widgets/ColorTool/styles.cjs +21 -77
  42. package/dist/{types/cjs/widgets/ColorTool/styles.d.cts → widgets/ColorTool/styles.d.ts} +276 -1207
  43. package/dist/widgets/ColorTool/styles.js +29 -96
  44. package/dist/widgets/ColorTool/utilities.cjs +1 -1
  45. package/dist/{types/cjs/widgets/ColorTool/utilities.d.cts → widgets/ColorTool/utilities.d.ts} +3 -2
  46. package/dist/widgets/ColorTool/utilities.js +30 -29
  47. package/package.json +7 -43
  48. package/dist/types/CameraFilter.d.ts +0 -6
  49. package/dist/types/ColorTool.d.ts +0 -45
  50. package/dist/types/FilterTool.d.ts +0 -16
  51. package/dist/types/SourceSelector.d.ts +0 -28
  52. package/dist/types/cjs/CameraFilter.d.cts +0 -1
  53. package/dist/types/cjs/ColorTool.d.cts +0 -1
  54. package/dist/types/cjs/FilterTool.d.cts +0 -1
  55. package/dist/types/cjs/SourceSelector.d.cts +0 -1
  56. package/dist/types/cjs/widgets/ColorTool/FilterImage/FilterImage.d.cts +0 -11
  57. package/dist/types/cjs/widgets/ColorTool/ImageComposite/ImageComposite.d.cts +0 -7
  58. /package/dist/{types/cjs/atomic/Blinker/Blinker.d.cts → atomic/Blinker/Blinker.d.ts} +0 -0
  59. /package/dist/{types/cjs/atomic/Blinker/Controls/Controls.d.cts → atomic/Blinker/Controls/Controls.d.ts} +0 -0
  60. /package/dist/{types/cjs/atomic/Blinker/Controls/styles.d.cts → atomic/Blinker/Controls/styles.d.ts} +0 -0
  61. /package/dist/{types/cjs/atomic/Blinker/Image/Image.d.cts → atomic/Blinker/Image/Image.d.ts} +0 -0
  62. /package/dist/{types/cjs/atomic/Blinker/Image/styles.d.cts → atomic/Blinker/Image/styles.d.ts} +0 -0
  63. /package/dist/{types/cjs/atomic/Blinker/Images/Images.d.cts → atomic/Blinker/Images/Images.d.ts} +0 -0
  64. /package/dist/{types/cjs/atomic/Blinker/Images/styles.d.cts → atomic/Blinker/Images/styles.d.ts} +0 -0
  65. /package/dist/{types/cjs/atomic/Blinker/_mocks/index.d.cts → atomic/Blinker/_mocks/index.d.ts} +0 -0
  66. /package/dist/{types/cjs/atomic/Blinker/index.d.cts → atomic/Blinker/index.d.ts} +0 -0
  67. /package/dist/{types/cjs/atomic/ElapsedTime/ElapsedTime.d.cts → atomic/ElapsedTime/ElapsedTime.d.ts} +0 -0
  68. /package/dist/{types/cjs/atomic/ElapsedTime/index.d.cts → atomic/ElapsedTime/index.d.ts} +0 -0
  69. /package/dist/{types/cjs/atomic/ElapsedTime/styles.d.cts → atomic/ElapsedTime/styles.d.ts} +0 -0
  70. /package/dist/{types/cjs/atomic/PlaybackControl/PlaybackControl.d.cts → atomic/PlaybackControl/PlaybackControl.d.ts} +0 -0
  71. /package/dist/{types/cjs/atomic/PlaybackControl/index.d.cts → atomic/PlaybackControl/index.d.ts} +0 -0
  72. /package/dist/{types/cjs/hooks/useInterval.d.cts → hooks/useInterval.d.ts} +0 -0
  73. /package/dist/{types/cjs/lib/utils.d.cts → lib/utils.d.ts} +0 -0
  74. /package/dist/{types/cjs/lib/utils.test.d.cts → lib/utils.test.d.ts} +0 -0
  75. /package/dist/{types/cjs/styles/svg.d.cts → styles/svg.d.ts} +0 -0
  76. /package/dist/{types/cjs/widgets/CameraFilter/CameraFilter.d.cts → widgets/CameraFilter/CameraFilter.d.ts} +0 -0
  77. /package/dist/{types/cjs/widgets/CameraFilter/CondensedFilterRanges/CondensedFilterRanges.d.cts → widgets/CameraFilter/CondensedFilterRanges/CondensedFilterRanges.d.ts} +0 -0
  78. /package/dist/{types/cjs/widgets/CameraFilter/CondensedFilterRanges/index.d.cts → widgets/CameraFilter/CondensedFilterRanges/index.d.ts} +0 -0
  79. /package/dist/{types/cjs/widgets/CameraFilter/SpectrumDisplay/ColorLabels/ColorLabels.d.cts → widgets/CameraFilter/SpectrumDisplay/ColorLabels/ColorLabels.d.ts} +0 -0
  80. /package/dist/{types/cjs/widgets/CameraFilter/SpectrumDisplay/ColorLabels/index.d.cts → widgets/CameraFilter/SpectrumDisplay/ColorLabels/index.d.ts} +0 -0
  81. /package/dist/{types/cjs/widgets/CameraFilter/SpectrumDisplay/SpectrumDisplay.d.cts → widgets/CameraFilter/SpectrumDisplay/SpectrumDisplay.d.ts} +0 -0
  82. /package/dist/{types/cjs/widgets/CameraFilter/SpectrumDisplay/SpectrumLabels/SpectrumLabels.d.cts → widgets/CameraFilter/SpectrumDisplay/SpectrumLabels/SpectrumLabels.d.ts} +0 -0
  83. /package/dist/{types/cjs/widgets/CameraFilter/SpectrumDisplay/SpectrumLabels/index.d.cts → widgets/CameraFilter/SpectrumDisplay/SpectrumLabels/index.d.ts} +0 -0
  84. /package/dist/{types/cjs/widgets/CameraFilter/SpectrumDisplay/index.d.cts → widgets/CameraFilter/SpectrumDisplay/index.d.ts} +0 -0
  85. /package/dist/{types/cjs/widgets/CameraFilter/data.d.cts → widgets/CameraFilter/data.d.ts} +0 -0
  86. /package/dist/{types/cjs/widgets/CameraFilter/index.d.cts → widgets/CameraFilter/index.d.ts} +0 -0
  87. /package/dist/{types/cjs/widgets/CameraFilter/styles.d.cts → widgets/CameraFilter/styles.d.ts} +0 -0
  88. /package/dist/{types/cjs/widgets/ColorTool/FilterControls/FilterControls.d.cts → widgets/ColorTool/FilterControls/FilterControls.d.ts} +0 -0
  89. /package/dist/{types/cjs/widgets/ColorTool/FilterControls/index.d.cts → widgets/ColorTool/FilterControls/index.d.ts} +0 -0
  90. /package/dist/{types/cjs/widgets/ColorTool/FilterImage/index.d.cts → widgets/ColorTool/FilterImage/index.d.ts} +0 -0
  91. /package/dist/{types/cjs/widgets/ColorTool/ImageComposite/index.d.cts → widgets/ColorTool/ImageComposite/index.d.ts} +0 -0
  92. /package/dist/{types/cjs/widgets/ColorTool/index.d.cts → widgets/ColorTool/index.d.ts} +0 -0
  93. /package/dist/{types/cjs/widgets/FilterTool/FilterTool.d.cts → widgets/FilterTool/FilterTool.d.ts} +0 -0
  94. /package/dist/{types/cjs/widgets/FilterTool/index.d.cts → widgets/FilterTool/index.d.ts} +0 -0
  95. /package/dist/{types/cjs/widgets/FilterTool/styles.d.cts → widgets/FilterTool/styles.d.ts} +0 -0
  96. /package/dist/{types/cjs/widgets/SourceSelector/Message/Message.d.cts → widgets/SourceSelector/Message/Message.d.ts} +0 -0
  97. /package/dist/{types/cjs/widgets/SourceSelector/Message/index.d.cts → widgets/SourceSelector/Message/index.d.ts} +0 -0
  98. /package/dist/{types/cjs/widgets/SourceSelector/Message/styles.d.cts → widgets/SourceSelector/Message/styles.d.ts} +0 -0
  99. /package/dist/{types/cjs/widgets/SourceSelector/Point/Point.d.cts → widgets/SourceSelector/Point/Point.d.ts} +0 -0
  100. /package/dist/{types/cjs/widgets/SourceSelector/Point/index.d.cts → widgets/SourceSelector/Point/index.d.ts} +0 -0
  101. /package/dist/{types/cjs/widgets/SourceSelector/Point/styles.d.cts → widgets/SourceSelector/Point/styles.d.ts} +0 -0
  102. /package/dist/{types/cjs/widgets/SourceSelector/Points/Points.d.cts → widgets/SourceSelector/Points/Points.d.ts} +0 -0
  103. /package/dist/{types/cjs/widgets/SourceSelector/Points/index.d.cts → widgets/SourceSelector/Points/index.d.ts} +0 -0
  104. /package/dist/{types/cjs/widgets/SourceSelector/SourceSelector.d.cts → widgets/SourceSelector/SourceSelector.d.ts} +0 -0
  105. /package/dist/{types/cjs/widgets/SourceSelector/index.d.cts → widgets/SourceSelector/index.d.ts} +0 -0
  106. /package/dist/{types/cjs/widgets/SourceSelector/mocks/index.d.cts → widgets/SourceSelector/mocks/index.d.ts} +0 -0
  107. /package/dist/{types/cjs/widgets/SourceSelector/utilities.d.cts → widgets/SourceSelector/utilities.d.ts} +0 -0
  108. /package/dist/{types/cjs/widgets/SourceSelector/utilities.test.d.cts → widgets/SourceSelector/utilities.test.d.ts} +0 -0
@@ -0,0 +1,3 @@
1
+ export * from './widgets/CameraFilter/CameraFilter'
2
+ import _default from './widgets/CameraFilter/CameraFilter'
3
+ export default _default
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),v=require("react-i18next"),h=require("./widgets/ColorTool/utilities.cjs"),t=require("./widgets/ColorTool/styles.cjs"),B=require("@rubin-epo/epo-react-lib/Select"),I=require("./widgets/ColorTool/FilterControls/FilterControls.cjs"),N=require("./widgets/ColorTool/ImageComposite/ImageComposite.cjs"),R=l=>l&&l.__esModule?l:{default:l},M=R(B),g=({data:l,objectOptions:m=[],selectedData:s,colorOptions:T=[],selectionCallback:n,isDisabled:j=!1,isDisplayOnly:a=!1,hideImage:C=!1,hideSubtitle:L=!1})=>{const _=r=>{const{label:i}=r,{filters:b}=s,q=b.map(x=>x.label===i?r:x);return n&&n({...s,filters:q})},y=r=>{const{value:i}=r.target;return n&&n({name:i,filters:h.getDataFiltersByName(l,i)})},p=()=>n&&n({...s,filters:h.resetFilters(s.filters)}),d=l.length>1,{t:o}=v.useTranslation(),F=o("colorTool.actions.select_an_object"),{filters:u,name:c,caption:f}=s,S=h.getCategoryName(l,c);return e.jsx(t.WidgetContainer,{children:e.jsxs(t.WidgetLayout,{style:{"--controls-row":a?"'image image'":void 0},children:[c&&(a||d)&&e.jsxs(t.Subtitle,{children:[d&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:o("colorTool.labels.object_type")}),e.jsx("dd",{children:S})]}),!L&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:o("colorTool.labels.object",{context:d?"selected":!1})}),e.jsx("dd",{children:c})]})]}),!a&&e.jsxs(t.ControlsContainer,{children:[d&&e.jsx(t.SelectionContainer,{children:e.jsx(M.default,{id:"astroObjectSelector",placeholder:F,options:m,onChange:y,value:c,disabled:j})}),u&&e.jsxs(e.Fragment,{children:[e.jsx(t.ToolsHeader,{id:"filterLabel",children:o("colorTool.labels.filter")}),e.jsx(t.ToolsHeader,{id:"colorLabel",children:o("colorTool.labels.color")}),e.jsx(t.ToolsHeader,{id:"intensityLabel",children:o("colorTool.labels.color_intensity")})]}),u&&u.map(r=>{const{label:i,isDisabled:b}=r;return e.jsx(I.default,{filter:r,isDisabled:j||b,colorOptions:T,onChangeFilterCallback:_,buttonLabelledById:"filterLabel",selectLabelledById:"colorLabel",sliderLabelledById:"intensityLabel"},`filter-${i}`)})]}),!C&&e.jsx(N.default,{filters:u}),c&&!a&&e.jsx(t.ResetButton,{disabled:j||!h.isResetButtonActive(s),onClick:p,icon:"RotateLeftWithCenter",children:o("colorTool.actions.reset")}),f&&e.jsx(t.Caption,{children:f})]})})};g.displayName="Widgets.ColorTool";exports.default=g;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),x=require("react"),N=require("react-i18next"),O=require("./widgets/ColorTool/utilities.cjs"),o=require("./widgets/ColorTool/styles.cjs"),W=require("@rubin-epo/epo-react-lib/SelectListbox"),H=require("./widgets/ColorTool/Actions/index.cjs"),y=require("./widgets/ColorTool/ImageComposite/ImageComposite.cjs"),R=require("./widgets/ColorTool/FilterControls/FilterControls.cjs"),$=l=>l&&l.__esModule?l:{default:l},v=$(W),T=({data:l,objectOptions:p=[],selectedData:n,colorOptions:L=[],selectionCallback:r,isDisabled:u=!1,isDisplayOnly:C=!1,config:S={actions:["reset"],width:600,height:600,hideSubtitle:!1}})=>{var g;const _={actions:["reset"],width:600,height:600,hideSubtitle:!1},h=x.useRef(null),{t:a}=N.useTranslation(),q=x.useCallback(t=>{const{label:f}=t,{filters:b}=n,M=b.map(m=>m.label===f?t:m);return r&&r({...n,filters:M})},[n,r]),F=x.useCallback(t=>{if(t!==null)return r&&r({name:t,filters:O.getDataFiltersByName(l,t)})},[r,l]),{filters:c,name:d}=n,{actions:w,width:s,height:i,hideSubtitle:B}={..._,...S};if(C)return e.jsx(y.default,{ref:h,filters:c,width:s,height:i,selectedObjectName:d});const j=l.length>1,I=a("colorTool.actions.select_an_object");return e.jsx(o.WidgetContainer,{children:e.jsxs(o.WidgetLayout,{style:{"--image-width":typeof s=="number"?`${s}px`:s,"--image-height":typeof i=="number"?`${i}px`:i},children:[d&&j&&e.jsx(o.Title,{children:!B&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:a("colorTool.labels.object")}),e.jsx("dd",{children:d})]})}),e.jsxs(o.ControlsContainer,{children:[c&&e.jsxs(e.Fragment,{children:[e.jsx(o.ToolsHeader,{id:"filterLabel",children:a("colorTool.labels.filter")}),e.jsx(o.ToolsHeader,{id:"colorLabel",children:a("colorTool.labels.color")}),e.jsx(o.ToolsHeader,{id:"intensityLabel",children:a("colorTool.labels.color_intensity")})]}),c&&c.map(t=>{const{label:f,isDisabled:b}=t;return e.jsx(R.default,{filter:t,isDisabled:u||b,colorOptions:L,onChangeFilterCallback:q,buttonLabelledById:"filterLabel",selectLabelledById:"colorLabel",sliderLabelledById:"intensityLabel"},`filter-${f}`)})]}),e.jsx(y.default,{ref:h,filters:c,width:s,height:i,selectedObjectName:d,children:j&&e.jsx(o.SelectionContainer,{children:e.jsx(v.default,{id:"astroObjectSelector",placeholder:I,options:p,onChangeCallback:F,value:d,isDisabled:u,width:"100%",maxWidth:"100%"})})}),e.jsx(H.default,{actions:w,images:(g=h.current)==null?void 0:g.getElementsByTagName("canvas"),selectedData:n,width:s,height:i,isDisabled:u,selectionCallback:r})]})})};T.displayName="Widgets.ColorTool";exports.default=T;
@@ -0,0 +1,3 @@
1
+ export * from './widgets/ColorTool/ColorTool'
2
+ import _default from './widgets/ColorTool/ColorTool'
3
+ export default _default
package/dist/ColorTool.js CHANGED
@@ -1,103 +1,139 @@
1
- import { jsx as e, jsxs as i, Fragment as b } from "react/jsx-runtime";
2
- import { useTranslation as x } from "react-i18next";
3
- import { getCategoryName as I, isResetButtonActive as R, getDataFiltersByName as W, resetFilters as _ } from "./widgets/ColorTool/utilities.js";
4
- import { WidgetContainer as w, WidgetLayout as A, Subtitle as H, ControlsContainer as M, SelectionContainer as P, ToolsHeader as g, ResetButton as $, Caption as q } from "./widgets/ColorTool/styles.js";
5
- import z from "@rubin-epo/epo-react-lib/Select";
6
- import E from "./widgets/ColorTool/FilterControls/FilterControls.js";
7
- import G from "./widgets/ColorTool/ImageComposite/ImageComposite.js";
1
+ import { jsx as e, jsxs as c, Fragment as L } from "react/jsx-runtime";
2
+ import { useRef as $, useCallback as T } from "react";
3
+ import { useTranslation as R } from "react-i18next";
4
+ import { getDataFiltersByName as A } from "./widgets/ColorTool/utilities.js";
5
+ import { WidgetContainer as E, WidgetLayout as H, Title as M, ControlsContainer as P, ToolsHeader as p, SelectionContainer as q } from "./widgets/ColorTool/styles.js";
6
+ import v from "@rubin-epo/epo-react-lib/SelectListbox";
7
+ import z from "./widgets/ColorTool/Actions/index.js";
8
+ import C from "./widgets/ColorTool/ImageComposite/ImageComposite.js";
9
+ import G from "./widgets/ColorTool/FilterControls/FilterControls.js";
8
10
  const J = ({
9
- data: h,
10
- objectOptions: C = [],
11
- selectedData: l,
12
- colorOptions: L = [],
13
- selectionCallback: r,
14
- isDisabled: m = !1,
15
- isDisplayOnly: c = !1,
16
- hideImage: T = !1,
17
- hideSubtitle: y = !1
11
+ data: d,
12
+ objectOptions: j = [],
13
+ selectedData: i,
14
+ colorOptions: x = [],
15
+ selectionCallback: o,
16
+ isDisabled: h = !1,
17
+ isDisplayOnly: S = !1,
18
+ config: w = {
19
+ actions: ["reset"],
20
+ width: 600,
21
+ height: 600,
22
+ hideSubtitle: !1
23
+ }
18
24
  }) => {
19
- const j = (t) => {
20
- const { label: n } = t, { filters: f } = l, v = f.map(
21
- (u) => u.label === n ? t : u
25
+ var g;
26
+ const B = {
27
+ actions: ["reset"],
28
+ width: 600,
29
+ height: 600,
30
+ hideSubtitle: !1
31
+ }, m = $(null), { t: n } = R(), F = T(
32
+ (t) => {
33
+ const { label: f } = t, { filters: b } = i, _ = b.map(
34
+ (y) => y.label === f ? t : y
35
+ );
36
+ return o && o({
37
+ ...i,
38
+ filters: _
39
+ });
40
+ },
41
+ [i, o]
42
+ ), I = T(
43
+ (t) => {
44
+ if (t !== null)
45
+ return o && o({
46
+ name: t,
47
+ filters: A(d, t)
48
+ });
49
+ },
50
+ [o, d]
51
+ ), { filters: s, name: a } = i, { actions: N, width: l, height: r, hideSubtitle: W } = {
52
+ ...B,
53
+ ...w
54
+ };
55
+ if (S)
56
+ return /* @__PURE__ */ e(
57
+ C,
58
+ {
59
+ ref: m,
60
+ filters: s,
61
+ width: l,
62
+ height: r,
63
+ selectedObjectName: a
64
+ }
22
65
  );
23
- return r && r({
24
- ...l,
25
- filters: v
26
- });
27
- }, B = (t) => {
28
- const { value: n } = t.target;
29
- return r && r({
30
- name: n,
31
- filters: W(h, n)
32
- });
33
- }, F = () => r && r({
34
- ...l,
35
- filters: _(l.filters)
36
- }), a = h.length > 1, { t: o } = x(), N = o("colorTool.actions.select_an_object"), { filters: d, name: s, caption: p } = l, S = I(h, s);
37
- return /* @__PURE__ */ e(w, { children: /* @__PURE__ */ i(
38
- A,
66
+ const u = d.length > 1, O = n("colorTool.actions.select_an_object");
67
+ return /* @__PURE__ */ e(E, { children: /* @__PURE__ */ c(
68
+ H,
39
69
  {
40
70
  style: {
41
- "--controls-row": c ? "'image image'" : void 0
71
+ "--image-width": typeof l == "number" ? `${l}px` : l,
72
+ "--image-height": typeof r == "number" ? `${r}px` : r
42
73
  },
43
74
  children: [
44
- s && (c || a) && /* @__PURE__ */ i(H, { children: [
45
- a && /* @__PURE__ */ i(b, { children: [
46
- /* @__PURE__ */ e("dt", { children: o("colorTool.labels.object_type") }),
47
- /* @__PURE__ */ e("dd", { children: S })
75
+ a && u && /* @__PURE__ */ e(M, { children: !W && /* @__PURE__ */ c(L, { children: [
76
+ /* @__PURE__ */ e("dt", { children: n("colorTool.labels.object") }),
77
+ /* @__PURE__ */ e("dd", { children: a })
78
+ ] }) }),
79
+ /* @__PURE__ */ c(P, { children: [
80
+ s && /* @__PURE__ */ c(L, { children: [
81
+ /* @__PURE__ */ e(p, { id: "filterLabel", children: n("colorTool.labels.filter") }),
82
+ /* @__PURE__ */ e(p, { id: "colorLabel", children: n("colorTool.labels.color") }),
83
+ /* @__PURE__ */ e(p, { id: "intensityLabel", children: n("colorTool.labels.color_intensity") })
48
84
  ] }),
49
- !y && /* @__PURE__ */ i(b, { children: [
50
- /* @__PURE__ */ e("dt", { children: o("colorTool.labels.object", {
51
- context: a ? "selected" : !1
52
- }) }),
53
- /* @__PURE__ */ e("dd", { children: s })
54
- ] })
55
- ] }),
56
- !c && /* @__PURE__ */ i(M, { children: [
57
- a && /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e(
58
- z,
59
- {
60
- id: "astroObjectSelector",
61
- placeholder: N,
62
- options: C,
63
- onChange: B,
64
- value: s,
65
- disabled: m
66
- }
67
- ) }),
68
- d && /* @__PURE__ */ i(b, { children: [
69
- /* @__PURE__ */ e(g, { id: "filterLabel", children: o("colorTool.labels.filter") }),
70
- /* @__PURE__ */ e(g, { id: "colorLabel", children: o("colorTool.labels.color") }),
71
- /* @__PURE__ */ e(g, { id: "intensityLabel", children: o("colorTool.labels.color_intensity") })
72
- ] }),
73
- d && d.map((t) => {
74
- const { label: n, isDisabled: f } = t;
85
+ s && s.map((t) => {
86
+ const { label: f, isDisabled: b } = t;
75
87
  return /* @__PURE__ */ e(
76
- E,
88
+ G,
77
89
  {
78
90
  filter: t,
79
- isDisabled: m || f,
80
- colorOptions: L,
81
- onChangeFilterCallback: j,
91
+ isDisabled: h || b,
92
+ colorOptions: x,
93
+ onChangeFilterCallback: F,
82
94
  buttonLabelledById: "filterLabel",
83
95
  selectLabelledById: "colorLabel",
84
96
  sliderLabelledById: "intensityLabel"
85
97
  },
86
- `filter-${n}`
98
+ `filter-${f}`
87
99
  );
88
100
  })
89
101
  ] }),
90
- !T && /* @__PURE__ */ e(G, { filters: d }),
91
- s && !c && /* @__PURE__ */ e(
92
- $,
102
+ /* @__PURE__ */ e(
103
+ C,
93
104
  {
94
- disabled: m || !R(l),
95
- onClick: F,
96
- icon: "RotateLeftWithCenter",
97
- children: o("colorTool.actions.reset")
105
+ ref: m,
106
+ filters: s,
107
+ width: l,
108
+ height: r,
109
+ selectedObjectName: a,
110
+ children: u && /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(
111
+ v,
112
+ {
113
+ id: "astroObjectSelector",
114
+ placeholder: O,
115
+ options: j,
116
+ onChangeCallback: I,
117
+ value: a,
118
+ isDisabled: h,
119
+ width: "100%",
120
+ maxWidth: "100%"
121
+ }
122
+ ) })
98
123
  }
99
124
  ),
100
- p && /* @__PURE__ */ e(q, { children: p })
125
+ /* @__PURE__ */ e(
126
+ z,
127
+ {
128
+ actions: N,
129
+ images: (g = m.current) == null ? void 0 : g.getElementsByTagName("canvas"),
130
+ selectedData: i,
131
+ width: l,
132
+ height: r,
133
+ isDisabled: h,
134
+ selectionCallback: o
135
+ }
136
+ )
101
137
  ]
102
138
  }
103
139
  ) });
@@ -0,0 +1,3 @@
1
+ export * from './widgets/FilterTool/FilterTool'
2
+ import _default from './widgets/FilterTool/FilterTool'
3
+ export default _default
@@ -0,0 +1,3 @@
1
+ export * from './widgets/SourceSelector/SourceSelector'
2
+ import _default from './widgets/SourceSelector/SourceSelector'
3
+ export default _default
@@ -281,7 +281,7 @@ export declare const PlaybackButton: import("styled-components").IStyledComponen
281
281
  formNoValidate?: boolean | undefined;
282
282
  formTarget?: string | undefined;
283
283
  name?: string | undefined;
284
- type?: "button" | "submit" | "reset" | undefined;
284
+ type?: "button" | "reset" | "submit" | undefined;
285
285
  value?: string | number | readonly string[] | undefined;
286
286
  defaultChecked?: boolean | undefined;
287
287
  defaultValue?: string | number | readonly string[] | undefined;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react");function R({url:n,crossOrigin:r,referrerpolicy:u,onLoadCallback:d,onErrorCallback:s}){const o=t.useRef("loading"),c=t.useRef(),[g,a]=t.useState(0),i=t.useRef(),f=t.useRef(),m=t.useRef();return(i.current!==n||f.current!==r||m.current!==u)&&(o.current="loading",c.current=void 0,i.current=n,f.current=r,m.current=u),t.useLayoutEffect(function(){if(!n)return;var e=document.createElement("img");function v(){o.current="loaded",c.current=e,d&&d(),a(Math.random())}function l(){o.current="failed",c.current=void 0,s&&s(),a(Math.random())}return e.addEventListener("load",v),e.addEventListener("error",l),r&&(e.crossOrigin=r),u&&(e.referrerPolicy=u),e.src=n,function(){e.removeEventListener("load",v),e.removeEventListener("error",l)}},[n,r,u]),[c.current,o.current]}exports.default=R;
@@ -0,0 +1,10 @@
1
+ type ImageStatus = "loading" | "loaded" | "failed";
2
+ interface useImageProps {
3
+ url: string;
4
+ crossOrigin?: "anonymous" | "use-credentials";
5
+ referrerpolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
6
+ onLoadCallback?: () => void;
7
+ onErrorCallback?: () => void;
8
+ }
9
+ declare function useImage({ url, crossOrigin, referrerpolicy, onLoadCallback, onErrorCallback, }: useImageProps): [undefined | HTMLImageElement, ImageStatus];
10
+ export default useImage;
@@ -0,0 +1,30 @@
1
+ import { useRef as o, useState as g, useLayoutEffect as l } from "react";
2
+ function M({
3
+ url: t,
4
+ crossOrigin: n,
5
+ referrerpolicy: r,
6
+ onLoadCallback: d,
7
+ onErrorCallback: a
8
+ }) {
9
+ const u = o("loading"), c = o(), [L, s] = g(0), i = o(), f = o(), m = o();
10
+ return (i.current !== t || f.current !== n || m.current !== r) && (u.current = "loading", c.current = void 0, i.current = t, f.current = n, m.current = r), l(
11
+ function() {
12
+ if (!t)
13
+ return;
14
+ var e = document.createElement("img");
15
+ function v() {
16
+ u.current = "loaded", c.current = e, d && d(), s(Math.random());
17
+ }
18
+ function E() {
19
+ u.current = "failed", c.current = void 0, a && a(), s(Math.random());
20
+ }
21
+ return e.addEventListener("load", v), e.addEventListener("error", E), n && (e.crossOrigin = n), r && (e.referrerPolicy = r), e.src = t, function() {
22
+ e.removeEventListener("load", v), e.removeEventListener("error", E);
23
+ };
24
+ },
25
+ [t, n, r]
26
+ ), [c.current, u.current];
27
+ }
28
+ export {
29
+ M as default
30
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(r,e){const c=function(){return r.indexOf("data:image/png")===0},i=function(t,o){var n=document.createElement("a");n.href=t,n.download=o,document.body.appendChild(n),n.click()};return{toBase64:function(){return r},toImg:function(){const t=document.createElement("img");return t.src=r,t},toCanvas:function(t){const o=document.createElement("canvas"),n=e==null?void 0:e.getBoundingClientRect();o.width=(n==null?void 0:n.width)||0,o.height=(n==null?void 0:n.height)||0;const a=o.getContext("2d");var u=this.toImg();u.onload=function(){a==null||a.drawImage(u,0,0),t(o)}},toPng:function(){if(c()){var t=document.createElement("img");return t.src=r,t}this.toCanvas(function(o){var n=document.createElement("img");return n.src=o.toDataURL(),n})},toJpeg:function(t){t=t||1,(o=>{this.toCanvas(function(n){var a=document.createElement("img");return a.src=n.toDataURL("image/jpeg",o),a})})(t)},downloadPng:function(t){if(t=t||"image.png",c()){i(r,t);return}this.toCanvas(function(o){i(o.toDataURL(),t)})}}}function m(r){const e=r.toDataURL();return g(e)}exports.fromCanvas=m;
@@ -0,0 +1,7 @@
1
+ declare function fromSvg(svgElement: SVGElement): {
2
+ [key: string]: Function;
3
+ };
4
+ declare function fromCanvas(canvasElement: HTMLCanvasElement): {
5
+ [key: string]: Function;
6
+ };
7
+ export { fromSvg, fromCanvas };
@@ -0,0 +1,60 @@
1
+ function g(r, c) {
2
+ const i = function() {
3
+ return r.indexOf("data:image/png") === 0;
4
+ }, e = function(t, o) {
5
+ var n = document.createElement("a");
6
+ n.href = t, n.download = o, document.body.appendChild(n), n.click();
7
+ };
8
+ return {
9
+ toBase64: function() {
10
+ return r;
11
+ },
12
+ toImg: function() {
13
+ const t = document.createElement("img");
14
+ return t.src = r, t;
15
+ },
16
+ toCanvas: function(t) {
17
+ const o = document.createElement("canvas"), n = c == null ? void 0 : c.getBoundingClientRect();
18
+ o.width = (n == null ? void 0 : n.width) || 0, o.height = (n == null ? void 0 : n.height) || 0;
19
+ const a = o.getContext("2d");
20
+ var u = this.toImg();
21
+ u.onload = function() {
22
+ a == null || a.drawImage(u, 0, 0), t(o);
23
+ };
24
+ },
25
+ toPng: function() {
26
+ if (i()) {
27
+ var t = document.createElement("img");
28
+ return t.src = r, t;
29
+ }
30
+ this.toCanvas(function(o) {
31
+ var n = document.createElement("img");
32
+ return n.src = o.toDataURL(), n;
33
+ });
34
+ },
35
+ toJpeg: function(t) {
36
+ t = t || 1, ((o) => {
37
+ this.toCanvas(function(n) {
38
+ var a = document.createElement("img");
39
+ return a.src = n.toDataURL("image/jpeg", o), a;
40
+ });
41
+ })(t);
42
+ },
43
+ downloadPng: function(t) {
44
+ if (t = t || "image.png", i()) {
45
+ e(r, t);
46
+ return;
47
+ }
48
+ this.toCanvas(function(o) {
49
+ e(o.toDataURL(), t);
50
+ });
51
+ }
52
+ };
53
+ }
54
+ function m(r) {
55
+ const c = r.toDataURL();
56
+ return g(c);
57
+ }
58
+ export {
59
+ m as fromCanvas
60
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("react/jsx-runtime"),p=require("react"),x=require("@rubin-epo/epo-react-lib/Button"),g=require("../../../../lib/reimg.cjs"),v=t=>t&&t.__esModule?t:{default:t},_=v(x),c=({images:t,filters:o,filename:s,width:r,height:n,children:l,isDisabled:u})=>{const i=p.useCallback(()=>{const a=document.createElement("canvas"),e=a.getContext("2d");t&&e&&(e.canvas.width=r,e.canvas.height=n,e.globalCompositeOperation="screen",Array.from(t).forEach((d,f)=>{o[f].active&&e.drawImage(d,0,0,r,n)})),g.fromCanvas(a).downloadPng(s)},[t,o]);return m.jsx(_.default,{disabled:u,style:{"--button-text-align":"left"},icon:"ArrowUpFromBracket",onClick:i,isBlock:!0,children:l})};c.displayName="Widgets.ColorTool.Reset";const b=c;exports.default=b;
@@ -0,0 +1,12 @@
1
+ import { FunctionComponent, PropsWithChildren } from "react";
2
+ import { ImageFilter } from "../../ColorTool";
3
+ interface ExportProps {
4
+ images?: HTMLCollection;
5
+ filename: string;
6
+ filters: ImageFilter[];
7
+ width: number;
8
+ height: number;
9
+ isDisabled: boolean;
10
+ }
11
+ declare const Export: FunctionComponent<PropsWithChildren<ExportProps>>;
12
+ export default Export;
@@ -0,0 +1,36 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { useCallback as x } from "react";
3
+ import u from "@rubin-epo/epo-react-lib/Button";
4
+ import { fromCanvas as C } from "../../../../lib/reimg.js";
5
+ const c = ({
6
+ images: t,
7
+ filters: r,
8
+ filename: s,
9
+ width: e,
10
+ height: a,
11
+ children: l,
12
+ isDisabled: m
13
+ }) => {
14
+ const i = x(() => {
15
+ const n = document.createElement("canvas"), o = n.getContext("2d");
16
+ t && o && (o.canvas.width = e, o.canvas.height = a, o.globalCompositeOperation = "screen", Array.from(t).forEach((p, d) => {
17
+ r[d].active && o.drawImage(p, 0, 0, e, a);
18
+ })), C(n).downloadPng(s);
19
+ }, [t, r]);
20
+ return /* @__PURE__ */ f(
21
+ u,
22
+ {
23
+ disabled: m,
24
+ style: { "--button-text-align": "left" },
25
+ icon: "ArrowUpFromBracket",
26
+ onClick: i,
27
+ isBlock: !0,
28
+ children: l
29
+ }
30
+ );
31
+ };
32
+ c.displayName = "Widgets.ColorTool.Reset";
33
+ const k = c;
34
+ export {
35
+ k as default
36
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),r=require("@rubin-epo/epo-react-lib/Button"),a=require("../../utilities.cjs"),c=t=>t&&t.__esModule?t:{default:t},d=c(r),f=t=>t.map(e=>{const{defaultValue:s,min:o,max:u}=e,i=s||1;return{...e,active:!1,color:"",brightness:a.getBrightnessValue(o,u,i),value:i}}),l=({isDisabled:t,selectedData:e,onResetCallback:s,children:o})=>{const{filters:u}=e;return n.jsx(d.default,{style:{"--button-text-align":"left"},disabled:t,icon:"RotateLeftWithCenter",onClick:()=>s&&s({...e,filters:f(u)}),isBlock:!0,children:o})};l.displayName="Widgets.ColorTool.Reset";const g=l;exports.default=g;
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent, PropsWithChildren } from "react";
2
+ import { AstroObject } from "../../ColorTool";
3
+ interface ResetProps {
4
+ isDisabled: boolean;
5
+ selectedData: AstroObject;
6
+ onResetCallback: (data: AstroObject) => void;
7
+ }
8
+ declare const Reset: FunctionComponent<PropsWithChildren<ResetProps>>;
9
+ export default Reset;
@@ -0,0 +1,39 @@
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import a from "@rubin-epo/epo-react-lib/Button";
3
+ import { getBrightnessValue as m } from "../../utilities.js";
4
+ const u = (o) => o.map((t) => {
5
+ const { defaultValue: e, min: s, max: r } = t, i = e || 1;
6
+ return {
7
+ ...t,
8
+ active: !1,
9
+ color: "",
10
+ brightness: m(s, r, i),
11
+ value: i
12
+ };
13
+ }), n = ({
14
+ isDisabled: o,
15
+ selectedData: t,
16
+ onResetCallback: e,
17
+ children: s
18
+ }) => {
19
+ const { filters: r } = t;
20
+ return /* @__PURE__ */ l(
21
+ a,
22
+ {
23
+ style: { "--button-text-align": "left" },
24
+ disabled: o,
25
+ icon: "RotateLeftWithCenter",
26
+ onClick: () => e && e({
27
+ ...t,
28
+ filters: u(r)
29
+ }),
30
+ isBlock: !0,
31
+ children: s
32
+ }
33
+ );
34
+ };
35
+ n.displayName = "Widgets.ColorTool.Reset";
36
+ const d = n;
37
+ export {
38
+ d as default
39
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),A=require("./Reset/index.cjs"),b=require("./Export/index.cjs"),j=require("./styles.cjs"),p=require("react-i18next"),h=require("../utilities.cjs"),i=({actions:o,isDisabled:c,width:l,height:u,selectedData:e,selectionCallback:s,images:a})=>{const{t:d}=p.useTranslation(),{filters:x,name:f}=e,r=c||!h.areActionsActive(e);return t.jsx(j.Actions,{children:o.map((m,n)=>{switch(m){case"reset":return t.jsx(A.default,{isDisabled:r,selectedData:e,onResetCallback:q=>s&&s(q),children:d("colorTool.actions.reset")},n);case"export":return t.jsx(b.default,{isDisabled:r,filters:x,width:l,height:u,images:a,filename:f,children:"Export"},n);case"save":return null;default:return null}})})};i.displayName="Widgets.ColorTool.Actions";const v=i;exports.default=v;
@@ -0,0 +1,13 @@
1
+ import { FunctionComponent } from "react";
2
+ import { AstroObject, ColorToolAction } from "../ColorTool";
3
+ interface ActionsProps {
4
+ actions: Array<ColorToolAction>;
5
+ isDisabled: boolean;
6
+ selectedData: AstroObject;
7
+ images: HTMLCollection | undefined;
8
+ width: number;
9
+ height: number;
10
+ selectionCallback: (data: AstroObject) => void;
11
+ }
12
+ declare const Actions: FunctionComponent<ActionsProps>;
13
+ export default Actions;
@@ -0,0 +1,55 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import x from "./Reset/index.js";
3
+ import h from "./Export/index.js";
4
+ import { Actions as b } from "./styles.js";
5
+ import { useTranslation as T } from "react-i18next";
6
+ import { areActionsActive as v } from "../utilities.js";
7
+ const i = ({
8
+ actions: n,
9
+ isDisabled: c,
10
+ width: a,
11
+ height: l,
12
+ selectedData: o,
13
+ selectionCallback: t,
14
+ images: m
15
+ }) => {
16
+ const { t: p } = T(), { filters: f, name: u } = o, s = c || !v(o);
17
+ return /* @__PURE__ */ r(b, { children: n.map((d, e) => {
18
+ switch (d) {
19
+ case "reset":
20
+ return /* @__PURE__ */ r(
21
+ x,
22
+ {
23
+ isDisabled: s,
24
+ selectedData: o,
25
+ onResetCallback: (A) => t && t(A),
26
+ children: p("colorTool.actions.reset")
27
+ },
28
+ e
29
+ );
30
+ case "export":
31
+ return /* @__PURE__ */ r(
32
+ h,
33
+ {
34
+ isDisabled: s,
35
+ filters: f,
36
+ width: a,
37
+ height: l,
38
+ images: m,
39
+ filename: u,
40
+ children: "Export"
41
+ },
42
+ e
43
+ );
44
+ case "save":
45
+ return null;
46
+ default:
47
+ return null;
48
+ }
49
+ }) });
50
+ };
51
+ i.displayName = "Widgets.ColorTool.Actions";
52
+ const y = i;
53
+ export {
54
+ y as default
55
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("styled-components"),o=t=>t&&t.__esModule?t:{default:t},a=o(e),l=a.default.div`
2
+ display: flex;
3
+ gap: var(--color-tool-padding, var(--PADDING_SMALL, 20px));
4
+ grid-area: actions;
5
+ `;exports.Actions=l;