@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.
- package/dist/ColorTool.cjs +1 -1
- package/dist/ColorTool.js +63 -66
- package/dist/ColorToolServer.cjs +1 -0
- package/dist/ColorToolServer.d.ts +3 -0
- package/dist/ColorToolServer.js +24 -0
- package/dist/localeStrings/en/epo-widget-lib.json +2 -1
- package/dist/localeStrings/es/epo-widget-lib.json +40 -3
- package/dist/widgets/ColorTool/Actions/Export/index.cjs +1 -1
- package/dist/widgets/ColorTool/Actions/Export/index.d.ts +1 -5
- package/dist/widgets/ColorTool/Actions/Export/index.js +18 -24
- package/dist/widgets/ColorTool/Actions/index.cjs +1 -1
- package/dist/widgets/ColorTool/Actions/index.d.ts +1 -3
- package/dist/widgets/ColorTool/Actions/index.js +24 -29
- package/dist/widgets/ColorTool/CompositeRender/index.cjs +1 -0
- package/dist/widgets/ColorTool/CompositeRender/index.d.ts +9 -0
- package/dist/widgets/ColorTool/CompositeRender/index.js +16 -0
- package/dist/widgets/ColorTool/CompositeRender/styles.cjs +3 -0
- package/dist/widgets/ColorTool/CompositeRender/styles.d.ts +274 -0
- package/dist/widgets/ColorTool/CompositeRender/styles.js +7 -0
- package/dist/widgets/ColorTool/FilterControls/styles.d.ts +1 -1
- package/dist/widgets/ColorTool/ImageComposite/ImageComposite.cjs +1 -1
- package/dist/widgets/ColorTool/ImageComposite/ImageComposite.d.ts +1 -1
- package/dist/widgets/ColorTool/ImageComposite/ImageComposite.js +66 -45
- package/dist/widgets/ColorTool/OffscreenFilter/index.cjs +1 -0
- package/dist/widgets/ColorTool/OffscreenFilter/index.d.ts +15 -0
- package/dist/widgets/ColorTool/OffscreenFilter/index.js +28 -0
- package/dist/widgets/ColorTool/server.d.ts +5 -0
- package/dist/widgets/ColorTool/styles.cjs +6 -18
- package/dist/widgets/ColorTool/styles.d.ts +0 -274
- package/dist/widgets/ColorTool/styles.js +11 -24
- package/dist/widgets/ColorTool/utilities.cjs +1 -1
- package/dist/widgets/ColorTool/utilities.d.ts +5 -0
- package/dist/widgets/ColorTool/utilities.js +32 -20
- package/package.json +3 -1
- package/dist/widgets/ColorTool/FilterImage/FilterImage.cjs +0 -1
- package/dist/widgets/ColorTool/FilterImage/FilterImage.d.ts +0 -16
- package/dist/widgets/ColorTool/FilterImage/FilterImage.js +0 -50
- package/dist/widgets/ColorTool/FilterImage/index.d.ts +0 -1
package/dist/ColorTool.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),
|
|
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
|
|
2
|
-
import { useRef as $, createElement as
|
|
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
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
|
10
|
-
const
|
|
11
|
-
data:
|
|
12
|
-
objectOptions:
|
|
9
|
+
import D from "./widgets/ColorTool/FilterControls/FilterControls.js";
|
|
10
|
+
const G = ({
|
|
11
|
+
data: p,
|
|
12
|
+
objectOptions: T = [],
|
|
13
13
|
selectedData: a,
|
|
14
|
-
colorOptions:
|
|
15
|
-
selectionCallback:
|
|
14
|
+
colorOptions: j = [],
|
|
15
|
+
selectionCallback: o,
|
|
16
16
|
isDisabled: d = !1,
|
|
17
|
-
isDisplayOnly:
|
|
18
|
-
className:
|
|
19
|
-
config:
|
|
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
|
-
|
|
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:
|
|
33
|
-
...
|
|
34
|
-
...
|
|
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 (
|
|
35
|
+
if (x)
|
|
37
36
|
return /* @__PURE__ */ e(
|
|
38
37
|
C,
|
|
39
38
|
{
|
|
40
39
|
ref: h,
|
|
41
|
-
filters:
|
|
42
|
-
width:
|
|
43
|
-
height:
|
|
44
|
-
selectedObjectName:
|
|
45
|
-
className:
|
|
40
|
+
filters: r,
|
|
41
|
+
width: n,
|
|
42
|
+
height: s,
|
|
43
|
+
selectedObjectName: i,
|
|
44
|
+
className: u
|
|
46
45
|
}
|
|
47
46
|
);
|
|
48
|
-
const
|
|
47
|
+
const I = (t) => {
|
|
49
48
|
const { label: m } = t, { filters: f } = a, _ = f.map(
|
|
50
|
-
(
|
|
49
|
+
(y) => y.label === m ? t : y
|
|
51
50
|
);
|
|
52
|
-
return
|
|
51
|
+
return o && o({
|
|
53
52
|
...a,
|
|
54
53
|
filters: _
|
|
55
54
|
});
|
|
56
|
-
},
|
|
55
|
+
}, W = (t) => {
|
|
57
56
|
if (t)
|
|
58
|
-
return
|
|
57
|
+
return o && o({
|
|
59
58
|
name: t,
|
|
60
|
-
filters: A(
|
|
59
|
+
filters: A(p, t)
|
|
61
60
|
});
|
|
62
|
-
},
|
|
63
|
-
return /* @__PURE__ */ e(
|
|
64
|
-
|
|
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
|
|
68
|
-
"--image-height": typeof
|
|
66
|
+
"--image-width": typeof n == "number" ? `${n}px` : n,
|
|
67
|
+
"--image-height": typeof s == "number" ? `${s}px` : s
|
|
69
68
|
},
|
|
70
69
|
children: [
|
|
71
|
-
|
|
72
|
-
/* @__PURE__ */ e("dt", { children:
|
|
73
|
-
/* @__PURE__ */ e("dd", { children:
|
|
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(
|
|
76
|
-
|
|
77
|
-
/* @__PURE__ */ e(b, { id: "filterLabel", children:
|
|
78
|
-
/* @__PURE__ */ e(b, { id: "colorLabel", children:
|
|
79
|
-
/* @__PURE__ */ e(b, { id: "intensityLabel", children:
|
|
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
|
-
|
|
80
|
+
r && r.map((t) => {
|
|
82
81
|
const { label: m, isDisabled: f } = t;
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
|
|
82
|
+
return /* @__PURE__ */ N(
|
|
83
|
+
D,
|
|
85
84
|
{
|
|
86
85
|
filter: t,
|
|
87
|
-
colorOptions:
|
|
86
|
+
colorOptions: j,
|
|
88
87
|
key: `filter-${m}`,
|
|
89
88
|
isDisabled: d || f,
|
|
90
|
-
onChangeFilterCallback:
|
|
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:
|
|
103
|
-
width:
|
|
104
|
-
height:
|
|
105
|
-
selectedObjectName:
|
|
106
|
-
children:
|
|
107
|
-
|
|
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:
|
|
112
|
-
onChangeCallback:
|
|
113
|
-
value:
|
|
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
|
-
|
|
121
|
+
z,
|
|
123
122
|
{
|
|
124
|
-
actions:
|
|
125
|
-
|
|
123
|
+
actions: w,
|
|
124
|
+
canvas: h.current,
|
|
126
125
|
selectedData: a,
|
|
127
|
-
width: o,
|
|
128
|
-
height: l,
|
|
129
126
|
isDisabled: d,
|
|
130
|
-
selectionCallback:
|
|
127
|
+
selectionCallback: o
|
|
131
128
|
}
|
|
132
129
|
)
|
|
133
130
|
]
|
|
134
131
|
}
|
|
135
132
|
) });
|
|
136
133
|
};
|
|
137
|
-
|
|
134
|
+
G.displayName = "Widgets.ColorTool";
|
|
138
135
|
export {
|
|
139
|
-
|
|
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,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
|
+
};
|
|
@@ -16,18 +16,55 @@
|
|
|
16
16
|
},
|
|
17
17
|
"filterTool": {
|
|
18
18
|
"title": "Herramienta de filtro",
|
|
19
|
-
"filter": "
|
|
19
|
+
"filter": "Filtro",
|
|
20
20
|
"whiteLight": "Luz blanca",
|
|
21
21
|
"prism": "Prisma",
|
|
22
|
-
"selectLabel": "
|
|
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": "
|
|
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
|
|
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
|
-
|
|
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
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import
|
|
4
|
-
import { fromCanvas as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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:
|
|
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
|
-
|
|
33
|
-
const
|
|
26
|
+
t.displayName = "Widgets.ColorTool.Reset";
|
|
27
|
+
const u = t;
|
|
34
28
|
export {
|
|
35
|
-
|
|
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"),
|
|
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
|
-
|
|
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
|
|
3
|
-
import
|
|
4
|
-
import { Actions as
|
|
5
|
-
import { useTranslation as
|
|
6
|
-
import { areActionsActive as
|
|
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:
|
|
9
|
-
isDisabled:
|
|
10
|
-
width: a,
|
|
11
|
-
height: l,
|
|
8
|
+
actions: c,
|
|
9
|
+
isDisabled: a,
|
|
12
10
|
selectedData: o,
|
|
13
11
|
selectionCallback: t,
|
|
14
|
-
|
|
12
|
+
canvas: l
|
|
15
13
|
}) => {
|
|
16
|
-
const { t:
|
|
17
|
-
return /* @__PURE__ */ r(
|
|
18
|
-
switch (
|
|
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
|
-
|
|
19
|
+
f,
|
|
22
20
|
{
|
|
23
|
-
isDisabled:
|
|
21
|
+
isDisabled: e,
|
|
24
22
|
selectedData: o,
|
|
25
|
-
onResetCallback: (
|
|
26
|
-
children:
|
|
23
|
+
onResetCallback: (u) => t && t(u),
|
|
24
|
+
children: s("colorTool.actions.reset")
|
|
27
25
|
},
|
|
28
|
-
|
|
26
|
+
n
|
|
29
27
|
);
|
|
30
28
|
case "export":
|
|
31
29
|
return /* @__PURE__ */ r(
|
|
32
|
-
|
|
30
|
+
d,
|
|
33
31
|
{
|
|
34
|
-
isDisabled:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
|
47
|
+
const j = i;
|
|
53
48
|
export {
|
|
54
|
-
|
|
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
|
+
};
|