@progress/kendo-react-inputs 9.5.0-develop.6 → 10.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/checkbox/Checkbox.js +1 -1
- package/checkbox/Checkbox.mjs +21 -23
- package/colors/ColorGradient.js +1 -1
- package/colors/ColorGradient.mjs +61 -60
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +25 -26
- package/colors/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +78 -79
- package/colors/FlatColorPicker.js +1 -1
- package/colors/FlatColorPicker.mjs +61 -62
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +1 -1
- package/index.d.ts +1 -1
- package/input/Input.js +1 -1
- package/input/Input.mjs +36 -39
- package/maskedtextbox/MaskedTextBox.js +1 -1
- package/maskedtextbox/MaskedTextBox.mjs +79 -80
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +18 -20
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +9 -9
- package/radiobutton/RadioButton.js +1 -1
- package/radiobutton/RadioButton.mjs +37 -39
- package/radiobutton/RadioGroup.js +1 -1
- package/radiobutton/RadioGroup.mjs +19 -21
- package/range-slider/RangeSlider.js +7 -7
- package/range-slider/RangeSlider.mjs +100 -101
- package/signature/Signature.js +1 -1
- package/signature/Signature.mjs +58 -58
- package/slider/Slider.js +1 -1
- package/slider/Slider.mjs +15 -16
- package/switch/Switch.js +1 -1
- package/switch/Switch.mjs +15 -16
- package/textbox/Textbox.js +1 -1
- package/textbox/Textbox.mjs +43 -45
|
@@ -7,92 +7,91 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as a from "react";
|
|
9
9
|
import R from "prop-types";
|
|
10
|
-
import { createPropsContext as Y, validatePackage as _, usePropsContext as j, useDir as
|
|
11
|
-
import { sliderDragTitle as
|
|
12
|
-
import { useLocalization as
|
|
13
|
-
import { RANGE_ACTION as r, rangeReducer as
|
|
14
|
-
import { packageMetadata as
|
|
15
|
-
const
|
|
16
|
-
const [
|
|
10
|
+
import { createPropsContext as Y, validatePackage as _, usePropsContext as j, useDir as J, Keys as m, useDraggable as Q, classNames as Z, getTabIndex as V, WatermarkOverlay as ee } from "@progress/kendo-react-common";
|
|
11
|
+
import { sliderDragTitle as $, messages as z } from "../messages/index.mjs";
|
|
12
|
+
import { useLocalization as te } from "@progress/kendo-react-intl";
|
|
13
|
+
import { RANGE_ACTION as r, rangeReducer as ae } from "./range-raducer.mjs";
|
|
14
|
+
import { packageMetadata as re } from "../package-metadata.mjs";
|
|
15
|
+
const ne = (n, s, p) => {
|
|
16
|
+
const [c, e] = a.useState(n), d = a.useCallback(
|
|
17
17
|
(g) => {
|
|
18
|
-
const
|
|
19
|
-
p && p(
|
|
18
|
+
const S = ae(s.state || c, { ...g, ...s });
|
|
19
|
+
p && p(S, g.event), e(S);
|
|
20
20
|
},
|
|
21
21
|
[s, p]
|
|
22
22
|
);
|
|
23
|
-
return [
|
|
24
|
-
},
|
|
25
|
-
_(
|
|
26
|
-
const p = j(re, n), e = {
|
|
23
|
+
return [c, d];
|
|
24
|
+
}, le = Y(), P = a.forwardRef((n, s) => {
|
|
25
|
+
const p = !_(re, { component: "RangeSlider" }), c = j(le, n), e = {
|
|
27
26
|
step: y.step,
|
|
28
27
|
largeStep: y.largeStep,
|
|
29
28
|
defaultValue: y.defaultValue,
|
|
30
29
|
vertical: y.vertical,
|
|
31
30
|
disabled: y.disabled,
|
|
32
|
-
...
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
a.useImperativeHandle(
|
|
37
|
-
element:
|
|
38
|
-
focus:
|
|
31
|
+
...c
|
|
32
|
+
}, d = a.useRef(null), g = a.useRef(null), S = a.useRef(null), D = a.useRef(null), T = a.useRef(null), K = a.useCallback(() => {
|
|
33
|
+
D.current && D.current.focus();
|
|
34
|
+
}, [D]);
|
|
35
|
+
a.useImperativeHandle(d, () => ({
|
|
36
|
+
element: g.current,
|
|
37
|
+
focus: K,
|
|
39
38
|
props: e
|
|
40
|
-
})), a.useImperativeHandle(s, () =>
|
|
41
|
-
const f = a.useMemo(() => e.min, [e.min]), k = a.useMemo(() => e.max, [e.max]),
|
|
39
|
+
})), a.useImperativeHandle(s, () => d.current);
|
|
40
|
+
const f = a.useMemo(() => e.min, [e.min]), k = a.useMemo(() => e.max, [e.max]), A = a.useMemo(
|
|
42
41
|
() => e.step !== void 0 ? e.step : y.step,
|
|
43
42
|
[e.step, y.step]
|
|
44
|
-
),
|
|
43
|
+
), H = a.useMemo(
|
|
45
44
|
() => e.largeStep !== void 0 ? e.largeStep : y.largeStep,
|
|
46
45
|
[e.largeStep, y.largeStep]
|
|
47
|
-
),
|
|
48
|
-
e.onChange &&
|
|
46
|
+
), o = J(g, e.dir), N = (t, u) => {
|
|
47
|
+
e.onChange && d.current && e.onChange.call(void 0, {
|
|
49
48
|
value: t,
|
|
50
|
-
target:
|
|
51
|
-
syntheticEvent:
|
|
49
|
+
target: d.current,
|
|
50
|
+
syntheticEvent: u
|
|
52
51
|
});
|
|
53
|
-
}, [
|
|
52
|
+
}, [E, L] = a.useState(""), [b, l] = ne(
|
|
54
53
|
e.defaultValue || y.defaultValue,
|
|
55
54
|
{
|
|
56
55
|
min: f,
|
|
57
56
|
max: k,
|
|
58
|
-
step:
|
|
59
|
-
largeStep:
|
|
57
|
+
step: A,
|
|
58
|
+
largeStep: H,
|
|
60
59
|
state: e.value
|
|
61
60
|
},
|
|
62
|
-
|
|
63
|
-
), i = a.useMemo(() => e.value ||
|
|
61
|
+
N
|
|
62
|
+
), i = a.useMemo(() => e.value || b, [e.value, b]), O = a.useRef(null), w = a.useRef(null), h = a.useMemo(() => (i.start - f) / (k - f) * 100, [i.start, f, k]), x = a.useMemo(() => (i.end - f) / (k - f) * 100, [i.end, f, k]), W = a.useMemo(
|
|
64
63
|
() => e.vertical ? { paddingTop: 0, height: "100%" } : {},
|
|
65
64
|
[e.vertical]
|
|
66
|
-
),
|
|
65
|
+
), q = a.useMemo(
|
|
67
66
|
() => e.vertical ? { marginTop: "0.5rem", marginBottom: "0.5rem" } : { marginLeft: "0.5rem", marginRight: "0.5rem" },
|
|
68
67
|
[e.vertical]
|
|
69
|
-
),
|
|
68
|
+
), M = te(), C = a.useCallback(
|
|
70
69
|
(t) => {
|
|
71
70
|
if (!w.current)
|
|
72
71
|
return;
|
|
73
|
-
const
|
|
74
|
-
return f +
|
|
72
|
+
const u = w.current.getBoundingClientRect(), v = e.vertical ? u.bottom - t.clientY : o === "rtl" ? u.right - t.clientX : t.clientX - u.left, I = e.vertical ? u.height : u.width, F = v / I;
|
|
73
|
+
return f + F * (k - f);
|
|
75
74
|
},
|
|
76
75
|
[
|
|
77
76
|
w,
|
|
78
77
|
e.vertical,
|
|
79
|
-
|
|
78
|
+
o,
|
|
80
79
|
f,
|
|
81
80
|
k,
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
b.start,
|
|
82
|
+
b.end,
|
|
84
83
|
e.value && e.value.start,
|
|
85
84
|
e.value && e.value.end
|
|
86
85
|
]
|
|
87
|
-
),
|
|
86
|
+
), B = a.useCallback(
|
|
88
87
|
(t) => t <= i.start ? "start" : t >= i.end ? "end" : 2 * t < i.end + i.start ? "start" : "end",
|
|
89
|
-
[
|
|
90
|
-
),
|
|
88
|
+
[b.start, b.end, e.value && e.value.start, e.value && e.value.end]
|
|
89
|
+
), G = a.useCallback(
|
|
91
90
|
(t) => {
|
|
92
91
|
switch (t.keyCode) {
|
|
93
92
|
case m.right:
|
|
94
93
|
t.preventDefault(), l({
|
|
95
|
-
type:
|
|
94
|
+
type: o === "rtl" ? r.decrease : r.increase,
|
|
96
95
|
key: "start",
|
|
97
96
|
event: t
|
|
98
97
|
});
|
|
@@ -102,7 +101,7 @@ const ae = (n, s, p) => {
|
|
|
102
101
|
break;
|
|
103
102
|
case m.left:
|
|
104
103
|
t.preventDefault(), l({
|
|
105
|
-
type:
|
|
104
|
+
type: o === "rtl" ? r.increase : r.decrease,
|
|
106
105
|
key: "start",
|
|
107
106
|
event: t
|
|
108
107
|
});
|
|
@@ -118,14 +117,14 @@ const ae = (n, s, p) => {
|
|
|
118
117
|
break;
|
|
119
118
|
case m.pageDown:
|
|
120
119
|
t.preventDefault(), l({
|
|
121
|
-
type:
|
|
120
|
+
type: o === "rtl" ? r.increaseLarge : r.decreaseLarge,
|
|
122
121
|
key: "start",
|
|
123
122
|
event: t
|
|
124
123
|
});
|
|
125
124
|
break;
|
|
126
125
|
case m.pageUp:
|
|
127
126
|
t.preventDefault(), l({
|
|
128
|
-
type:
|
|
127
|
+
type: o === "rtl" ? r.decreaseLarge : r.increaseLarge,
|
|
129
128
|
key: "start",
|
|
130
129
|
event: t
|
|
131
130
|
});
|
|
@@ -138,7 +137,7 @@ const ae = (n, s, p) => {
|
|
|
138
137
|
switch (t.keyCode) {
|
|
139
138
|
case m.right:
|
|
140
139
|
t.preventDefault(), l({
|
|
141
|
-
type:
|
|
140
|
+
type: o === "rtl" ? r.decrease : r.increase,
|
|
142
141
|
key: "end",
|
|
143
142
|
event: t
|
|
144
143
|
});
|
|
@@ -148,7 +147,7 @@ const ae = (n, s, p) => {
|
|
|
148
147
|
break;
|
|
149
148
|
case m.left:
|
|
150
149
|
t.preventDefault(), l({
|
|
151
|
-
type:
|
|
150
|
+
type: o === "rtl" ? r.increase : r.decrease,
|
|
152
151
|
key: "end",
|
|
153
152
|
event: t
|
|
154
153
|
});
|
|
@@ -164,55 +163,55 @@ const ae = (n, s, p) => {
|
|
|
164
163
|
break;
|
|
165
164
|
case m.pageDown:
|
|
166
165
|
t.preventDefault(), l({
|
|
167
|
-
type:
|
|
166
|
+
type: o === "rtl" ? r.increaseLarge : r.decreaseLarge,
|
|
168
167
|
key: "end",
|
|
169
168
|
event: t
|
|
170
169
|
});
|
|
171
170
|
break;
|
|
172
171
|
case m.pageUp:
|
|
173
172
|
t.preventDefault(), l({
|
|
174
|
-
type:
|
|
173
|
+
type: o === "rtl" ? r.decreaseLarge : r.increaseLarge,
|
|
175
174
|
key: "end",
|
|
176
175
|
event: t
|
|
177
176
|
});
|
|
178
177
|
break;
|
|
179
178
|
}
|
|
180
179
|
},
|
|
181
|
-
[l,
|
|
180
|
+
[l, o]
|
|
182
181
|
), X = a.useCallback(
|
|
183
182
|
(t) => {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
l({ type:
|
|
183
|
+
const u = C(t), v = B(u);
|
|
184
|
+
L(v), v === "end" ? T.current.focus() : D.current.focus();
|
|
185
|
+
const I = v === "end" ? r.end : r.start;
|
|
186
|
+
l({ type: I, payload: u, event: t });
|
|
188
187
|
},
|
|
189
188
|
[e.vertical, f, k, l]
|
|
190
189
|
);
|
|
191
|
-
return
|
|
190
|
+
return Q(
|
|
192
191
|
w,
|
|
193
192
|
{
|
|
194
193
|
onPress: X,
|
|
195
194
|
onDrag: (t) => {
|
|
196
|
-
const
|
|
197
|
-
l({ type: v, payload:
|
|
195
|
+
const u = C(t), v = E === "end" ? r.end : r.start;
|
|
196
|
+
l({ type: v, payload: u, event: t });
|
|
198
197
|
},
|
|
199
198
|
onRelease: (t) => {
|
|
200
|
-
const
|
|
201
|
-
l({ type: v, payload:
|
|
199
|
+
const u = C(t), v = E === "end" ? r.end : r.start;
|
|
200
|
+
l({ type: v, payload: u, event: t }), L("");
|
|
202
201
|
}
|
|
203
202
|
},
|
|
204
203
|
{ autoScroll: !1 }
|
|
205
|
-
), /* @__PURE__ */ a.createElement(
|
|
204
|
+
), /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement(
|
|
206
205
|
"div",
|
|
207
206
|
{
|
|
208
207
|
id: e.id,
|
|
209
208
|
style: e.style,
|
|
210
|
-
ref:
|
|
211
|
-
dir:
|
|
212
|
-
className:
|
|
209
|
+
ref: g,
|
|
210
|
+
dir: o,
|
|
211
|
+
className: Z(
|
|
213
212
|
"k-slider",
|
|
214
213
|
{
|
|
215
|
-
"k-rtl":
|
|
214
|
+
"k-rtl": o === "rtl",
|
|
216
215
|
"k-disabled": e.disabled,
|
|
217
216
|
"k-slider-vertical": e.vertical,
|
|
218
217
|
"k-slider-horizontal": !e.vertical
|
|
@@ -229,81 +228,81 @@ const ae = (n, s, p) => {
|
|
|
229
228
|
flexGrow: 1,
|
|
230
229
|
position: "relative",
|
|
231
230
|
touchAction: "none",
|
|
232
|
-
...
|
|
231
|
+
...q
|
|
233
232
|
}
|
|
234
233
|
},
|
|
235
|
-
e.children && /* @__PURE__ */ a.createElement("ul", { className: "k-reset k-slider-items", style: { ...
|
|
234
|
+
e.children && /* @__PURE__ */ a.createElement("ul", { className: "k-reset k-slider-items", style: { ...W } }, a.Children.map(e.children, (t, u) => t && a.cloneElement(
|
|
236
235
|
t,
|
|
237
236
|
{
|
|
238
237
|
position: 100 * (t.props.position - e.min) / (e.max - e.min),
|
|
239
238
|
vertical: e.vertical,
|
|
240
|
-
firstTick:
|
|
241
|
-
lastTick:
|
|
239
|
+
firstTick: u === 0,
|
|
240
|
+
lastTick: u === a.Children.count(e.children) - 1
|
|
242
241
|
},
|
|
243
242
|
t.props.children
|
|
244
243
|
))),
|
|
245
244
|
/* @__PURE__ */ a.createElement(
|
|
246
245
|
"div",
|
|
247
246
|
{
|
|
248
|
-
ref:
|
|
247
|
+
ref: O,
|
|
249
248
|
className: "k-slider-track",
|
|
250
|
-
style: e.vertical ? { bottom: 0, height: "100%" } : { [
|
|
249
|
+
style: e.vertical ? { bottom: 0, height: "100%" } : { [o === "rtl" ? "right" : "left"]: 0, width: "100%" }
|
|
251
250
|
},
|
|
252
|
-
h !== null &&
|
|
251
|
+
h !== null && x !== null && /* @__PURE__ */ a.createElement(
|
|
253
252
|
"div",
|
|
254
253
|
{
|
|
255
254
|
"data-selection": !0,
|
|
256
|
-
ref:
|
|
255
|
+
ref: S,
|
|
257
256
|
title: `${i.start} - ${i.end}`,
|
|
258
257
|
className: "k-slider-selection",
|
|
259
|
-
style: e.vertical ? { height:
|
|
260
|
-
[
|
|
261
|
-
width:
|
|
258
|
+
style: e.vertical ? { height: x - h + "%", bottom: h + "%" } : {
|
|
259
|
+
[o === "rtl" ? "right" : "left"]: h + "%",
|
|
260
|
+
width: x - h + "%"
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
263
|
),
|
|
265
264
|
/* @__PURE__ */ a.createElement(
|
|
266
265
|
"span",
|
|
267
266
|
{
|
|
268
|
-
ref:
|
|
267
|
+
ref: D,
|
|
269
268
|
role: "slider",
|
|
270
|
-
tabIndex:
|
|
269
|
+
tabIndex: V(e.startTabIndex, e.disabled, void 0),
|
|
271
270
|
"aria-valuemin": f,
|
|
272
271
|
"aria-valuemax": Math.max(k, i.end),
|
|
273
272
|
"aria-valuenow": i.start,
|
|
274
273
|
"aria-disabled": e.disabled ? "true" : void 0,
|
|
275
274
|
"aria-valuetext": `${i.start} - ${i.end}`,
|
|
276
275
|
className: "k-draghandle k-draghandle-start",
|
|
277
|
-
title:
|
|
278
|
-
style: e.vertical ? { bottom: "calc(" + h + "%)", zIndex: 1 } :
|
|
279
|
-
onKeyDown:
|
|
276
|
+
title: M.toLanguageString($, z[$]),
|
|
277
|
+
style: e.vertical ? { bottom: "calc(" + h + "%)", zIndex: 1 } : o === "rtl" ? { right: "calc(" + h + "% - 13px)", zIndex: 1 } : { left: "calc(" + h + "%)", zIndex: 1 },
|
|
278
|
+
onKeyDown: G
|
|
280
279
|
}
|
|
281
280
|
),
|
|
282
281
|
/* @__PURE__ */ a.createElement(
|
|
283
282
|
"span",
|
|
284
283
|
{
|
|
285
|
-
ref:
|
|
284
|
+
ref: T,
|
|
286
285
|
role: "slider",
|
|
287
|
-
tabIndex:
|
|
286
|
+
tabIndex: V(e.endTabIndex, e.disabled, void 0),
|
|
288
287
|
"aria-valuemin": Math.min(f, i.start),
|
|
289
288
|
"aria-valuemax": k,
|
|
290
289
|
"aria-valuenow": i.end,
|
|
291
290
|
"aria-disabled": e.disabled ? "true" : void 0,
|
|
292
291
|
"aria-valuetext": `${i.start} - ${i.end}`,
|
|
293
292
|
className: "k-draghandle k-draghandle-end",
|
|
294
|
-
title:
|
|
295
|
-
style: e.vertical ? { bottom: "calc(" +
|
|
293
|
+
title: M.toLanguageString($, z[$]),
|
|
294
|
+
style: e.vertical ? { bottom: "calc(" + x + "%)", zIndex: 1 } : o === "rtl" ? { right: "calc(" + x + "% - 13px)", zIndex: 1 } : { left: "calc(" + x + "%)", zIndex: 1 },
|
|
296
295
|
onKeyDown: U
|
|
297
296
|
}
|
|
298
297
|
)
|
|
299
298
|
)
|
|
300
299
|
)
|
|
301
|
-
);
|
|
302
|
-
}),
|
|
300
|
+
), p && /* @__PURE__ */ a.createElement(ee, null));
|
|
301
|
+
}), se = {
|
|
303
302
|
value: (n, s, p) => {
|
|
304
303
|
if (n.value) {
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
304
|
+
const c = n.value.start, e = n.value.end, d = n.min, g = n.max;
|
|
305
|
+
if (c > e || c > g || c < d || e > g || e < d || e < c)
|
|
307
306
|
return new Error(
|
|
308
307
|
`Invalid prop + ${s} supplied to ${p}.
|
|
309
308
|
The { start, end } value must be between the min & max value and { start, end } must be start < end.
|
|
@@ -314,8 +313,8 @@ const ae = (n, s, p) => {
|
|
|
314
313
|
},
|
|
315
314
|
defaultValue: (n, s, p) => {
|
|
316
315
|
if (n.defaultValue) {
|
|
317
|
-
const
|
|
318
|
-
if (
|
|
316
|
+
const c = n.defaultValue.start, e = n.defaultValue.end, d = n.min, g = n.max;
|
|
317
|
+
if (c > e || c > g || c < d || e > g || e < d || e < c)
|
|
319
318
|
return new Error(
|
|
320
319
|
`Invalid prop + ${s} supplied to ${p}.
|
|
321
320
|
The { start, end } value must be between the min & max value and { start, end } must be start < end.
|
|
@@ -327,24 +326,24 @@ const ae = (n, s, p) => {
|
|
|
327
326
|
onChange: R.func,
|
|
328
327
|
step: R.number,
|
|
329
328
|
min: (n, s, p) => {
|
|
330
|
-
const
|
|
331
|
-
return
|
|
329
|
+
const c = n[s], e = n.min, d = n.max;
|
|
330
|
+
return e === void 0 ? new Error(
|
|
332
331
|
`Invalid prop + ${s} supplied to ${p}.
|
|
333
332
|
${s} value can not be undefined.
|
|
334
333
|
`
|
|
335
|
-
) :
|
|
334
|
+
) : c && e >= d ? new Error(
|
|
336
335
|
`Invalid prop + ${s} supplied to ${p}.
|
|
337
336
|
${s} value can not be equal to or bigger than the max value.
|
|
338
337
|
`
|
|
339
338
|
) : null;
|
|
340
339
|
},
|
|
341
340
|
max: (n, s, p) => {
|
|
342
|
-
const
|
|
343
|
-
return
|
|
341
|
+
const c = n[s], e = n.min, d = n.max;
|
|
342
|
+
return d === void 0 ? new Error(
|
|
344
343
|
`Invalid prop + ${s} supplied to ${p}.
|
|
345
344
|
${s} value can not be undefined.
|
|
346
345
|
`
|
|
347
|
-
) :
|
|
346
|
+
) : c && d <= e ? new Error(
|
|
348
347
|
`Invalid prop + ${s} supplied to ${p}.
|
|
349
348
|
${s} value can not be equal to or smaller than the min value.
|
|
350
349
|
`
|
|
@@ -363,9 +362,9 @@ const ae = (n, s, p) => {
|
|
|
363
362
|
vertical: !1,
|
|
364
363
|
disabled: !1
|
|
365
364
|
};
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
P.displayName = "KendoReactRangeSlider";
|
|
366
|
+
P.propTypes = se;
|
|
368
367
|
export {
|
|
369
|
-
|
|
370
|
-
|
|
368
|
+
P as RangeSlider,
|
|
369
|
+
le as RangeSliderPropsContext
|
|
371
370
|
};
|
package/signature/Signature.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ce=require("@progress/kendo-inputs-common"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ce=require("@progress/kendo-inputs-common"),_=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-react-common"),Se=require("@progress/kendo-react-dialogs"),ze=require("@progress/kendo-react-intl"),a=require("prop-types"),Oe=require("react"),p=require("../messages/index.js"),Ee=require("../package-metadata.js"),xe=require("./utils/index.js"),N=require("@progress/kendo-svg-icons");function Me(c){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const f in c)if(f!=="default"){const b=Object.getOwnPropertyDescriptor(c,f);Object.defineProperty(k,f,b.get?b:{enumerable:!0,get:()=>c[f]})}}return k.default=c,Object.freeze(k)}const n=Me(Oe),we=250,Ie=84,ne=3,oe=2,Le="#000000",Pe="#ffffff",te=c=>c!==void 0,ae=r.createPropsContext(),E=n.forwardRef((c,k)=>{const f=!r.validatePackage(Ee.packageMetadata,{component:"Signature"}),b=r.usePropsContext(ae,c),e=n.useMemo(()=>({strokeWidth:l.strokeWidth,smooth:l.smooth,popupScale:l.popupScale,exportScale:l.exportScale,maximizable:l.maximizable,disabled:l.disabled,required:l.required,validityStyles:l.validityStyles,onChange:l.onChange,onFocus:l.onFocus,onBlur:l.onBlur,onOpen:l.onOpen,onClose:l.onClose,size:l.size,rounded:l.rounded,fillMode:l.fillMode,...b}),[b]),x=ze.useLocalization(),d=n.useRef(null),v=n.useRef(null),F=n.useRef(null),j=n.useRef(null),M=n.useRef(null),[s,re]=n.useState(),[h,W]=n.useState(!1),[w,G]=n.useState(!1),[C,A]=n.useState(),[se,ie]=n.useState(),V=te(e.value)?e.value:C,[le,ce]=n.useState(!1),y=te(e.open),g=y?e.open:le,ue=e.maximized||w||!e.maximizable||e.disabled,de=!(e.maximized&&!w),me=!(!(e.value||C)||w||e.readOnly||e.disabled),U=x.toLanguageString(p.signatureMaximize,p.messages[p.signatureMaximize]),H=x.toLanguageString(p.signatureMinimize,p.messages[p.signatureMinimize]),$=x.toLanguageString(p.signatureClear,p.messages[p.signatureClear]),I=e.popupScale||ne,L=e.exportScale||oe,P=t=>{A(t),e.onChange&&e.onChange({value:t})},pe=t=>{s==null||s.loadImage(t.value),P(t.value)};n.useEffect(()=>{e.value!==C&&(A(e.value),s==null||s.loadImage(e.value))},[e.value]);const fe=()=>{s==null||s.clear(),P()},S=n.useCallback(t=>{y||ce(t)},[y]),ge=t=>{var o,i;Y(t),(i=((o=M.current)==null?void 0:o.element)||v.current)==null||i.focus()},q=n.useCallback(()=>{let t=Le;return!e.color&&typeof document!="undefined"&&d.current&&(t=getComputedStyle(d.current).color),e.color||t},[e.color]),D=n.useCallback(()=>{let t=Pe;return!e.backgroundColor&&typeof document!="undefined"&&d.current&&(t=getComputedStyle(d.current).backgroundColor),e.backgroundColor||t},[e.backgroundColor]),K=()=>({scale:e.maximized?e.popupScale:1,color:q(),backgroundColor:D(),strokeWidth:e.strokeWidth,smooth:e.smooth,readonly:e.readOnly}),X=async t=>{const{width:o,height:i}=t;return await(s==null?void 0:s.exportImage({width:o*L,height:i*L}))};n.useEffect(()=>{const t=v.current,o=new Ce.SignaturePad(t,K());return V&&o.loadImage(V),re(o),()=>o.destroy()},[]),n.useEffect(()=>{s==null||s.setOptions({onChange:async()=>P(await X(Z())),onDraw:()=>G(!0),onDrawEnd:()=>G(!1)})},[s]),r.useIsomorphicLayoutEffect(()=>s==null?void 0:s.setOptions(K()),[e.readOnly,e.color,e.backgroundColor,e.strokeWidth,e.smooth]),n.useEffect(()=>{var i,u;const t=(u=(i=F.current)==null?void 0:i.element)==null?void 0:u.querySelector(".k-overlay");if(!t)return;const o=()=>S(!1);return t.addEventListener("click",o),()=>t.removeEventListener("click",o)},[g]),n.useEffect(()=>{if(!g||typeof document=="undefined")return;const t=o=>{var i,u;o.key==="Escape"&&(S(!1),(u=(i=M.current)==null?void 0:i.element)==null||u.focus())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g]),n.useEffect(()=>{var t,o;e.maximized&&((o=(t=j.current)==null?void 0:t.element)==null||o.focus())},[]);const R=n.useCallback(()=>{var t;return(t=v.current)==null?void 0:t.focus()},[]),z=n.useCallback(()=>e.value,[e.value]),J=n.useCallback(()=>e.name,[e.name]),O=n.useCallback(()=>e.required,[e.required]),T=n.useCallback(()=>{const t=e.validationMessage!==void 0,i=!z(),u=e.valid!==void 0?e.valid:!O()||!i;return{customError:t,valid:u,valueMissing:i}},[e.validationMessage,e.valid,z,O]),B=n.useCallback(()=>e.validityStyles,[e.validityStyles]),Q=n.useCallback(()=>e,[e]),m=n.useCallback(()=>{const t={element:d.current,focus:R};return Object.defineProperty(t,"name",{get:J}),Object.defineProperty(t,"value",{get:z}),Object.defineProperty(t,"validity",{get:T}),Object.defineProperty(t,"validityStyles",{get:B}),Object.defineProperty(t,"required",{get:O}),Object.defineProperty(t,"props",{get:Q}),Object.defineProperty(t,"color",{get:q}),Object.defineProperty(t,"backgroundColor",{get:D}),t},[J,z,T,B,O,R,Q,q,D]);n.useImperativeHandle(k,m);const ke=n.useCallback(t=>{h||e.maximized||(W(!0),r.dispatchEvent(e.onFocus,t,m(),{}))},[h,e.onFocus,m]),be=n.useCallback(t=>{xe.hasParent(t.relatedTarget,d.current)||(W(!1),r.dispatchEvent(e.onBlur,t,m(),{}))},[h,e.onBlur,m]),ye=n.useCallback(async t=>{ie(await X(ee())),S(!0),r.dispatchEvent(e.onOpen,t,m(),{})},[g,y,e.onOpen,e.value,C,m]),Y=n.useCallback(t=>{S(!1),r.dispatchEvent(e.onClose,t,m(),{})},[g,y,e.onClose,m]),ve=()=>{fe(),R()},Z=()=>{var i,u;const t=e.width||((i=d.current)==null?void 0:i.offsetWidth)||we,o=e.height||((u=d.current)==null?void 0:u.offsetHeight)||Ie;return{width:t,height:o}},ee=()=>{const{width:t,height:o}=Z();return{width:t*I,height:o*I}},he=!B()||T().valid;return n.createElement("div",{ref:d,dir:e.dir,style:{width:e.width,height:e.height,...e.style},className:r.classNames("k-input","k-signature",{"k-signature-maximized":e.maximized,[`k-signature-${r.kendoThemeMaps.sizeMap[e.size]||e.size}`]:e.size,[`k-signature-${e.fillMode}`]:e.fillMode,[`k-input-${e.fillMode}`]:e.fillMode,[`k-rounded-${r.kendoThemeMaps.roundedMap[e.rounded]||e.rounded}`]:e.rounded,"k-invalid":!he,"k-required":e.required,"k-disabled":e.disabled,"k-focus":h},e.className),onFocus:ke,onBlur:be},n.createElement("div",{className:"k-signature-canvas",ref:v,tabIndex:r.getTabIndex(e.tabIndex,e.disabled),role:"img",id:e.id,"aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-disabled":e.disabled?"true":void 0}),n.createElement("div",{className:"k-signature-actions k-signature-actions-top"},n.createElement(_.Button,{type:"button",className:r.classNames("k-signature-action","k-signature-maximize",{"k-hidden":e.disabled||ue}),ref:M,icon:"hyperlink-open",svgIcon:N.hyperlinkOpenIcon,fillMode:"flat",size:e.size,onClick:ye,"aria-label":U,title:U}),n.createElement(_.Button,{type:"button",className:r.classNames("k-signature-action","k-signature-minimize","k-rotate-180",{"k-hidden":e.disabled||de}),ref:j,icon:"hyperlink-open",svgIcon:N.hyperlinkOpenIcon,fillMode:"flat",size:e.size,onClick:Y,"aria-label":H,title:H})),!e.hideLine&&n.createElement("div",{className:"k-signature-line",style:{zIndex:2,pointerEvents:"none"}}),n.createElement("div",{className:"k-signature-actions k-signature-actions-bottom"},me&&n.createElement(_.Button,{type:"button",className:"k-signature-action k-signature-clear",icon:"x",svgIcon:N.xIcon,fillMode:"flat",size:e.size,onClick:ve,"aria-label":$,title:$})),g&&n.createElement(Se.Dialog,{ref:F},n.createElement(E,{...e,...ee(),value:se,maximized:!0,exportScale:1/I*L,open:!1,onChange:pe,onClose:ge})),f&&n.createElement(r.WatermarkOverlay,null))});E.propTypes={value:a.string,width:a.number,height:a.number,tabIndex:a.number,dir:a.string,ariaDescribedBy:a.string,ariaLabelledBy:a.string,ariaLabel:a.string,readOnly:a.bool,disabled:a.bool,validationMessage:a.string,required:a.bool,onChange:a.func,onFocus:a.func,onBlur:a.func,onOpen:a.func,onClose:a.func,size:a.oneOf([null,"small","medium","large"]),rounded:a.oneOf([null,"small","medium","large"]),fillMode:a.oneOf([null,"solid","flat","outline"])};const l={strokeWidth:1,smooth:!1,popupScale:ne,exportScale:oe,maximizable:!0,disabled:!1,required:!1,validityStyles:!0,onChange:c=>r.noop,onFocus:c=>r.noop,onBlur:c=>r.noop,onOpen:c=>r.noop,onClose:c=>r.noop,size:"medium",rounded:"medium",fillMode:"solid"};E.displayName="KendoSignature";exports.Signature=E;exports.SignaturePropsContext=ae;
|