@getodk/web-forms 0.23.1 → 1.0.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.
- package/README.md +353 -3
- package/dist/ActionsInfoDialog-B8AZQOuY.js +44 -0
- package/dist/CanvasBlock-DWoXGSW9.js +1171 -0
- package/dist/{MapBlock-PuSKnmfD.js → MapBlock-BTX9u64V.js} +4764 -4807
- package/dist/index-Cg9qvMI9.js +68551 -0
- package/dist/index.js +2 -2
- package/dist/strings_es-C8xkQaZj.js +127 -0
- package/dist/strings_fr-C0vLmCzP.js +127 -0
- package/dist/strings_id-BE0G3I_d.js +127 -0
- package/dist/vue-konva-D0sZ6RWk.js +7890 -0
- package/package.json +23 -19
- package/dist/index-BYKrQSL_.js +0 -47556
|
@@ -0,0 +1,1171 @@
|
|
|
1
|
+
import { resolveComponent as T, openBlock as d, createElementBlock as m, mergeProps as P, createCommentVNode as k, createVNode as C, withCtx as U, Transition as Ue, createElementVNode as L, shallowRef as j, computed as w, onUnmounted as ge, defineComponent as be, inject as ke, ref as S, watch as ye, onBeforeUnmount as Ae, Fragment as Se, normalizeClass as $, unref as a, normalizeStyle as Ve, createBlock as B, useModel as $e, onMounted as Fe, createTextVNode as Ze, toDisplayString as G, renderList as Xe, mergeModels as re } from "vue";
|
|
2
|
+
import { A as _e } from "./ActionsInfoDialog-B8AZQOuY.js";
|
|
3
|
+
import { B as Ne, k as je, l as Ge, O as Ye, m as Ke, C as We, n as ae, r as qe, o as Je, q as Qe, Z as Y, T as Ce, I as x, _ as we, u as en, v as se, j as nn } from "./index-Cg9qvMI9.js";
|
|
4
|
+
var tn = ({ dt: e }) => `
|
|
5
|
+
.p-colorpicker {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.p-colorpicker-dragging {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.p-colorpicker-preview {
|
|
15
|
+
width: ${e("colorpicker.preview.width")};
|
|
16
|
+
height: ${e("colorpicker.preview.height")};
|
|
17
|
+
padding: 0;
|
|
18
|
+
border: 0 none;
|
|
19
|
+
border-radius: ${e("colorpicker.preview.border.radius")};
|
|
20
|
+
transition: background ${e("colorpicker.transition.duration")}, color ${e("colorpicker.transition.duration")}, border-color ${e("colorpicker.transition.duration")}, outline-color ${e("colorpicker.transition.duration")}, box-shadow ${e("colorpicker.transition.duration")};
|
|
21
|
+
outline-color: transparent;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.p-colorpicker-preview:enabled:focus-visible {
|
|
26
|
+
border-color: ${e("colorpicker.preview.focus.border.color")};
|
|
27
|
+
box-shadow: ${e("colorpicker.preview.focus.ring.shadow")};
|
|
28
|
+
outline: ${e("colorpicker.preview.focus.ring.width")} ${e("colorpicker.preview.focus.ring.style")} ${e("colorpicker.preview.focus.ring.color")};
|
|
29
|
+
outline-offset: ${e("colorpicker.preview.focus.ring.offset")};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.p-colorpicker-panel {
|
|
33
|
+
background: ${e("colorpicker.panel.background")};
|
|
34
|
+
border: 1px solid ${e("colorpicker.panel.border.color")};
|
|
35
|
+
border-radius: ${e("colorpicker.panel.border.radius")};
|
|
36
|
+
box-shadow: ${e("colorpicker.panel.shadow")};
|
|
37
|
+
width: 193px;
|
|
38
|
+
height: 166px;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0;
|
|
41
|
+
left: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.p-colorpicker-panel-inline {
|
|
45
|
+
box-shadow: none;
|
|
46
|
+
position: static;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.p-colorpicker-content {
|
|
50
|
+
position: relative;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.p-colorpicker-color-selector {
|
|
54
|
+
width: 150px;
|
|
55
|
+
height: 150px;
|
|
56
|
+
inset-block-start: 8px;
|
|
57
|
+
inset-inline-start: 8px;
|
|
58
|
+
position: absolute;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.p-colorpicker-color-background {
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 100%;
|
|
64
|
+
background: linear-gradient(to top, #000 0%, rgba(0, 0, 0, 0) 100%), linear-gradient(to right, #fff 0%, rgba(255, 255, 255, 0) 100%);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.p-colorpicker-color-handle {
|
|
68
|
+
position: absolute;
|
|
69
|
+
inset-block-start: 0px;
|
|
70
|
+
inset-inline-start: 150px;
|
|
71
|
+
border-radius: 100%;
|
|
72
|
+
width: 10px;
|
|
73
|
+
height: 10px;
|
|
74
|
+
border-width: 1px;
|
|
75
|
+
border-style: solid;
|
|
76
|
+
margin: -5px 0 0 -5px;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
opacity: 0.85;
|
|
79
|
+
border-color: ${e("colorpicker.handle.color")};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.p-colorpicker-hue {
|
|
83
|
+
width: 17px;
|
|
84
|
+
height: 150px;
|
|
85
|
+
inset-block-start: 8px;
|
|
86
|
+
inset-inline-start: 167px;
|
|
87
|
+
position: absolute;
|
|
88
|
+
opacity: 0.85;
|
|
89
|
+
background: linear-gradient(0deg,
|
|
90
|
+
red 0,
|
|
91
|
+
#ff0 17%,
|
|
92
|
+
#0f0 33%,
|
|
93
|
+
#0ff 50%,
|
|
94
|
+
#00f 67%,
|
|
95
|
+
#f0f 83%,
|
|
96
|
+
red);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.p-colorpicker-hue-handle {
|
|
100
|
+
position: absolute;
|
|
101
|
+
inset-block-start: 150px;
|
|
102
|
+
inset-inline-start: 0px;
|
|
103
|
+
width: 21px;
|
|
104
|
+
margin-inline-start: -2px;
|
|
105
|
+
margin-block-start: -5px;
|
|
106
|
+
height: 10px;
|
|
107
|
+
border-width: 2px;
|
|
108
|
+
border-style: solid;
|
|
109
|
+
opacity: 0.85;
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
border-color: ${e("colorpicker.handle.color")};
|
|
112
|
+
}
|
|
113
|
+
`, on = {
|
|
114
|
+
root: "p-colorpicker p-component",
|
|
115
|
+
preview: function(n) {
|
|
116
|
+
var t = n.props;
|
|
117
|
+
return ["p-colorpicker-preview", {
|
|
118
|
+
"p-disabled": t.disabled
|
|
119
|
+
}];
|
|
120
|
+
},
|
|
121
|
+
panel: function(n) {
|
|
122
|
+
var t = n.instance, o = n.props;
|
|
123
|
+
return ["p-colorpicker-panel", {
|
|
124
|
+
"p-colorpicker-panel-inline": o.inline,
|
|
125
|
+
"p-disabled": o.disabled,
|
|
126
|
+
"p-invalid": t.$invalid
|
|
127
|
+
}];
|
|
128
|
+
},
|
|
129
|
+
colorSelector: "p-colorpicker-color-selector",
|
|
130
|
+
colorBackground: "p-colorpicker-color-background",
|
|
131
|
+
colorHandle: "p-colorpicker-color-handle",
|
|
132
|
+
hue: "p-colorpicker-hue",
|
|
133
|
+
hueHandle: "p-colorpicker-hue-handle"
|
|
134
|
+
}, ln = Ne.extend({
|
|
135
|
+
name: "colorpicker",
|
|
136
|
+
style: tn,
|
|
137
|
+
classes: on
|
|
138
|
+
}), rn = {
|
|
139
|
+
name: "BaseColorPicker",
|
|
140
|
+
extends: Ge,
|
|
141
|
+
props: {
|
|
142
|
+
defaultColor: {
|
|
143
|
+
type: null,
|
|
144
|
+
default: "ff0000"
|
|
145
|
+
},
|
|
146
|
+
inline: {
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: !1
|
|
149
|
+
},
|
|
150
|
+
format: {
|
|
151
|
+
type: String,
|
|
152
|
+
default: "hex"
|
|
153
|
+
},
|
|
154
|
+
tabindex: {
|
|
155
|
+
type: String,
|
|
156
|
+
default: null
|
|
157
|
+
},
|
|
158
|
+
autoZIndex: {
|
|
159
|
+
type: Boolean,
|
|
160
|
+
default: !0
|
|
161
|
+
},
|
|
162
|
+
baseZIndex: {
|
|
163
|
+
type: Number,
|
|
164
|
+
default: 0
|
|
165
|
+
},
|
|
166
|
+
appendTo: {
|
|
167
|
+
type: [String, Object],
|
|
168
|
+
default: "body"
|
|
169
|
+
},
|
|
170
|
+
inputId: {
|
|
171
|
+
type: String,
|
|
172
|
+
default: null
|
|
173
|
+
},
|
|
174
|
+
panelClass: null,
|
|
175
|
+
overlayClass: null
|
|
176
|
+
},
|
|
177
|
+
style: ln,
|
|
178
|
+
provide: function() {
|
|
179
|
+
return {
|
|
180
|
+
$pcColorPicker: this,
|
|
181
|
+
$parentInstance: this
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}, Ie = {
|
|
185
|
+
name: "ColorPicker",
|
|
186
|
+
extends: rn,
|
|
187
|
+
inheritAttrs: !1,
|
|
188
|
+
emits: ["change", "show", "hide"],
|
|
189
|
+
data: function() {
|
|
190
|
+
return {
|
|
191
|
+
overlayVisible: !1
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
hsbValue: null,
|
|
195
|
+
localHue: null,
|
|
196
|
+
outsideClickListener: null,
|
|
197
|
+
documentMouseMoveListener: null,
|
|
198
|
+
documentMouseUpListener: null,
|
|
199
|
+
scrollHandler: null,
|
|
200
|
+
resizeListener: null,
|
|
201
|
+
hueDragging: null,
|
|
202
|
+
colorDragging: null,
|
|
203
|
+
selfUpdate: null,
|
|
204
|
+
picker: null,
|
|
205
|
+
colorSelector: null,
|
|
206
|
+
colorHandle: null,
|
|
207
|
+
hueView: null,
|
|
208
|
+
hueHandle: null,
|
|
209
|
+
watch: {
|
|
210
|
+
modelValue: {
|
|
211
|
+
immediate: !0,
|
|
212
|
+
handler: function(n) {
|
|
213
|
+
this.hsbValue = this.toHSB(n), this.selfUpdate ? this.selfUpdate = !1 : this.updateUI();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
beforeUnmount: function() {
|
|
218
|
+
this.unbindOutsideClickListener(), this.unbindDragListeners(), this.unbindResizeListener(), this.scrollHandler && (this.scrollHandler.destroy(), this.scrollHandler = null), this.picker && this.autoZIndex && Y.clear(this.picker), this.clearRefs();
|
|
219
|
+
},
|
|
220
|
+
mounted: function() {
|
|
221
|
+
this.updateUI();
|
|
222
|
+
},
|
|
223
|
+
methods: {
|
|
224
|
+
pickColor: function(n) {
|
|
225
|
+
var t = this.colorSelector.getBoundingClientRect(), o = t.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0), l = t.left + document.body.scrollLeft, i = Math.floor(100 * Math.max(0, Math.min(150, (n.pageX || n.changedTouches[0].pageX) - l)) / 150), u = Math.floor(100 * (150 - Math.max(0, Math.min(150, (n.pageY || n.changedTouches[0].pageY) - o))) / 150);
|
|
226
|
+
this.hsbValue = this.validateHSB({
|
|
227
|
+
h: this.localHue,
|
|
228
|
+
s: i,
|
|
229
|
+
b: u
|
|
230
|
+
}), this.selfUpdate = !0, this.updateColorHandle(), this.updateInput(), this.updateModel(n);
|
|
231
|
+
},
|
|
232
|
+
pickHue: function(n) {
|
|
233
|
+
var t = this.hueView.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
|
|
234
|
+
this.localHue = Math.floor(360 * (150 - Math.max(0, Math.min(150, (n.pageY || n.changedTouches[0].pageY) - t))) / 150), this.hsbValue = this.validateHSB({
|
|
235
|
+
h: this.localHue,
|
|
236
|
+
s: 100,
|
|
237
|
+
b: 100
|
|
238
|
+
}), this.selfUpdate = !0, this.updateColorSelector(), this.updateHue(), this.updateModel(n), this.updateInput();
|
|
239
|
+
},
|
|
240
|
+
updateModel: function(n) {
|
|
241
|
+
var t = this.d_value;
|
|
242
|
+
switch (this.format) {
|
|
243
|
+
case "hex":
|
|
244
|
+
t = this.HSBtoHEX(this.hsbValue);
|
|
245
|
+
break;
|
|
246
|
+
case "rgb":
|
|
247
|
+
t = this.HSBtoRGB(this.hsbValue);
|
|
248
|
+
break;
|
|
249
|
+
case "hsb":
|
|
250
|
+
t = this.hsbValue;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
this.writeValue(t, n), this.$emit("change", {
|
|
254
|
+
event: n,
|
|
255
|
+
value: t
|
|
256
|
+
});
|
|
257
|
+
},
|
|
258
|
+
updateColorSelector: function() {
|
|
259
|
+
if (this.colorSelector) {
|
|
260
|
+
var n = this.validateHSB({
|
|
261
|
+
h: this.hsbValue.h,
|
|
262
|
+
s: 100,
|
|
263
|
+
b: 100
|
|
264
|
+
});
|
|
265
|
+
this.colorSelector.style.backgroundColor = "#" + this.HSBtoHEX(n);
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
updateColorHandle: function() {
|
|
269
|
+
this.colorHandle && (this.colorHandle.style.left = Math.floor(150 * this.hsbValue.s / 100) + "px", this.colorHandle.style.top = Math.floor(150 * (100 - this.hsbValue.b) / 100) + "px");
|
|
270
|
+
},
|
|
271
|
+
updateHue: function() {
|
|
272
|
+
this.hueHandle && (this.hueHandle.style.top = Math.floor(150 - 150 * this.hsbValue.h / 360) + "px");
|
|
273
|
+
},
|
|
274
|
+
updateInput: function() {
|
|
275
|
+
this.$refs.input && (this.$refs.input.style.backgroundColor = "#" + this.HSBtoHEX(this.hsbValue));
|
|
276
|
+
},
|
|
277
|
+
updateUI: function() {
|
|
278
|
+
this.updateHue(), this.updateColorHandle(), this.updateInput(), this.updateColorSelector();
|
|
279
|
+
},
|
|
280
|
+
validateHSB: function(n) {
|
|
281
|
+
return {
|
|
282
|
+
h: Math.min(360, Math.max(0, n.h)),
|
|
283
|
+
s: Math.min(100, Math.max(0, n.s)),
|
|
284
|
+
b: Math.min(100, Math.max(0, n.b))
|
|
285
|
+
};
|
|
286
|
+
},
|
|
287
|
+
validateRGB: function(n) {
|
|
288
|
+
return {
|
|
289
|
+
r: Math.min(255, Math.max(0, n.r)),
|
|
290
|
+
g: Math.min(255, Math.max(0, n.g)),
|
|
291
|
+
b: Math.min(255, Math.max(0, n.b))
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
validateHEX: function(n) {
|
|
295
|
+
var t = 6 - n.length;
|
|
296
|
+
if (t > 0) {
|
|
297
|
+
for (var o = [], l = 0; l < t; l++)
|
|
298
|
+
o.push("0");
|
|
299
|
+
o.push(n), n = o.join("");
|
|
300
|
+
}
|
|
301
|
+
return n;
|
|
302
|
+
},
|
|
303
|
+
HEXtoRGB: function(n) {
|
|
304
|
+
var t = parseInt(n.indexOf("#") > -1 ? n.substring(1) : n, 16);
|
|
305
|
+
return {
|
|
306
|
+
r: t >> 16,
|
|
307
|
+
g: (t & 65280) >> 8,
|
|
308
|
+
b: t & 255
|
|
309
|
+
};
|
|
310
|
+
},
|
|
311
|
+
HEXtoHSB: function(n) {
|
|
312
|
+
return this.RGBtoHSB(this.HEXtoRGB(n));
|
|
313
|
+
},
|
|
314
|
+
RGBtoHSB: function(n) {
|
|
315
|
+
var t = {
|
|
316
|
+
h: 0,
|
|
317
|
+
s: 0,
|
|
318
|
+
b: 0
|
|
319
|
+
}, o = Math.min(n.r, n.g, n.b), l = Math.max(n.r, n.g, n.b), i = l - o;
|
|
320
|
+
return t.b = l, t.s = l !== 0 ? 255 * i / l : 0, t.s !== 0 ? n.r === l ? t.h = (n.g - n.b) / i : n.g === l ? t.h = 2 + (n.b - n.r) / i : t.h = 4 + (n.r - n.g) / i : t.h = -1, t.h *= 60, t.h < 0 && (t.h += 360), t.s *= 100 / 255, t.b *= 100 / 255, t;
|
|
321
|
+
},
|
|
322
|
+
HSBtoRGB: function(n) {
|
|
323
|
+
var t = {
|
|
324
|
+
r: null,
|
|
325
|
+
g: null,
|
|
326
|
+
b: null
|
|
327
|
+
}, o = Math.round(n.h), l = Math.round(n.s * 255 / 100), i = Math.round(n.b * 255 / 100);
|
|
328
|
+
if (l === 0)
|
|
329
|
+
t = {
|
|
330
|
+
r: i,
|
|
331
|
+
g: i,
|
|
332
|
+
b: i
|
|
333
|
+
};
|
|
334
|
+
else {
|
|
335
|
+
var u = i, r = (255 - l) * i / 255, v = (u - r) * (o % 60) / 60;
|
|
336
|
+
o === 360 && (o = 0), o < 60 ? (t.r = u, t.b = r, t.g = r + v) : o < 120 ? (t.g = u, t.b = r, t.r = u - v) : o < 180 ? (t.g = u, t.r = r, t.b = r + v) : o < 240 ? (t.b = u, t.r = r, t.g = u - v) : o < 300 ? (t.b = u, t.g = r, t.r = r + v) : o < 360 ? (t.r = u, t.g = r, t.b = u - v) : (t.r = 0, t.g = 0, t.b = 0);
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
r: Math.round(t.r),
|
|
340
|
+
g: Math.round(t.g),
|
|
341
|
+
b: Math.round(t.b)
|
|
342
|
+
};
|
|
343
|
+
},
|
|
344
|
+
RGBtoHEX: function(n) {
|
|
345
|
+
var t = [n.r.toString(16), n.g.toString(16), n.b.toString(16)];
|
|
346
|
+
for (var o in t)
|
|
347
|
+
t[o].length === 1 && (t[o] = "0" + t[o]);
|
|
348
|
+
return t.join("");
|
|
349
|
+
},
|
|
350
|
+
HSBtoHEX: function(n) {
|
|
351
|
+
return this.RGBtoHEX(this.HSBtoRGB(n));
|
|
352
|
+
},
|
|
353
|
+
toHSB: function(n) {
|
|
354
|
+
var t;
|
|
355
|
+
if (n)
|
|
356
|
+
switch (this.format) {
|
|
357
|
+
case "hex":
|
|
358
|
+
t = this.HEXtoHSB(n);
|
|
359
|
+
break;
|
|
360
|
+
case "rgb":
|
|
361
|
+
t = this.RGBtoHSB(n);
|
|
362
|
+
break;
|
|
363
|
+
case "hsb":
|
|
364
|
+
t = n;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
else
|
|
368
|
+
t = this.HEXtoHSB(this.defaultColor);
|
|
369
|
+
return this.localHue == null || !this.overlayVisible ? this.localHue = t.h : t.h = this.localHue, t;
|
|
370
|
+
},
|
|
371
|
+
onOverlayEnter: function(n) {
|
|
372
|
+
this.updateUI(), this.alignOverlay(), this.bindOutsideClickListener(), this.bindScrollListener(), this.bindResizeListener(), this.autoZIndex && Y.set("overlay", n, this.baseZIndex, this.$primevue.config.zIndex.overlay), this.$emit("show");
|
|
373
|
+
},
|
|
374
|
+
onOverlayLeave: function() {
|
|
375
|
+
this.unbindOutsideClickListener(), this.unbindScrollListener(), this.unbindResizeListener(), this.clearRefs(), this.$emit("hide");
|
|
376
|
+
},
|
|
377
|
+
onOverlayAfterLeave: function(n) {
|
|
378
|
+
this.autoZIndex && Y.clear(n);
|
|
379
|
+
},
|
|
380
|
+
alignOverlay: function() {
|
|
381
|
+
this.appendTo === "self" ? Je(this.picker, this.$refs.input) : Qe(this.picker, this.$refs.input);
|
|
382
|
+
},
|
|
383
|
+
onInputClick: function() {
|
|
384
|
+
this.disabled || (this.overlayVisible = !this.overlayVisible);
|
|
385
|
+
},
|
|
386
|
+
onInputKeydown: function(n) {
|
|
387
|
+
switch (n.code) {
|
|
388
|
+
case "Space":
|
|
389
|
+
this.overlayVisible = !this.overlayVisible, n.preventDefault();
|
|
390
|
+
break;
|
|
391
|
+
case "Escape":
|
|
392
|
+
case "Tab":
|
|
393
|
+
this.overlayVisible = !1;
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
onInputBlur: function(n) {
|
|
398
|
+
var t, o;
|
|
399
|
+
(t = (o = this.formField).onBlur) === null || t === void 0 || t.call(o);
|
|
400
|
+
},
|
|
401
|
+
onColorMousedown: function(n) {
|
|
402
|
+
this.disabled || (this.bindDragListeners(), this.onColorDragStart(n));
|
|
403
|
+
},
|
|
404
|
+
onColorDragStart: function(n) {
|
|
405
|
+
this.disabled || (this.colorDragging = !0, this.pickColor(n), this.$el.setAttribute("p-colorpicker-dragging", "true"), !this.isUnstyled && ae(this.$el, "p-colorpicker-dragging"), n.preventDefault());
|
|
406
|
+
},
|
|
407
|
+
onDrag: function(n) {
|
|
408
|
+
this.colorDragging && (this.pickColor(n), n.preventDefault()), this.hueDragging && (this.pickHue(n), n.preventDefault());
|
|
409
|
+
},
|
|
410
|
+
onDragEnd: function() {
|
|
411
|
+
this.colorDragging = !1, this.hueDragging = !1, this.$el.setAttribute("p-colorpicker-dragging", "false"), !this.isUnstyled && qe(this.$el, "p-colorpicker-dragging"), this.unbindDragListeners();
|
|
412
|
+
},
|
|
413
|
+
onHueMousedown: function(n) {
|
|
414
|
+
this.disabled || (this.bindDragListeners(), this.onHueDragStart(n));
|
|
415
|
+
},
|
|
416
|
+
onHueDragStart: function(n) {
|
|
417
|
+
this.disabled || (this.hueDragging = !0, this.pickHue(n), !this.isUnstyled && ae(this.$el, "p-colorpicker-dragging"));
|
|
418
|
+
},
|
|
419
|
+
isInputClicked: function(n) {
|
|
420
|
+
return this.$refs.input && this.$refs.input.isSameNode(n.target);
|
|
421
|
+
},
|
|
422
|
+
bindDragListeners: function() {
|
|
423
|
+
this.bindDocumentMouseMoveListener(), this.bindDocumentMouseUpListener();
|
|
424
|
+
},
|
|
425
|
+
unbindDragListeners: function() {
|
|
426
|
+
this.unbindDocumentMouseMoveListener(), this.unbindDocumentMouseUpListener();
|
|
427
|
+
},
|
|
428
|
+
bindOutsideClickListener: function() {
|
|
429
|
+
var n = this;
|
|
430
|
+
this.outsideClickListener || (this.outsideClickListener = function(t) {
|
|
431
|
+
n.overlayVisible && n.picker && !n.picker.contains(t.target) && !n.isInputClicked(t) && (n.overlayVisible = !1);
|
|
432
|
+
}, document.addEventListener("click", this.outsideClickListener, !0));
|
|
433
|
+
},
|
|
434
|
+
unbindOutsideClickListener: function() {
|
|
435
|
+
this.outsideClickListener && (document.removeEventListener("click", this.outsideClickListener, !0), this.outsideClickListener = null);
|
|
436
|
+
},
|
|
437
|
+
bindScrollListener: function() {
|
|
438
|
+
var n = this;
|
|
439
|
+
this.scrollHandler || (this.scrollHandler = new We(this.$refs.container, function() {
|
|
440
|
+
n.overlayVisible && (n.overlayVisible = !1);
|
|
441
|
+
})), this.scrollHandler.bindScrollListener();
|
|
442
|
+
},
|
|
443
|
+
unbindScrollListener: function() {
|
|
444
|
+
this.scrollHandler && this.scrollHandler.unbindScrollListener();
|
|
445
|
+
},
|
|
446
|
+
bindResizeListener: function() {
|
|
447
|
+
var n = this;
|
|
448
|
+
this.resizeListener || (this.resizeListener = function() {
|
|
449
|
+
n.overlayVisible && !Ke() && (n.overlayVisible = !1);
|
|
450
|
+
}, window.addEventListener("resize", this.resizeListener));
|
|
451
|
+
},
|
|
452
|
+
unbindResizeListener: function() {
|
|
453
|
+
this.resizeListener && (window.removeEventListener("resize", this.resizeListener), this.resizeListener = null);
|
|
454
|
+
},
|
|
455
|
+
bindDocumentMouseMoveListener: function() {
|
|
456
|
+
this.documentMouseMoveListener || (this.documentMouseMoveListener = this.onDrag.bind(this), document.addEventListener("mousemove", this.documentMouseMoveListener));
|
|
457
|
+
},
|
|
458
|
+
unbindDocumentMouseMoveListener: function() {
|
|
459
|
+
this.documentMouseMoveListener && (document.removeEventListener("mousemove", this.documentMouseMoveListener), this.documentMouseMoveListener = null);
|
|
460
|
+
},
|
|
461
|
+
bindDocumentMouseUpListener: function() {
|
|
462
|
+
this.documentMouseUpListener || (this.documentMouseUpListener = this.onDragEnd.bind(this), document.addEventListener("mouseup", this.documentMouseUpListener));
|
|
463
|
+
},
|
|
464
|
+
unbindDocumentMouseUpListener: function() {
|
|
465
|
+
this.documentMouseUpListener && (document.removeEventListener("mouseup", this.documentMouseUpListener), this.documentMouseUpListener = null);
|
|
466
|
+
},
|
|
467
|
+
pickerRef: function(n) {
|
|
468
|
+
this.picker = n;
|
|
469
|
+
},
|
|
470
|
+
colorSelectorRef: function(n) {
|
|
471
|
+
this.colorSelector = n;
|
|
472
|
+
},
|
|
473
|
+
colorHandleRef: function(n) {
|
|
474
|
+
this.colorHandle = n;
|
|
475
|
+
},
|
|
476
|
+
hueViewRef: function(n) {
|
|
477
|
+
this.hueView = n;
|
|
478
|
+
},
|
|
479
|
+
hueHandleRef: function(n) {
|
|
480
|
+
this.hueHandle = n;
|
|
481
|
+
},
|
|
482
|
+
clearRefs: function() {
|
|
483
|
+
this.picker = null, this.colorSelector = null, this.colorHandle = null, this.hueView = null, this.hueHandle = null;
|
|
484
|
+
},
|
|
485
|
+
onOverlayClick: function(n) {
|
|
486
|
+
Ye.emit("overlay-click", {
|
|
487
|
+
originalEvent: n,
|
|
488
|
+
target: this.$el
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
components: {
|
|
493
|
+
Portal: je
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
function A(e) {
|
|
497
|
+
"@babel/helpers - typeof";
|
|
498
|
+
return A = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
499
|
+
return typeof n;
|
|
500
|
+
} : function(n) {
|
|
501
|
+
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
502
|
+
}, A(e);
|
|
503
|
+
}
|
|
504
|
+
function ue(e, n) {
|
|
505
|
+
var t = Object.keys(e);
|
|
506
|
+
if (Object.getOwnPropertySymbols) {
|
|
507
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
508
|
+
n && (o = o.filter(function(l) {
|
|
509
|
+
return Object.getOwnPropertyDescriptor(e, l).enumerable;
|
|
510
|
+
})), t.push.apply(t, o);
|
|
511
|
+
}
|
|
512
|
+
return t;
|
|
513
|
+
}
|
|
514
|
+
function ce(e) {
|
|
515
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
516
|
+
var t = arguments[n] != null ? arguments[n] : {};
|
|
517
|
+
n % 2 ? ue(Object(t), !0).forEach(function(o) {
|
|
518
|
+
an(e, o, t[o]);
|
|
519
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ue(Object(t)).forEach(function(o) {
|
|
520
|
+
Object.defineProperty(e, o, Object.getOwnPropertyDescriptor(t, o));
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
return e;
|
|
524
|
+
}
|
|
525
|
+
function an(e, n, t) {
|
|
526
|
+
return (n = sn(n)) in e ? Object.defineProperty(e, n, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[n] = t, e;
|
|
527
|
+
}
|
|
528
|
+
function sn(e) {
|
|
529
|
+
var n = un(e, "string");
|
|
530
|
+
return A(n) == "symbol" ? n : n + "";
|
|
531
|
+
}
|
|
532
|
+
function un(e, n) {
|
|
533
|
+
if (A(e) != "object" || !e) return e;
|
|
534
|
+
var t = e[Symbol.toPrimitive];
|
|
535
|
+
if (t !== void 0) {
|
|
536
|
+
var o = t.call(e, n);
|
|
537
|
+
if (A(o) != "object") return o;
|
|
538
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
539
|
+
}
|
|
540
|
+
return (n === "string" ? String : Number)(e);
|
|
541
|
+
}
|
|
542
|
+
var cn = ["id", "tabindex", "disabled"];
|
|
543
|
+
function dn(e, n, t, o, l, i) {
|
|
544
|
+
var u = T("Portal");
|
|
545
|
+
return d(), m("div", P({
|
|
546
|
+
ref: "container",
|
|
547
|
+
class: e.cx("root")
|
|
548
|
+
}, e.ptmi("root")), [e.inline ? k("", !0) : (d(), m("input", P({
|
|
549
|
+
key: 0,
|
|
550
|
+
ref: "input",
|
|
551
|
+
id: e.inputId,
|
|
552
|
+
type: "text",
|
|
553
|
+
class: e.cx("preview"),
|
|
554
|
+
readonly: "",
|
|
555
|
+
tabindex: e.tabindex,
|
|
556
|
+
disabled: e.disabled,
|
|
557
|
+
onClick: n[0] || (n[0] = function() {
|
|
558
|
+
return i.onInputClick && i.onInputClick.apply(i, arguments);
|
|
559
|
+
}),
|
|
560
|
+
onKeydown: n[1] || (n[1] = function() {
|
|
561
|
+
return i.onInputKeydown && i.onInputKeydown.apply(i, arguments);
|
|
562
|
+
}),
|
|
563
|
+
onBlur: n[2] || (n[2] = function() {
|
|
564
|
+
return i.onInputBlur && i.onInputBlur.apply(i, arguments);
|
|
565
|
+
})
|
|
566
|
+
}, e.ptm("preview")), null, 16, cn)), C(u, {
|
|
567
|
+
appendTo: e.appendTo,
|
|
568
|
+
disabled: e.inline
|
|
569
|
+
}, {
|
|
570
|
+
default: U(function() {
|
|
571
|
+
return [C(Ue, P({
|
|
572
|
+
name: "p-connected-overlay",
|
|
573
|
+
onEnter: i.onOverlayEnter,
|
|
574
|
+
onLeave: i.onOverlayLeave,
|
|
575
|
+
onAfterLeave: i.onOverlayAfterLeave
|
|
576
|
+
}, e.ptm("transition")), {
|
|
577
|
+
default: U(function() {
|
|
578
|
+
return [e.inline || l.overlayVisible ? (d(), m("div", P({
|
|
579
|
+
key: 0,
|
|
580
|
+
ref: i.pickerRef,
|
|
581
|
+
class: [e.cx("panel"), e.panelClass, e.overlayClass],
|
|
582
|
+
onClick: n[11] || (n[11] = function() {
|
|
583
|
+
return i.onOverlayClick && i.onOverlayClick.apply(i, arguments);
|
|
584
|
+
})
|
|
585
|
+
}, ce(ce({}, e.ptm("panel")), e.ptm("overlay"))), [L("div", P({
|
|
586
|
+
class: e.cx("content")
|
|
587
|
+
}, e.ptm("content")), [L("div", P({
|
|
588
|
+
ref: i.colorSelectorRef,
|
|
589
|
+
class: e.cx("colorSelector"),
|
|
590
|
+
onMousedown: n[3] || (n[3] = function(r) {
|
|
591
|
+
return i.onColorMousedown(r);
|
|
592
|
+
}),
|
|
593
|
+
onTouchstart: n[4] || (n[4] = function(r) {
|
|
594
|
+
return i.onColorDragStart(r);
|
|
595
|
+
}),
|
|
596
|
+
onTouchmove: n[5] || (n[5] = function(r) {
|
|
597
|
+
return i.onDrag(r);
|
|
598
|
+
}),
|
|
599
|
+
onTouchend: n[6] || (n[6] = function(r) {
|
|
600
|
+
return i.onDragEnd();
|
|
601
|
+
})
|
|
602
|
+
}, e.ptm("colorSelector")), [L("div", P({
|
|
603
|
+
class: e.cx("colorBackground")
|
|
604
|
+
}, e.ptm("colorBackground")), [L("div", P({
|
|
605
|
+
ref: i.colorHandleRef,
|
|
606
|
+
class: e.cx("colorHandle")
|
|
607
|
+
}, e.ptm("colorHandle")), null, 16)], 16)], 16), L("div", P({
|
|
608
|
+
ref: i.hueViewRef,
|
|
609
|
+
class: e.cx("hue"),
|
|
610
|
+
onMousedown: n[7] || (n[7] = function(r) {
|
|
611
|
+
return i.onHueMousedown(r);
|
|
612
|
+
}),
|
|
613
|
+
onTouchstart: n[8] || (n[8] = function(r) {
|
|
614
|
+
return i.onHueDragStart(r);
|
|
615
|
+
}),
|
|
616
|
+
onTouchmove: n[9] || (n[9] = function(r) {
|
|
617
|
+
return i.onDrag(r);
|
|
618
|
+
}),
|
|
619
|
+
onTouchend: n[10] || (n[10] = function(r) {
|
|
620
|
+
return i.onDragEnd();
|
|
621
|
+
})
|
|
622
|
+
}, e.ptm("hue")), [L("div", P({
|
|
623
|
+
ref: i.hueHandleRef,
|
|
624
|
+
class: e.cx("hueHandle")
|
|
625
|
+
}, e.ptm("hueHandle")), null, 16)], 16)], 16)], 16)) : k("", !0)];
|
|
626
|
+
}),
|
|
627
|
+
_: 1
|
|
628
|
+
}, 16, ["onEnter", "onLeave", "onAfterLeave"])];
|
|
629
|
+
}),
|
|
630
|
+
_: 1
|
|
631
|
+
}, 8, ["appendTo", "disabled"])], 16);
|
|
632
|
+
}
|
|
633
|
+
Ie.render = dn;
|
|
634
|
+
const W = "000000", Me = 7, fn = 4, de = "image/jpeg", hn = "canvas.jpg", fe = 0.25, he = 4, ve = 0.25, vn = (e, n) => {
|
|
635
|
+
const { width: t, height: o } = q(n), { width: l, height: i } = q(e), u = l / t, r = i / o;
|
|
636
|
+
return Math.min(u, r, 1);
|
|
637
|
+
}, q = ({ width: e = 0, height: n = 0 } = {}) => ({
|
|
638
|
+
width: Math.max(1, e),
|
|
639
|
+
height: Math.max(1, n)
|
|
640
|
+
}), pe = async (e, n, t) => {
|
|
641
|
+
if (n <= 0)
|
|
642
|
+
return null;
|
|
643
|
+
const o = await e.toBlob({
|
|
644
|
+
pixelRatio: 1 / n,
|
|
645
|
+
mimeType: de,
|
|
646
|
+
quality: 0.9,
|
|
647
|
+
// Visible quality to 100% but lowers file size significantly.
|
|
648
|
+
...t
|
|
649
|
+
});
|
|
650
|
+
return o ? new File([o], hn, { type: de }) : null;
|
|
651
|
+
}, pn = (e, n) => {
|
|
652
|
+
const t = n.getClientRect({ relativeTo: e }), o = Math.max(0, t.x), l = Math.max(0, t.y), i = Math.min(e.width(), t.x + t.width) - o, u = Math.min(e.height(), t.y + t.height) - l;
|
|
653
|
+
return i <= 0 || u <= 0 ? null : { x: o, y: l, width: i, height: u };
|
|
654
|
+
}, me = (e, n) => ({
|
|
655
|
+
points: e,
|
|
656
|
+
stroke: n,
|
|
657
|
+
strokeWidth: Me,
|
|
658
|
+
lineCap: "round",
|
|
659
|
+
lineJoin: "round",
|
|
660
|
+
tension: 0
|
|
661
|
+
}), Le = (e) => ({ x: e.clientX, y: e.clientY }), K = (e) => e && !e.isPrimary, F = (e) => {
|
|
662
|
+
e.rafId !== null && (cancelAnimationFrame(e.rafId), e.rafId = null);
|
|
663
|
+
}, mn = (e) => {
|
|
664
|
+
const n = e.stage?.getPointerPosition();
|
|
665
|
+
return n ? { x: n.x * e.scaleInv, y: n.y * e.scaleInv } : null;
|
|
666
|
+
}, gn = (e, n, t) => {
|
|
667
|
+
if (!n.value)
|
|
668
|
+
return;
|
|
669
|
+
const o = Le(e.evt);
|
|
670
|
+
t.active = !0, t.lastX = o.x, t.lastY = o.y;
|
|
671
|
+
}, bn = (e, n, t, o) => {
|
|
672
|
+
if (t.hasBackgroundImage && !t.imageEl.value)
|
|
673
|
+
return;
|
|
674
|
+
F(e), e.stage = t.stageRef.value?.getNode() ?? null, e.scaleInv = 1 / o.value;
|
|
675
|
+
const l = mn(e);
|
|
676
|
+
l && (e.active = !0, e.livePoints = [l.x, l.y, l.x, l.y], n.value = e.livePoints.slice());
|
|
677
|
+
}, kn = (e, n, t) => {
|
|
678
|
+
if (!t.value)
|
|
679
|
+
return;
|
|
680
|
+
const o = Le(e);
|
|
681
|
+
t.value.scrollLeft += n.lastX - o.x, t.value.scrollTop += n.lastY - o.y, n.lastX = o.x, n.lastY = o.y;
|
|
682
|
+
}, yn = (e, n) => {
|
|
683
|
+
const t = e.stage?.getPointerPosition();
|
|
684
|
+
t && (e.livePoints.push(t.x * e.scaleInv, t.y * e.scaleInv), e.rafId ??= requestAnimationFrame(() => {
|
|
685
|
+
n.value = e.livePoints.slice(), e.rafId = null;
|
|
686
|
+
}));
|
|
687
|
+
}, Sn = (e, n, t) => {
|
|
688
|
+
n.value = [], t.value = [], e.active = !1, e.livePoints = [], F(e);
|
|
689
|
+
}, Cn = (e) => {
|
|
690
|
+
const n = j([]), t = j([]), o = j(1), l = w(
|
|
691
|
+
() => vn(e.containerSize.value, e.imageSize.value)
|
|
692
|
+
), i = w(() => l.value * o.value), u = w(() => o.value >= he), r = w(() => o.value <= fe), v = w(
|
|
693
|
+
() => me(t.value, e.activeColor.value)
|
|
694
|
+
), h = {
|
|
695
|
+
active: !1,
|
|
696
|
+
livePoints: [],
|
|
697
|
+
rafId: null,
|
|
698
|
+
stage: null,
|
|
699
|
+
scaleInv: 1,
|
|
700
|
+
nextStrokeId: 0
|
|
701
|
+
}, I = {
|
|
702
|
+
active: !1,
|
|
703
|
+
lastX: 0,
|
|
704
|
+
lastY: 0
|
|
705
|
+
}, E = () => {
|
|
706
|
+
n.value.length && (n.value = [], e.onStrokeCommitted());
|
|
707
|
+
}, M = () => {
|
|
708
|
+
n.value.length && (n.value = n.value.slice(0, -1), e.onStrokeCommitted());
|
|
709
|
+
}, b = () => {
|
|
710
|
+
if (h.livePoints.length < fn)
|
|
711
|
+
return;
|
|
712
|
+
const c = {
|
|
713
|
+
id: h.nextStrokeId++,
|
|
714
|
+
config: me([...h.livePoints], e.activeColor.value)
|
|
715
|
+
};
|
|
716
|
+
n.value = [...n.value, c], e.onStrokeCommitted();
|
|
717
|
+
}, H = (c) => {
|
|
718
|
+
if (!K(c.evt)) {
|
|
719
|
+
if (I.active) {
|
|
720
|
+
I.active = !1;
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
h.active && (h.active = !1, F(h), b(), h.livePoints = [], t.value = []);
|
|
724
|
+
}
|
|
725
|
+
}, f = (c) => {
|
|
726
|
+
if (!K(c.evt)) {
|
|
727
|
+
if (I.active) {
|
|
728
|
+
kn(c.evt, I, e.containerRef);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
if (h.active) {
|
|
732
|
+
yn(h, t);
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}, y = (c) => {
|
|
737
|
+
if (c.evt.preventDefault(), !K(c.evt)) {
|
|
738
|
+
if (!e.isStrokeActive.value) {
|
|
739
|
+
gn(c, e.containerRef, I);
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
bn(h, t, e, i);
|
|
743
|
+
}
|
|
744
|
+
}, V = async () => {
|
|
745
|
+
const c = e.stageRef.value?.getNode();
|
|
746
|
+
if (!c)
|
|
747
|
+
return null;
|
|
748
|
+
if (e.hasBackgroundImage || e.imageEl.value)
|
|
749
|
+
return pe(c, l.value);
|
|
750
|
+
const O = e.strokesLayerRef.value?.getNode();
|
|
751
|
+
if (!O)
|
|
752
|
+
return null;
|
|
753
|
+
const D = pn(c, O);
|
|
754
|
+
return D ? pe(c, l.value, D) : null;
|
|
755
|
+
};
|
|
756
|
+
return ge(() => {
|
|
757
|
+
F(h), h.stage = null;
|
|
758
|
+
}), {
|
|
759
|
+
committedStrokes: n,
|
|
760
|
+
liveStrokePoints: t,
|
|
761
|
+
liveStrokeConfig: v,
|
|
762
|
+
effectiveScale: i,
|
|
763
|
+
isZoomInDisabled: u,
|
|
764
|
+
isZoomOutDisabled: r,
|
|
765
|
+
safeSize: (c) => q(c),
|
|
766
|
+
clearAll: () => E(),
|
|
767
|
+
flattenStage: () => V(),
|
|
768
|
+
resetDrawingState: () => Sn(h, n, t),
|
|
769
|
+
resetZoom: () => o.value = 1,
|
|
770
|
+
onPointerDown: (c) => y(c),
|
|
771
|
+
onPointerMove: (c) => f(c),
|
|
772
|
+
onPointerUp: (c) => H(c),
|
|
773
|
+
undo: () => M(),
|
|
774
|
+
zoomIn: () => o.value = Math.min(he, o.value + ve),
|
|
775
|
+
zoomOut: () => o.value = Math.max(fe, o.value - ve)
|
|
776
|
+
};
|
|
777
|
+
}, wn = { class: "control-bar-vertical" }, In = ["aria-label"], Mn = ["aria-label"], Ln = ["aria-label"], Hn = ["aria-label"], Pn = {
|
|
778
|
+
key: 0,
|
|
779
|
+
class: "control-bar-zoom"
|
|
780
|
+
}, Bn = ["aria-label", "disabled"], On = ["aria-label", "disabled"], Dn = {
|
|
781
|
+
key: 1,
|
|
782
|
+
class: "control-bar-horizontal"
|
|
783
|
+
}, xn = ["aria-label", "disabled"], En = ["aria-label", "disabled"], Rn = /* @__PURE__ */ be({
|
|
784
|
+
__name: "CanvasControls",
|
|
785
|
+
props: {
|
|
786
|
+
modeConfig: {},
|
|
787
|
+
disableClearAll: { type: Boolean },
|
|
788
|
+
disableUndo: { type: Boolean },
|
|
789
|
+
disableZoomIn: { type: Boolean },
|
|
790
|
+
disableZoomOut: { type: Boolean },
|
|
791
|
+
isBlankCanvas: { type: Boolean },
|
|
792
|
+
isFullScreen: { type: Boolean },
|
|
793
|
+
isPanActive: { type: Boolean }
|
|
794
|
+
},
|
|
795
|
+
emits: [
|
|
796
|
+
"changePan",
|
|
797
|
+
"changeColor",
|
|
798
|
+
"clearAll",
|
|
799
|
+
"closeFullScreen",
|
|
800
|
+
"undo",
|
|
801
|
+
"zoomIn",
|
|
802
|
+
"zoomOut"
|
|
803
|
+
],
|
|
804
|
+
setup(e, { emit: n }) {
|
|
805
|
+
const t = {
|
|
806
|
+
clearAll: "mdiTrashCanOutline",
|
|
807
|
+
closeFullScreen: "mdiArrowCollapse",
|
|
808
|
+
colorPicker: "mdiPalette",
|
|
809
|
+
exitAfterSave: "mdiCheck",
|
|
810
|
+
openInfo: "mdiInformationSlabCircleOutline",
|
|
811
|
+
pan: "mdiHandBackRightOutline",
|
|
812
|
+
undo: "mdiArrowULeftTop",
|
|
813
|
+
zoomIn: "mdiPlus",
|
|
814
|
+
zoomOut: "mdiMinus"
|
|
815
|
+
}, o = e, l = n, i = ke(Ce), u = S(), r = S(!1), v = S(W), h = S(!1), I = w(() => o.isBlankCanvas ? {
|
|
816
|
+
icon: t.closeFullScreen,
|
|
817
|
+
description: i("common_actions.close_full_screen.description"),
|
|
818
|
+
infoClasses: ["mobile-only"]
|
|
819
|
+
} : {
|
|
820
|
+
icon: t.exitAfterSave,
|
|
821
|
+
description: i("canvas_controls.exit_after_save.description"),
|
|
822
|
+
infoClasses: ["mobile-only"]
|
|
823
|
+
}), E = w(() => [
|
|
824
|
+
I.value,
|
|
825
|
+
{ icon: t.colorPicker, description: i("canvas_controls.color_picker.description") },
|
|
826
|
+
{ icon: t.pan, description: i("canvas_controls.pan.description") },
|
|
827
|
+
{ icon: t.zoomIn, description: i("common_actions.zoom_in.description") },
|
|
828
|
+
{ icon: t.zoomOut, description: i("common_actions.zoom_out.description") },
|
|
829
|
+
{ icon: t.clearAll, description: i("canvas_controls.clear_all.description") },
|
|
830
|
+
{ icon: t.undo, description: i("common_actions.undo.description") }
|
|
831
|
+
]), M = (H) => {
|
|
832
|
+
l("changePan", !1), v.value = H.value, l("changeColor", `#${v.value}`);
|
|
833
|
+
}, b = (H) => {
|
|
834
|
+
u.value && !u.value.contains(H.target) && (r.value = !1);
|
|
835
|
+
};
|
|
836
|
+
return ye(r, (H) => {
|
|
837
|
+
if (H) {
|
|
838
|
+
document.addEventListener("pointerdown", b);
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
document.removeEventListener("pointerdown", b);
|
|
842
|
+
}), Ae(() => {
|
|
843
|
+
document.removeEventListener("pointerdown", b);
|
|
844
|
+
}), (H, f) => (d(), m(Se, null, [
|
|
845
|
+
L("div", {
|
|
846
|
+
class: $(["control-bar", { "full-screen-active": e.isFullScreen }])
|
|
847
|
+
}, [
|
|
848
|
+
L("div", wn, [
|
|
849
|
+
e.isFullScreen ? (d(), m("button", {
|
|
850
|
+
key: 0,
|
|
851
|
+
"aria-label": I.value.description,
|
|
852
|
+
class: "close-fullscreen",
|
|
853
|
+
onClick: f[0] || (f[0] = (y) => l("closeFullScreen"))
|
|
854
|
+
}, [
|
|
855
|
+
C(x, {
|
|
856
|
+
name: I.value.icon
|
|
857
|
+
}, null, 8, ["name"])
|
|
858
|
+
], 8, In)) : k("", !0),
|
|
859
|
+
e.modeConfig.hasColorPicker ? (d(), m("button", {
|
|
860
|
+
key: 1,
|
|
861
|
+
"aria-label": a(i)("canvas_controls.color_picker.description"),
|
|
862
|
+
class: "color-picker-btn",
|
|
863
|
+
onClick: f[1] || (f[1] = (y) => r.value = !r.value)
|
|
864
|
+
}, [
|
|
865
|
+
v.value !== a(W) ? (d(), m("span", {
|
|
866
|
+
key: 0,
|
|
867
|
+
class: "color-swatch",
|
|
868
|
+
style: Ve({ background: `#${v.value}` })
|
|
869
|
+
}, null, 4)) : (d(), B(x, {
|
|
870
|
+
key: 1,
|
|
871
|
+
name: t.colorPicker
|
|
872
|
+
}, null, 8, ["name"]))
|
|
873
|
+
], 8, Mn)) : k("", !0),
|
|
874
|
+
e.modeConfig.hasPanToggle ? (d(), m("button", {
|
|
875
|
+
key: 2,
|
|
876
|
+
"aria-label": a(i)("canvas_controls.pan.description"),
|
|
877
|
+
class: $(["pan-btn", { "pan-active-btn": e.isPanActive }]),
|
|
878
|
+
onClick: f[2] || (f[2] = (y) => l("changePan", !e.isPanActive))
|
|
879
|
+
}, [
|
|
880
|
+
C(x, {
|
|
881
|
+
name: t.pan
|
|
882
|
+
}, null, 8, ["name"])
|
|
883
|
+
], 10, Ln)) : k("", !0),
|
|
884
|
+
e.modeConfig.hasInfoDialog ? (d(), m("button", {
|
|
885
|
+
key: 3,
|
|
886
|
+
"aria-label": a(i)("common_actions.open_info.description"),
|
|
887
|
+
class: "info-dialog",
|
|
888
|
+
onClick: f[3] || (f[3] = (y) => h.value = !0)
|
|
889
|
+
}, [
|
|
890
|
+
C(x, {
|
|
891
|
+
name: t.openInfo
|
|
892
|
+
}, null, 8, ["name"])
|
|
893
|
+
], 8, Hn)) : k("", !0)
|
|
894
|
+
]),
|
|
895
|
+
e.modeConfig.hasZoom ? (d(), m("div", Pn, [
|
|
896
|
+
L("button", {
|
|
897
|
+
"aria-label": a(i)("common_actions.zoom_in.description"),
|
|
898
|
+
disabled: e.disableZoomIn,
|
|
899
|
+
onClick: f[4] || (f[4] = (y) => l("zoomIn"))
|
|
900
|
+
}, [
|
|
901
|
+
C(x, {
|
|
902
|
+
name: t.zoomIn
|
|
903
|
+
}, null, 8, ["name"])
|
|
904
|
+
], 8, Bn),
|
|
905
|
+
L("button", {
|
|
906
|
+
"aria-label": a(i)("common_actions.zoom_out.description"),
|
|
907
|
+
disabled: e.disableZoomOut,
|
|
908
|
+
onClick: f[5] || (f[5] = (y) => l("zoomOut"))
|
|
909
|
+
}, [
|
|
910
|
+
C(x, {
|
|
911
|
+
name: t.zoomOut
|
|
912
|
+
}, null, 8, ["name"])
|
|
913
|
+
], 8, On)
|
|
914
|
+
])) : k("", !0),
|
|
915
|
+
e.modeConfig.hasDelete || e.modeConfig.hasUndo ? (d(), m("div", Dn, [
|
|
916
|
+
e.modeConfig.hasDelete ? (d(), m("button", {
|
|
917
|
+
key: 0,
|
|
918
|
+
"aria-label": a(i)("canvas_controls.clear_all.description"),
|
|
919
|
+
disabled: e.disableClearAll,
|
|
920
|
+
onClick: f[6] || (f[6] = (y) => l("clearAll"))
|
|
921
|
+
}, [
|
|
922
|
+
C(x, {
|
|
923
|
+
name: t.clearAll
|
|
924
|
+
}, null, 8, ["name"])
|
|
925
|
+
], 8, xn)) : k("", !0),
|
|
926
|
+
e.modeConfig.hasUndo ? (d(), m("button", {
|
|
927
|
+
key: 1,
|
|
928
|
+
"aria-label": a(i)("common_actions.undo.description"),
|
|
929
|
+
disabled: e.disableUndo,
|
|
930
|
+
onClick: f[7] || (f[7] = (y) => l("undo"))
|
|
931
|
+
}, [
|
|
932
|
+
C(x, {
|
|
933
|
+
name: t.undo
|
|
934
|
+
}, null, 8, ["name"])
|
|
935
|
+
], 8, En)) : k("", !0)
|
|
936
|
+
])) : k("", !0)
|
|
937
|
+
], 2),
|
|
938
|
+
r.value ? (d(), m("div", {
|
|
939
|
+
key: 0,
|
|
940
|
+
ref_key: "colorPickerPanel",
|
|
941
|
+
ref: u,
|
|
942
|
+
class: "color-picker-panel"
|
|
943
|
+
}, [
|
|
944
|
+
C(a(Ie), {
|
|
945
|
+
"model-value": v.value,
|
|
946
|
+
inline: "",
|
|
947
|
+
onChange: M
|
|
948
|
+
}, null, 8, ["model-value"])
|
|
949
|
+
], 512)) : k("", !0),
|
|
950
|
+
C(_e, {
|
|
951
|
+
visible: h.value,
|
|
952
|
+
"onUpdate:visible": f[8] || (f[8] = (y) => h.value = y),
|
|
953
|
+
title: a(i)("common_actions.info_dialog.title"),
|
|
954
|
+
"actions-info": E.value
|
|
955
|
+
}, null, 8, ["visible", "title", "actions-info"])
|
|
956
|
+
], 64));
|
|
957
|
+
}
|
|
958
|
+
}), zn = /* @__PURE__ */ we(Rn, [["__scopeId", "data-v-4867e97c"]]), Tn = {
|
|
959
|
+
key: 2,
|
|
960
|
+
class: "canvas-status"
|
|
961
|
+
}, Un = {
|
|
962
|
+
key: 3,
|
|
963
|
+
class: "canvas-status canvas-status-error"
|
|
964
|
+
}, An = 500, Vn = 0.65, $n = /* @__PURE__ */ be({
|
|
965
|
+
__name: "CanvasBlock",
|
|
966
|
+
props: /* @__PURE__ */ re({
|
|
967
|
+
mode: {},
|
|
968
|
+
baseImageSrc: {},
|
|
969
|
+
isDisabled: { type: Boolean }
|
|
970
|
+
}, {
|
|
971
|
+
isFullScreen: { type: Boolean, default: !1 },
|
|
972
|
+
isFullScreenModifiers: {}
|
|
973
|
+
}),
|
|
974
|
+
emits: /* @__PURE__ */ re(["saveImage"], ["update:isFullScreen"]),
|
|
975
|
+
setup(e, { emit: n }) {
|
|
976
|
+
const t = { width: 1, height: 1 }, o = e, l = n, i = $e(e, "isFullScreen"), u = ke(Ce), r = en(o.mode), v = S(), h = S({ ...t }), I = S(), E = S(), M = S(), b = S({ ...t }), H = w(() => ({ x: 0, y: 0, fill: "white", ...b.value })), f = S(r.hasBackgroundImage || !!o.baseImageSrc), y = S(!1), V = S(`#${W}`), c = S(!0), O = { timerId: null }, D = () => {
|
|
977
|
+
O.timerId && (clearTimeout(O.timerId), O.timerId = null);
|
|
978
|
+
}, J = () => {
|
|
979
|
+
D(), O.timerId = setTimeout(() => {
|
|
980
|
+
O.timerId = null, ee();
|
|
981
|
+
}, An);
|
|
982
|
+
}, s = Cn({
|
|
983
|
+
stageRef: I,
|
|
984
|
+
strokesLayerRef: E,
|
|
985
|
+
containerRef: v,
|
|
986
|
+
containerSize: h,
|
|
987
|
+
imageSize: b,
|
|
988
|
+
isStrokeActive: c,
|
|
989
|
+
activeColor: V,
|
|
990
|
+
hasBackgroundImage: r.hasBackgroundImage,
|
|
991
|
+
imageEl: M,
|
|
992
|
+
onStrokeCommitted: J
|
|
993
|
+
}), He = w(() => {
|
|
994
|
+
const p = !o.baseImageSrc, g = !s.committedStrokes.value.length;
|
|
995
|
+
return o.mode === se.DRAW && !o.isDisabled && p && g;
|
|
996
|
+
}), Pe = w(() => ({
|
|
997
|
+
width: Math.round(b.value.width * s.effectiveScale.value),
|
|
998
|
+
height: Math.round(b.value.height * s.effectiveScale.value)
|
|
999
|
+
})), Be = w(() => ({ image: M.value, x: 0, y: 0, ...b.value })), Q = w(() => ({
|
|
1000
|
+
scaleX: s.effectiveScale.value,
|
|
1001
|
+
scaleY: s.effectiveScale.value,
|
|
1002
|
+
listening: !1
|
|
1003
|
+
})), Oe = w(() => {
|
|
1004
|
+
const p = b.value.height * Vn;
|
|
1005
|
+
return {
|
|
1006
|
+
points: [0, p, b.value.width, p],
|
|
1007
|
+
stroke: "#aaaaaa",
|
|
1008
|
+
strokeWidth: Me / 2,
|
|
1009
|
+
listening: !1
|
|
1010
|
+
};
|
|
1011
|
+
}), ee = async () => {
|
|
1012
|
+
const p = await s.flattenStage();
|
|
1013
|
+
p && l("saveImage", p);
|
|
1014
|
+
}, R = { pending: null }, ne = () => {
|
|
1015
|
+
if (R.pending) {
|
|
1016
|
+
const p = R.pending;
|
|
1017
|
+
R.pending = null, p.src = "";
|
|
1018
|
+
}
|
|
1019
|
+
}, te = (p) => p !== R.pending ? !1 : (R.pending = null, f.value = !1, !0), De = () => {
|
|
1020
|
+
const p = v.value?.parentElement;
|
|
1021
|
+
return p != null && getComputedStyle(p).getPropertyValue("--is-mobile-active") === "1";
|
|
1022
|
+
}, Z = () => {
|
|
1023
|
+
h.value = s.safeSize({
|
|
1024
|
+
width: v.value?.clientWidth,
|
|
1025
|
+
height: v.value?.clientHeight
|
|
1026
|
+
}), i.value && !De() && ie(), !M.value && i.value && !s.committedStrokes.value.length && (b.value = {
|
|
1027
|
+
width: h.value.width,
|
|
1028
|
+
height: o.mode === se.SIGNATURE ? b.value.height : h.value.height
|
|
1029
|
+
});
|
|
1030
|
+
}, oe = (p) => {
|
|
1031
|
+
b.value = p, f.value = !1, Z();
|
|
1032
|
+
}, xe = (p) => {
|
|
1033
|
+
f.value = !0, y.value = !1, M.value = void 0, s.resetZoom(), s.resetDrawingState(), D(), ne();
|
|
1034
|
+
const g = new Image();
|
|
1035
|
+
R.pending = g, g.onload = () => {
|
|
1036
|
+
if (!te(g))
|
|
1037
|
+
return;
|
|
1038
|
+
M.value = g;
|
|
1039
|
+
const _ = s.safeSize({ width: g.naturalWidth, height: g.naturalHeight });
|
|
1040
|
+
oe(_), J();
|
|
1041
|
+
}, g.onerror = () => {
|
|
1042
|
+
te(g) && (y.value = !0);
|
|
1043
|
+
}, g.src = p;
|
|
1044
|
+
}, Ee = () => {
|
|
1045
|
+
r.hasBackgroundImage || s.resetZoom(), i.value = !0;
|
|
1046
|
+
}, ie = () => {
|
|
1047
|
+
i.value = !1, s.resetZoom(), D(), ee();
|
|
1048
|
+
};
|
|
1049
|
+
ye(
|
|
1050
|
+
() => s.committedStrokes.value.length,
|
|
1051
|
+
(p, g) => {
|
|
1052
|
+
!M.value && g > 0 && p === 0 && (D(), l("saveImage", null));
|
|
1053
|
+
}
|
|
1054
|
+
);
|
|
1055
|
+
const Re = () => {
|
|
1056
|
+
if (Z(), o.baseImageSrc) {
|
|
1057
|
+
xe(o.baseImageSrc);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
r.hasBackgroundImage || oe({ ...h.value });
|
|
1061
|
+
}, X = { current: null };
|
|
1062
|
+
return Fe(() => {
|
|
1063
|
+
Re(), X.current = new ResizeObserver(() => Z()), X.current.observe(v.value);
|
|
1064
|
+
}), ge(() => {
|
|
1065
|
+
X.current?.disconnect(), D(), ne();
|
|
1066
|
+
}), (p, g) => {
|
|
1067
|
+
const _ = T("v-image"), ze = T("v-rect"), N = T("v-line"), le = T("v-layer"), Te = T("v-stage");
|
|
1068
|
+
return d(), m("div", {
|
|
1069
|
+
class: $(["canvas-block", {
|
|
1070
|
+
"canvas-full-screen": i.value,
|
|
1071
|
+
"canvas-compact": a(r).isCompact,
|
|
1072
|
+
"canvas-blank": !a(r).hasBackgroundImage
|
|
1073
|
+
}])
|
|
1074
|
+
}, [
|
|
1075
|
+
e.isDisabled ? k("", !0) : (d(), B(zn, {
|
|
1076
|
+
key: 0,
|
|
1077
|
+
"is-pan-active": !c.value,
|
|
1078
|
+
"mode-config": a(r),
|
|
1079
|
+
"is-full-screen": i.value,
|
|
1080
|
+
"is-blank-canvas": !a(s).committedStrokes.value.length,
|
|
1081
|
+
"disable-clear-all": !a(s).committedStrokes.value.length,
|
|
1082
|
+
"disable-undo": !a(s).committedStrokes.value.length,
|
|
1083
|
+
"disable-zoom-in": a(s).isZoomInDisabled.value,
|
|
1084
|
+
"disable-zoom-out": a(s).isZoomOutDisabled.value,
|
|
1085
|
+
onChangePan: g[0] || (g[0] = (z) => c.value = !z),
|
|
1086
|
+
onClearAll: a(s).clearAll,
|
|
1087
|
+
onCloseFullScreen: ie,
|
|
1088
|
+
onZoomIn: a(s).zoomIn,
|
|
1089
|
+
onZoomOut: a(s).zoomOut,
|
|
1090
|
+
onUndo: a(s).undo,
|
|
1091
|
+
onChangeColor: g[1] || (g[1] = (z) => V.value = z)
|
|
1092
|
+
}, null, 8, ["is-pan-active", "mode-config", "is-full-screen", "is-blank-canvas", "disable-clear-all", "disable-undo", "disable-zoom-in", "disable-zoom-out", "onClearAll", "onZoomIn", "onZoomOut", "onUndo"])),
|
|
1093
|
+
L("div", {
|
|
1094
|
+
ref_key: "containerRef",
|
|
1095
|
+
ref: v,
|
|
1096
|
+
class: "canvas-stage-wrap"
|
|
1097
|
+
}, [
|
|
1098
|
+
!i.value && !e.isDisabled ? (d(), m("div", {
|
|
1099
|
+
key: 0,
|
|
1100
|
+
class: "canvas-overlay full-screen-overlay",
|
|
1101
|
+
onClick: Ee
|
|
1102
|
+
})) : k("", !0),
|
|
1103
|
+
He.value ? (d(), B(a(nn), {
|
|
1104
|
+
key: 1,
|
|
1105
|
+
severity: "contrast",
|
|
1106
|
+
closable: "",
|
|
1107
|
+
size: "small",
|
|
1108
|
+
class: "canvas-snackbar"
|
|
1109
|
+
}, {
|
|
1110
|
+
default: U(() => [
|
|
1111
|
+
Ze(G(a(u)("canvas_block.draw_instruction.message")), 1)
|
|
1112
|
+
]),
|
|
1113
|
+
_: 1
|
|
1114
|
+
})) : k("", !0),
|
|
1115
|
+
f.value ? (d(), m("p", Tn, G(a(u)("canvas_block.loading_image.message")), 1)) : y.value ? (d(), m("p", Un, G(a(u)("canvas_block.load_image.error")), 1)) : (d(), B(Te, {
|
|
1116
|
+
key: 4,
|
|
1117
|
+
ref_key: "stageRef",
|
|
1118
|
+
ref: I,
|
|
1119
|
+
config: Pe.value,
|
|
1120
|
+
class: $(["canvas-stage", { "canvas-pan-mode": !c.value, "canvas-disabled": e.isDisabled }]),
|
|
1121
|
+
onPointerdown: a(s).onPointerDown,
|
|
1122
|
+
onPointermove: a(s).onPointerMove,
|
|
1123
|
+
onPointerup: a(s).onPointerUp,
|
|
1124
|
+
onPointerleave: a(s).onPointerUp,
|
|
1125
|
+
onPointercancel: a(s).onPointerUp
|
|
1126
|
+
}, {
|
|
1127
|
+
default: U(() => [
|
|
1128
|
+
C(le, { config: Q.value }, {
|
|
1129
|
+
default: U(() => [
|
|
1130
|
+
M.value ? (d(), B(_, {
|
|
1131
|
+
key: 0,
|
|
1132
|
+
config: Be.value
|
|
1133
|
+
}, null, 8, ["config"])) : (d(), B(ze, {
|
|
1134
|
+
key: 1,
|
|
1135
|
+
config: H.value
|
|
1136
|
+
}, null, 8, ["config"])),
|
|
1137
|
+
a(r).hasGuideLines && !M.value ? (d(), B(N, {
|
|
1138
|
+
key: 2,
|
|
1139
|
+
config: Oe.value
|
|
1140
|
+
}, null, 8, ["config"])) : k("", !0)
|
|
1141
|
+
]),
|
|
1142
|
+
_: 1
|
|
1143
|
+
}, 8, ["config"]),
|
|
1144
|
+
C(le, {
|
|
1145
|
+
ref_key: "strokesLayerRef",
|
|
1146
|
+
ref: E,
|
|
1147
|
+
config: Q.value
|
|
1148
|
+
}, {
|
|
1149
|
+
default: U(() => [
|
|
1150
|
+
(d(!0), m(Se, null, Xe(a(s).committedStrokes.value, (z) => (d(), B(N, {
|
|
1151
|
+
key: z.id,
|
|
1152
|
+
config: z.config
|
|
1153
|
+
}, null, 8, ["config"]))), 128)),
|
|
1154
|
+
a(s).liveStrokePoints.value.length >= 2 ? (d(), B(N, {
|
|
1155
|
+
key: 0,
|
|
1156
|
+
config: a(s).liveStrokeConfig.value
|
|
1157
|
+
}, null, 8, ["config"])) : k("", !0)
|
|
1158
|
+
]),
|
|
1159
|
+
_: 1
|
|
1160
|
+
}, 8, ["config"])
|
|
1161
|
+
]),
|
|
1162
|
+
_: 1
|
|
1163
|
+
}, 8, ["config", "class", "onPointerdown", "onPointermove", "onPointerup", "onPointerleave", "onPointercancel"]))
|
|
1164
|
+
], 512)
|
|
1165
|
+
], 2);
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
}), _n = /* @__PURE__ */ we($n, [["__scopeId", "data-v-e18eacca"]]);
|
|
1169
|
+
export {
|
|
1170
|
+
_n as default
|
|
1171
|
+
};
|