@rubin-epo/epo-widget-lib 0.6.7 → 0.6.10

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 (38) hide show
  1. package/dist/ColorTool.cjs +1 -1
  2. package/dist/ColorTool.js +63 -66
  3. package/dist/ColorToolServer.cjs +1 -0
  4. package/dist/ColorToolServer.d.ts +3 -0
  5. package/dist/ColorToolServer.js +24 -0
  6. package/dist/localeStrings/en/epo-widget-lib.json +2 -1
  7. package/dist/localeStrings/es/epo-widget-lib.json +40 -3
  8. package/dist/widgets/ColorTool/Actions/Export/index.cjs +1 -1
  9. package/dist/widgets/ColorTool/Actions/Export/index.d.ts +1 -5
  10. package/dist/widgets/ColorTool/Actions/Export/index.js +18 -24
  11. package/dist/widgets/ColorTool/Actions/index.cjs +1 -1
  12. package/dist/widgets/ColorTool/Actions/index.d.ts +1 -3
  13. package/dist/widgets/ColorTool/Actions/index.js +24 -29
  14. package/dist/widgets/ColorTool/CompositeRender/index.cjs +1 -0
  15. package/dist/widgets/ColorTool/CompositeRender/index.d.ts +9 -0
  16. package/dist/widgets/ColorTool/CompositeRender/index.js +16 -0
  17. package/dist/widgets/ColorTool/CompositeRender/styles.cjs +3 -0
  18. package/dist/widgets/ColorTool/CompositeRender/styles.d.ts +274 -0
  19. package/dist/widgets/ColorTool/CompositeRender/styles.js +7 -0
  20. package/dist/widgets/ColorTool/FilterControls/styles.d.ts +1 -1
  21. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.cjs +1 -1
  22. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.d.ts +1 -1
  23. package/dist/widgets/ColorTool/ImageComposite/ImageComposite.js +66 -45
  24. package/dist/widgets/ColorTool/OffscreenFilter/index.cjs +1 -0
  25. package/dist/widgets/ColorTool/OffscreenFilter/index.d.ts +15 -0
  26. package/dist/widgets/ColorTool/OffscreenFilter/index.js +28 -0
  27. package/dist/widgets/ColorTool/server.d.ts +5 -0
  28. package/dist/widgets/ColorTool/styles.cjs +6 -18
  29. package/dist/widgets/ColorTool/styles.d.ts +0 -274
  30. package/dist/widgets/ColorTool/styles.js +11 -24
  31. package/dist/widgets/ColorTool/utilities.cjs +1 -1
  32. package/dist/widgets/ColorTool/utilities.d.ts +5 -0
  33. package/dist/widgets/ColorTool/utilities.js +32 -20
  34. package/package.json +3 -1
  35. package/dist/widgets/ColorTool/FilterImage/FilterImage.cjs +0 -1
  36. package/dist/widgets/ColorTool/FilterImage/FilterImage.d.ts +0 -16
  37. package/dist/widgets/ColorTool/FilterImage/FilterImage.js +0 -50
  38. package/dist/widgets/ColorTool/FilterImage/index.d.ts +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),y=require("react"),W=require("react-i18next"),H=require("./widgets/ColorTool/utilities.cjs"),l=require("./widgets/ColorTool/styles.cjs"),N=require("@rubin-epo/epo-react-lib/SelectListbox"),R=require("./widgets/ColorTool/Actions/index.cjs"),T=require("./widgets/ColorTool/ImageComposite/ImageComposite.cjs"),$=require("./widgets/ColorTool/FilterControls/FilterControls.cjs"),v=o=>o&&o.__esModule?o:{default:o},E=v(N),p=({data:o,objectOptions:L=[],selectedData:d,colorOptions:C=[],selectionCallback:i,isDisabled:u=!1,isDisplayOnly:S=!1,className:g,config:_={actions:["reset"],width:600,height:600,hideSubtitle:!1}})=>{var j;const q={actions:["reset"],width:600,height:600,hideSubtitle:!1},h=y.useRef(null),{t:n}=W.useTranslation(),{filters:a,name:c}=d,{actions:F,width:r,height:s,hideSubtitle:w}={...q,..._};if(S)return e.jsx(T.default,{ref:h,filters:a,width:r,height:s,selectedObjectName:c,className:g});const B=t=>{const{label:f}=t,{filters:b}=d,O=b.map(m=>m.label===f?t:m);return i&&i({...d,filters:O})},I=t=>{if(t)return i&&i({name:t,filters:H.getDataFiltersByName(o,t)})},x=o.length>1,M=n("colorTool.actions.select_an_object");return e.jsx(l.WidgetContainer,{className:g,children:e.jsxs(l.WidgetLayout,{style:{"--image-width":typeof r=="number"?`${r}px`:r,"--image-height":typeof s=="number"?`${s}px`:s},children:[c&&x&&e.jsx(l.Title,{children:!w&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:n("colorTool.labels.object")}),e.jsx("dd",{children:c})]})}),e.jsxs(l.ControlsContainer,{children:[a&&e.jsxs(e.Fragment,{children:[e.jsx(l.ToolsHeader,{id:"filterLabel",children:n("colorTool.labels.filter")}),e.jsx(l.ToolsHeader,{id:"colorLabel",children:n("colorTool.labels.color")}),e.jsx(l.ToolsHeader,{id:"intensityLabel",children:n("colorTool.labels.color_intensity")})]}),a&&a.map(t=>{const{label:f,isDisabled:b}=t;return y.createElement($.default,{filter:t,colorOptions:C,key:`filter-${f}`,isDisabled:u||b,onChangeFilterCallback:B,buttonLabelledById:"filterLabel",selectLabelledById:"colorLabel",sliderLabelledById:"intensityLabel"})})]}),e.jsx(T.default,{ref:h,filters:a,width:r,height:s,selectedObjectName:c,children:x&&e.jsx(l.SelectionContainer,{children:e.jsx(E.default,{id:"astroObjectSelector",placeholder:M,options:L,onChangeCallback:I,value:c,isDisabled:u,width:"100%",maxWidth:"100%"})})}),e.jsx(R.default,{actions:F,images:(j=h.current)==null?void 0:j.getElementsByTagName("canvas"),selectedData:d,width:r,height:s,isDisabled:u,selectionCallback:i})]})})};p.displayName="Widgets.ColorTool";exports.default=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),m=require("react"),O=require("react-i18next"),W=require("./widgets/ColorTool/utilities.cjs"),l=require("./widgets/ColorTool/styles.cjs"),H=require("@rubin-epo/epo-react-lib/SelectListbox"),R=require("./widgets/ColorTool/Actions/index.cjs"),y=require("./widgets/ColorTool/ImageComposite/ImageComposite.cjs"),$=require("./widgets/ColorTool/FilterControls/FilterControls.cjs"),v=o=>o&&o.__esModule?o:{default:o},N=v(H),p=({data:o,objectOptions:T=[],selectedData:d,colorOptions:L=[],selectionCallback:r,isDisabled:u=!1,isDisplayOnly:C=!1,className:x,config:S={actions:["reset"],width:600,height:600,hideSubtitle:!1}})=>{const _={actions:["reset"],width:600,height:600,hideSubtitle:!1},h=m.useRef(null),{t:i}=O.useTranslation(),{filters:s,name:n}=d,{actions:q,width:a,height:c,hideSubtitle:F}={..._,...S};if(C)return e.jsx(y.default,{ref:h,filters:s,width:a,height:c,selectedObjectName:n,className:x});const w=t=>{const{label:f}=t,{filters:b}=d,M=b.map(g=>g.label===f?t:g);return r&&r({...d,filters:M})},I=t=>{if(t)return r&&r({name:t,filters:W.getDataFiltersByName(o,t)})},j=o.length>1,B=i("colorTool.actions.select_an_object");return e.jsx(l.WidgetContainer,{className:x,children:e.jsxs(l.WidgetLayout,{style:{"--image-width":typeof a=="number"?`${a}px`:a,"--image-height":typeof c=="number"?`${c}px`:c},children:[n&&j&&e.jsx(l.Title,{children:!F&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:i("colorTool.labels.object")}),e.jsx("dd",{children:n})]})}),e.jsxs(l.ControlsContainer,{children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(l.ToolsHeader,{id:"filterLabel",children:i("colorTool.labels.filter")}),e.jsx(l.ToolsHeader,{id:"colorLabel",children:i("colorTool.labels.color")}),e.jsx(l.ToolsHeader,{id:"intensityLabel",children:i("colorTool.labels.color_intensity")})]}),s&&s.map(t=>{const{label:f,isDisabled:b}=t;return m.createElement($.default,{filter:t,colorOptions:L,key:`filter-${f}`,isDisabled:u||b,onChangeFilterCallback:w,buttonLabelledById:"filterLabel",selectLabelledById:"colorLabel",sliderLabelledById:"intensityLabel"})})]}),e.jsx(y.default,{ref:h,filters:s,width:a,height:c,selectedObjectName:n,children:j&&e.jsx(l.SelectionContainer,{children:e.jsx(N.default,{id:"astroObjectSelector",placeholder:B,options:T,onChangeCallback:I,value:n,isDisabled:u,width:"100%",maxWidth:"100%"})})}),e.jsx(R.default,{actions:q,canvas:h.current,selectedData:d,isDisabled:u,selectionCallback:r})]})})};p.displayName="Widgets.ColorTool";exports.default=p;
package/dist/ColorTool.js CHANGED
@@ -1,93 +1,92 @@
1
- import { jsx as e, jsxs as c, Fragment as T } from "react/jsx-runtime";
2
- import { useRef as $, createElement as E } from "react";
1
+ import { jsx as e, jsxs as c, Fragment as L } from "react/jsx-runtime";
2
+ import { useRef as $, createElement as N } from "react";
3
3
  import { useTranslation as R } from "react-i18next";
4
4
  import { getDataFiltersByName as A } from "./widgets/ColorTool/utilities.js";
5
- import { WidgetContainer as H, WidgetLayout as M, Title as P, ControlsContainer as q, ToolsHeader as b, SelectionContainer as v } from "./widgets/ColorTool/styles.js";
6
- import z from "@rubin-epo/epo-react-lib/SelectListbox";
7
- import D from "./widgets/ColorTool/Actions/index.js";
5
+ import { WidgetContainer as E, WidgetLayout as H, Title as M, ControlsContainer as P, ToolsHeader as b, 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
8
  import C from "./widgets/ColorTool/ImageComposite/ImageComposite.js";
9
- import G from "./widgets/ColorTool/FilterControls/FilterControls.js";
10
- const J = ({
11
- data: g,
12
- objectOptions: j = [],
9
+ import D from "./widgets/ColorTool/FilterControls/FilterControls.js";
10
+ const G = ({
11
+ data: p,
12
+ objectOptions: T = [],
13
13
  selectedData: a,
14
- colorOptions: x = [],
15
- selectionCallback: r,
14
+ colorOptions: j = [],
15
+ selectionCallback: o,
16
16
  isDisabled: d = !1,
17
- isDisplayOnly: S = !1,
18
- className: p,
19
- config: F = {
17
+ isDisplayOnly: x = !1,
18
+ className: u,
19
+ config: S = {
20
20
  actions: ["reset"],
21
21
  width: 600,
22
22
  height: 600,
23
23
  hideSubtitle: !1
24
24
  }
25
25
  }) => {
26
- var y;
27
- const w = {
26
+ const F = {
28
27
  actions: ["reset"],
29
28
  width: 600,
30
29
  height: 600,
31
30
  hideSubtitle: !1
32
- }, h = $(null), { t: i } = R(), { filters: n, name: s } = a, { actions: B, width: o, height: l, hideSubtitle: I } = {
33
- ...w,
34
- ...F
31
+ }, h = $(null), { t: l } = R(), { filters: r, name: i } = a, { actions: w, width: n, height: s, hideSubtitle: B } = {
32
+ ...F,
33
+ ...S
35
34
  };
36
- if (S)
35
+ if (x)
37
36
  return /* @__PURE__ */ e(
38
37
  C,
39
38
  {
40
39
  ref: h,
41
- filters: n,
42
- width: o,
43
- height: l,
44
- selectedObjectName: s,
45
- className: p
40
+ filters: r,
41
+ width: n,
42
+ height: s,
43
+ selectedObjectName: i,
44
+ className: u
46
45
  }
47
46
  );
48
- const W = (t) => {
47
+ const I = (t) => {
49
48
  const { label: m } = t, { filters: f } = a, _ = f.map(
50
- (L) => L.label === m ? t : L
49
+ (y) => y.label === m ? t : y
51
50
  );
52
- return r && r({
51
+ return o && o({
53
52
  ...a,
54
53
  filters: _
55
54
  });
56
- }, N = (t) => {
55
+ }, W = (t) => {
57
56
  if (t)
58
- return r && r({
57
+ return o && o({
59
58
  name: t,
60
- filters: A(g, t)
59
+ filters: A(p, t)
61
60
  });
62
- }, u = g.length > 1, O = i("colorTool.actions.select_an_object");
63
- return /* @__PURE__ */ e(H, { className: p, children: /* @__PURE__ */ c(
64
- M,
61
+ }, g = p.length > 1, O = l("colorTool.actions.select_an_object");
62
+ return /* @__PURE__ */ e(E, { className: u, children: /* @__PURE__ */ c(
63
+ H,
65
64
  {
66
65
  style: {
67
- "--image-width": typeof o == "number" ? `${o}px` : o,
68
- "--image-height": typeof l == "number" ? `${l}px` : l
66
+ "--image-width": typeof n == "number" ? `${n}px` : n,
67
+ "--image-height": typeof s == "number" ? `${s}px` : s
69
68
  },
70
69
  children: [
71
- s && u && /* @__PURE__ */ e(P, { children: !I && /* @__PURE__ */ c(T, { children: [
72
- /* @__PURE__ */ e("dt", { children: i("colorTool.labels.object") }),
73
- /* @__PURE__ */ e("dd", { children: s })
70
+ i && g && /* @__PURE__ */ e(M, { children: !B && /* @__PURE__ */ c(L, { children: [
71
+ /* @__PURE__ */ e("dt", { children: l("colorTool.labels.object") }),
72
+ /* @__PURE__ */ e("dd", { children: i })
74
73
  ] }) }),
75
- /* @__PURE__ */ c(q, { children: [
76
- n && /* @__PURE__ */ c(T, { children: [
77
- /* @__PURE__ */ e(b, { id: "filterLabel", children: i("colorTool.labels.filter") }),
78
- /* @__PURE__ */ e(b, { id: "colorLabel", children: i("colorTool.labels.color") }),
79
- /* @__PURE__ */ e(b, { id: "intensityLabel", children: i("colorTool.labels.color_intensity") })
74
+ /* @__PURE__ */ c(P, { children: [
75
+ r && /* @__PURE__ */ c(L, { children: [
76
+ /* @__PURE__ */ e(b, { id: "filterLabel", children: l("colorTool.labels.filter") }),
77
+ /* @__PURE__ */ e(b, { id: "colorLabel", children: l("colorTool.labels.color") }),
78
+ /* @__PURE__ */ e(b, { id: "intensityLabel", children: l("colorTool.labels.color_intensity") })
80
79
  ] }),
81
- n && n.map((t) => {
80
+ r && r.map((t) => {
82
81
  const { label: m, isDisabled: f } = t;
83
- return /* @__PURE__ */ E(
84
- G,
82
+ return /* @__PURE__ */ N(
83
+ D,
85
84
  {
86
85
  filter: t,
87
- colorOptions: x,
86
+ colorOptions: j,
88
87
  key: `filter-${m}`,
89
88
  isDisabled: d || f,
90
- onChangeFilterCallback: W,
89
+ onChangeFilterCallback: I,
91
90
  buttonLabelledById: "filterLabel",
92
91
  selectLabelledById: "colorLabel",
93
92
  sliderLabelledById: "intensityLabel"
@@ -99,18 +98,18 @@ const J = ({
99
98
  C,
100
99
  {
101
100
  ref: h,
102
- filters: n,
103
- width: o,
104
- height: l,
105
- selectedObjectName: s,
106
- children: u && /* @__PURE__ */ e(v, { children: /* @__PURE__ */ e(
107
- z,
101
+ filters: r,
102
+ width: n,
103
+ height: s,
104
+ selectedObjectName: i,
105
+ children: g && /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(
106
+ v,
108
107
  {
109
108
  id: "astroObjectSelector",
110
109
  placeholder: O,
111
- options: j,
112
- onChangeCallback: N,
113
- value: s,
110
+ options: T,
111
+ onChangeCallback: W,
112
+ value: i,
114
113
  isDisabled: d,
115
114
  width: "100%",
116
115
  maxWidth: "100%"
@@ -119,22 +118,20 @@ const J = ({
119
118
  }
120
119
  ),
121
120
  /* @__PURE__ */ e(
122
- D,
121
+ z,
123
122
  {
124
- actions: B,
125
- images: (y = h.current) == null ? void 0 : y.getElementsByTagName("canvas"),
123
+ actions: w,
124
+ canvas: h.current,
126
125
  selectedData: a,
127
- width: o,
128
- height: l,
129
126
  isDisabled: d,
130
- selectionCallback: r
127
+ selectionCallback: o
131
128
  }
132
129
  )
133
130
  ]
134
131
  }
135
132
  ) });
136
133
  };
137
- J.displayName = "Widgets.ColorTool";
134
+ G.displayName = "Widgets.ColorTool";
138
135
  export {
139
- J as default
136
+ G as default
140
137
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("skia-canvas"),C=require("./widgets/ColorTool/utilities.cjs"),p=(t,a,e,n)=>{t.fillStyle=a,t.fillRect(0,0,e,n)},d=(t,a=[],e,n,s="screen")=>{t.globalCompositeOperation=s,a.forEach(o=>{t.drawCanvas(o,0,0,e,n)})};async function f(t=[],a=600,e=600){const n=t.filter(({active:l})=>l),s=await Promise.all(n.map(async({image:l,color:g="transparent",brightness:m})=>{const i=new c.Canvas(a,e),r=i.getContext("2d"),v=await c.loadImage(l);return r.drawImage(v,0,0,a,e),r.globalCompositeOperation="multiply",r.filter=C.getFilters({brightness:m,contrast:1.3}),p(r,g,a,e),i})),o=new c.Canvas(a,e),u=o.getContext("2d");return d(u,s,a,e),o}const y=async(t=[],a="png",e=600,n=600)=>(await f(t,e,n)).toDataURL(a);exports.default=y;
@@ -0,0 +1,3 @@
1
+ export * from './widgets/ColorTool/server'
2
+ import _default from './widgets/ColorTool/server'
3
+ export default _default
@@ -0,0 +1,24 @@
1
+ import { Canvas as i, loadImage as v } from "skia-canvas";
2
+ import { getFilters as C } from "./widgets/ColorTool/utilities.js";
3
+ const u = (e, a, t, n) => {
4
+ e.fillStyle = a, e.fillRect(0, 0, t, n);
5
+ }, d = (e, a = [], t, n, s = "screen") => {
6
+ e.globalCompositeOperation = s, a.forEach((o) => {
7
+ e.drawCanvas(o, 0, 0, t, n);
8
+ });
9
+ };
10
+ async function y(e = [], a = 600, t = 600) {
11
+ const n = e.filter(({ active: c }) => c), s = await Promise.all(
12
+ n.map(
13
+ async ({ image: c, color: p = "transparent", brightness: g }) => {
14
+ const l = new i(a, t), r = l.getContext("2d"), f = await v(c);
15
+ return r.drawImage(f, 0, 0, a, t), r.globalCompositeOperation = "multiply", r.filter = C({ brightness: g, contrast: 1.3 }), u(r, p, a, t), l;
16
+ }
17
+ )
18
+ ), o = new i(a, t), m = o.getContext("2d");
19
+ return d(m, s, a, t), o;
20
+ }
21
+ const w = async (e = [], a = "png", t = 600, n = 600) => (await y(e, t, n)).toDataURL(a);
22
+ export {
23
+ w as default
24
+ };
@@ -52,7 +52,8 @@
52
52
  "actions": {
53
53
  "select_an_object": "Select an object",
54
54
  "select_filter": "Select a filter",
55
- "reset": "Reset"
55
+ "reset": "Reset",
56
+ "export": "Export"
56
57
  }
57
58
  },
58
59
  "source_selector": {
@@ -16,18 +16,55 @@
16
16
  },
17
17
  "filterTool": {
18
18
  "title": "Herramienta de filtro",
19
- "filter": "El filtro",
19
+ "filter": "Filtro",
20
20
  "whiteLight": "Luz blanca",
21
21
  "prism": "Prisma",
22
- "selectLabel": "Seleccione un filtro:",
22
+ "selectLabel": "Selecciona un filtro:",
23
+ "light_out": "Luz bloqueada",
24
+ "light_filtered": "Luz filtrada",
23
25
  "colors": {
24
26
  "violet": "Violeta",
25
27
  "blue": "Azul",
26
28
  "green": "Verde",
27
29
  "yellow": "Amarillo",
28
- "orange": "Naranja",
30
+ "orange": "Naranjo",
29
31
  "red": "Rojo",
30
32
  "none": "Ninguno"
31
33
  }
34
+ },
35
+ "colorTool": {
36
+ "labels": {
37
+ "object_type": "Tipo de objeto:",
38
+ "object": "Objeto:",
39
+ "object_selected": "Objeto seleccionado:",
40
+ "filter": "Filtro",
41
+ "color": "Color",
42
+ "color_intensity": "Intensidad de color"
43
+ },
44
+ "actions": {
45
+ "select_an_object": "Selecciona un objeto",
46
+ "select_filter": "Selecciona un filtro",
47
+ "reset": "Reiniciar",
48
+ "export": "Exportar"
49
+ }
50
+ },
51
+ "source_selector": {
52
+ "messages": {
53
+ "success": "¡Muy bien!",
54
+ "failure": "Inténtalo de nuevo."
55
+ }
56
+ },
57
+ "camera_filter": {
58
+ "title": "Rangos de los filtros de la cámara LSST del Observatorio Rubin",
59
+ "labels": {
60
+ "select": "Seleccione uno de los filtros Rubin",
61
+ "option": "Filtro {{band}}",
62
+ "option_none": "Ninguno",
63
+ "captured_range": "Espectro electromagnético capturado con el filtro {{filter}} aplicado",
64
+ "captured_range_no_filter": "Espectro electromagnético sin filtro aplicado.",
65
+ "ultraviolet": "Ultravioleta",
66
+ "visible": "Luz visible",
67
+ "infrared": "Infrarrojo"
68
+ }
32
69
  }
33
70
  }
@@ -1 +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;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),s=require("react"),i=require("@rubin-epo/epo-react-lib/Button"),a=require("../../../../lib/reimg.cjs"),c=t=>t&&t.__esModule?t:{default:t},d=c(i),e=({canvas:t,filename:o,isDisabled:r,children:l})=>{const u=s.useCallback(()=>{t&&a.fromCanvas(t).downloadPng(o)},[t]);return n.jsx(d.default,{disabled:r,style:{"--button-text-align":"left"},icon:"ArrowUpFromBracket",onClick:u,isBlock:!0,children:l})};e.displayName="Widgets.ColorTool.Reset";const f=e;exports.default=f;
@@ -1,11 +1,7 @@
1
1
  import { FunctionComponent, PropsWithChildren } from "react";
2
- import { ImageFilter } from "../../ColorTool";
3
2
  interface ExportProps {
4
- images?: HTMLCollection;
3
+ canvas: HTMLCanvasElement | null;
5
4
  filename: string;
6
- filters: ImageFilter[];
7
- width: number;
8
- height: number;
9
5
  isDisabled: boolean;
10
6
  }
11
7
  declare const Export: FunctionComponent<PropsWithChildren<ExportProps>>;
@@ -1,26 +1,20 @@
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
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { useCallback as n } from "react";
3
+ import s from "@rubin-epo/epo-react-lib/Button";
4
+ import { fromCanvas as p } from "../../../../lib/reimg.js";
5
+ const t = ({
6
+ canvas: o,
7
+ filename: r,
8
+ isDisabled: e,
9
+ children: l
13
10
  }) => {
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,
11
+ const i = n(() => {
12
+ o && p(o).downloadPng(r);
13
+ }, [o]);
14
+ return /* @__PURE__ */ m(
15
+ s,
22
16
  {
23
- disabled: m,
17
+ disabled: e,
24
18
  style: { "--button-text-align": "left" },
25
19
  icon: "ArrowUpFromBracket",
26
20
  onClick: i,
@@ -29,8 +23,8 @@ const c = ({
29
23
  }
30
24
  );
31
25
  };
32
- c.displayName = "Widgets.ColorTool.Reset";
33
- const k = c;
26
+ t.displayName = "Widgets.ColorTool.Reset";
27
+ const u = t;
34
28
  export {
35
- k as default
29
+ u as default
36
30
  };
@@ -1 +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;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),f=require("./Reset/index.cjs"),m=require("./Export/index.cjs"),q=require("./styles.cjs"),A=require("react-i18next"),b=require("../utilities.cjs"),i=({actions:c,isDisabled:l,selectedData:e,selectionCallback:s,canvas:u})=>{const{t:r}=A.useTranslation(),{name:a}=e,n=l||!b.areActionsActive(e);return t.jsx(q.Actions,{children:c.map((d,o)=>{switch(d){case"reset":return t.jsx(f.default,{isDisabled:n,selectedData:e,onResetCallback:x=>s&&s(x),children:r("colorTool.actions.reset")},o);case"export":return t.jsx(m.default,{isDisabled:n,canvas:u,filename:a,children:r("colorTool.actions.export")},o);case"save":return null;default:return null}})})};i.displayName="Widgets.ColorTool.Actions";const j=i;exports.default=j;
@@ -4,9 +4,7 @@ interface ActionsProps {
4
4
  actions: Array<ColorToolAction>;
5
5
  isDisabled: boolean;
6
6
  selectedData: AstroObject;
7
- images: HTMLCollection | undefined;
8
- width: number;
9
- height: number;
7
+ canvas: HTMLCanvasElement | null;
10
8
  selectionCallback: (data: AstroObject) => void;
11
9
  }
12
10
  declare const Actions: FunctionComponent<ActionsProps>;
@@ -1,45 +1,40 @@
1
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";
2
+ import f from "./Reset/index.js";
3
+ import d from "./Export/index.js";
4
+ import { Actions as A } from "./styles.js";
5
+ import { useTranslation as x } from "react-i18next";
6
+ import { areActionsActive as h } from "../utilities.js";
7
7
  const i = ({
8
- actions: n,
9
- isDisabled: c,
10
- width: a,
11
- height: l,
8
+ actions: c,
9
+ isDisabled: a,
12
10
  selectedData: o,
13
11
  selectionCallback: t,
14
- images: m
12
+ canvas: l
15
13
  }) => {
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) {
14
+ const { t: s } = x(), { name: m } = o, e = a || !h(o);
15
+ return /* @__PURE__ */ r(A, { children: c.map((p, n) => {
16
+ switch (p) {
19
17
  case "reset":
20
18
  return /* @__PURE__ */ r(
21
- x,
19
+ f,
22
20
  {
23
- isDisabled: s,
21
+ isDisabled: e,
24
22
  selectedData: o,
25
- onResetCallback: (A) => t && t(A),
26
- children: p("colorTool.actions.reset")
23
+ onResetCallback: (u) => t && t(u),
24
+ children: s("colorTool.actions.reset")
27
25
  },
28
- e
26
+ n
29
27
  );
30
28
  case "export":
31
29
  return /* @__PURE__ */ r(
32
- h,
30
+ d,
33
31
  {
34
- isDisabled: s,
35
- filters: f,
36
- width: a,
37
- height: l,
38
- images: m,
39
- filename: u,
40
- children: "Export"
32
+ isDisabled: e,
33
+ canvas: l,
34
+ filename: m,
35
+ children: s("colorTool.actions.export")
41
36
  },
42
- e
37
+ n
43
38
  );
44
39
  case "save":
45
40
  return null;
@@ -49,7 +44,7 @@ const i = ({
49
44
  }) });
50
45
  };
51
46
  i.displayName = "Widgets.ColorTool.Actions";
52
- const y = i;
47
+ const j = i;
53
48
  export {
54
- y as default
49
+ j as default
55
50
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react/jsx-runtime"),m=require("react"),g=require("../utilities.cjs"),C=require("./styles.cjs"),i=m.forwardRef(({layers:s=[],renderLayers:c=[],width:t,height:o},e)=>{var n;const r=(n=e==null?void 0:e.current)==null?void 0:n.getContext("2d"),l=s.filter((u,a)=>u&&c[a]);return r&&(r.clearRect(0,0,t,o),g.mergeCanvases(r,l,t,o)),s.length>0?d.jsx(C.Image,{ref:e,role:"img",width:t,height:o}):null});i.displayName="Widgets.ColorTool.CompositeRenderer";const R=i;exports.default=R;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ interface CompositeRendererProps {
3
+ layers: Array<HTMLCanvasElement>;
4
+ renderLayers: Array<boolean>;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ declare const CompositeRenderer: import("react").ForwardRefExoticComponent<CompositeRendererProps & import("react").RefAttributes<HTMLCanvasElement>>;
9
+ export default CompositeRenderer;
@@ -0,0 +1,16 @@
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import { forwardRef as d } from "react";
3
+ import { mergeCanvases as C } from "../utilities.js";
4
+ import { Image as R } from "./styles.js";
5
+ const s = d(
6
+ ({ layers: m = [], renderLayers: a = [], width: e, height: r }, o) => {
7
+ var n;
8
+ const t = (n = o == null ? void 0 : o.current) == null ? void 0 : n.getContext("2d"), c = m.filter((i, l) => i && a[l]);
9
+ return t && (t.clearRect(0, 0, e, r), C(t, c, e, r)), m.length > 0 ? /* @__PURE__ */ p(R, { ref: o, role: "img", width: e, height: r }) : null;
10
+ }
11
+ );
12
+ s.displayName = "Widgets.ColorTool.CompositeRenderer";
13
+ const v = s;
14
+ export {
15
+ v as default
16
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("styled-components"),a=t=>t&&t.__esModule?t:{default:t},l=a(e),o=l.default.canvas`
2
+ width: 100%;
3
+ `;exports.Image=o;