@progress/kendo-react-inputs 15.2.0-develop.1 → 15.2.0-develop.3
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 +79 -77
- package/colors/ColorContrastLabels.js +1 -1
- package/colors/ColorContrastLabels.mjs +2 -2
- package/colors/ColorGradient.js +1 -1
- package/colors/ColorGradient.mjs +51 -52
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +71 -72
- package/colors/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +247 -239
- package/colors/FlatColorPicker.d.ts +4 -4
- package/colors/FlatColorPicker.js +1 -1
- package/colors/FlatColorPicker.mjs +104 -100
- package/colors/interfaces/ColorPaletteProps.d.ts +7 -0
- package/colors/interfaces/ColorPickerPaletteSettings.d.ts +5 -0
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/maskedtextbox/MaskedTextBox.d.ts +1 -0
- package/maskedtextbox/MaskedTextBox.js +1 -1
- package/maskedtextbox/MaskedTextBox.mjs +26 -23
- package/maskedtextbox/MaskedTextBoxProps.d.ts +7 -0
- package/messages/index.d.ts +5 -0
- package/messages/index.js +1 -1
- package/messages/index.mjs +46 -44
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +2 -2
- package/otpinput/OTPInput.js +1 -1
- package/otpinput/OTPInput.mjs +141 -143
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +10 -10
- package/radiobutton/RadioButton.js +1 -1
- package/radiobutton/RadioButton.mjs +32 -30
- package/range-slider/RangeSlider.js +11 -11
- package/range-slider/RangeSlider.mjs +54 -54
- package/rating/Rating.d.ts +12 -0
- package/rating/Rating.js +2 -2
- package/rating/Rating.mjs +91 -92
- package/signature/Signature.js +1 -1
- package/signature/Signature.mjs +113 -110
- package/slider/Slider.d.ts +12 -0
- package/slider/Slider.js +1 -1
- package/slider/Slider.mjs +61 -56
- package/switch/Switch.d.ts +15 -0
- package/switch/Switch.js +1 -1
- package/switch/Switch.mjs +82 -79
- package/textarea/TextArea.js +1 -1
- package/textarea/TextArea.mjs +11 -12
package/rating/Rating.mjs
CHANGED
|
@@ -7,28 +7,26 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as a from "react";
|
|
9
9
|
import c from "prop-types";
|
|
10
|
-
import { usePropsContext as
|
|
11
|
-
import { RatingItem as
|
|
12
|
-
import { RATING_ACTION as r, ratingReducer as
|
|
13
|
-
import { calcIsFirstHalf as
|
|
14
|
-
|
|
15
|
-
import { useLocalization as de } from "@progress/kendo-react-intl";
|
|
16
|
-
const A = {
|
|
10
|
+
import { usePropsContext as Z, useDir as ee, useWebMcpRegister as te, Keys as E, IconWrap as y, toIconName as z, classNames as ae, getTabIndex as ne, createPropsContext as le, svgIconPropType as $ } from "@progress/kendo-react-common";
|
|
11
|
+
import { RatingItem as se } from "./RatingItem.mjs";
|
|
12
|
+
import { RATING_ACTION as r, ratingReducer as oe } from "./rating-reducer.mjs";
|
|
13
|
+
import { calcIsFirstHalf as K, toRound as D, getRemainder as ie, isHalf as re, isSelected as F, isCorrectValue as L } from "./utils/index.mjs";
|
|
14
|
+
const S = {
|
|
17
15
|
name: "star",
|
|
18
16
|
content: '<path d="m22.762 10.668-4.557 3.931 1.389 5.88a1.661 1.661 0 0 1-2.481 1.805L12 19.138l-5.116 3.146a1.661 1.661 0 0 1-2.478-1.805l1.394-5.88-4.557-3.931a1.667 1.667 0 0 1 .943-2.921l5.974-.482 2.304-5.577a1.656 1.656 0 0 1 3.065 0l2.304 5.577 5.973.482a1.667 1.667 0 0 1 .95 2.922z" />',
|
|
19
17
|
viewBox: "0 0 24 24"
|
|
20
|
-
},
|
|
18
|
+
}, A = {
|
|
21
19
|
name: "star-outline",
|
|
22
20
|
content: '<path d="M23.065 8.95a1.44 1.44 0 0 0-1.267-1l-6.101-.493-2.351-5.691a1.454 1.454 0 0 0-2.691 0L8.304 7.454l-6.101.496A1.44 1.44 0 0 0 .936 8.951a1.46 1.46 0 0 0 .433 1.562l4.657 4.011-1.417 5.998a1.46 1.46 0 0 0 .567 1.52 1.43 1.43 0 0 0 1.61.061L12 18.898l5.222 3.211a1.43 1.43 0 0 0 1.611-.061 1.46 1.46 0 0 0 .566-1.52l-1.417-5.998 4.65-4.016a1.46 1.46 0 0 0 .433-1.564m-1.229.644-4.929 4.253a.61.61 0 0 0-.195.599l1.506 6.357a.24.24 0 0 1-.096.261.23.23 0 0 1-.262.009l-5.541-3.404a.61.61 0 0 0-.636 0l-5.54 3.403a.23.23 0 0 1-.263-.01.24.24 0 0 1-.101-.26l1.506-6.358a.61.61 0 0 0-.194-.598l-4.93-4.253a.24.24 0 0 1-.074-.269.23.23 0 0 1 .21-.167l6.471-.522a.61.61 0 0 0 .513-.373l2.493-6.035a.238.238 0 0 1 .444 0l2.494 6.035a.61.61 0 0 0 .512.373l6.472.522a.23.23 0 0 1 .21.167.24.24 0 0 1-.068.269z" />',
|
|
23
21
|
viewBox: "0 0 24 24"
|
|
24
|
-
},
|
|
25
|
-
const [e,
|
|
26
|
-
return [e, (
|
|
27
|
-
const
|
|
28
|
-
|
|
22
|
+
}, W = (n, v, g) => {
|
|
23
|
+
const [e, u] = a.useState(n);
|
|
24
|
+
return [e, (o) => {
|
|
25
|
+
const V = oe(v.state || e, { ...o, ...v });
|
|
26
|
+
g && g(V, o.event), u(V);
|
|
29
27
|
}];
|
|
30
|
-
},
|
|
31
|
-
const
|
|
28
|
+
}, ce = le(), X = a.forwardRef((n, v) => {
|
|
29
|
+
const g = Z(ce, n), e = {
|
|
32
30
|
dir: s.dir,
|
|
33
31
|
min: s.min,
|
|
34
32
|
max: s.max,
|
|
@@ -39,13 +37,13 @@ const A = {
|
|
|
39
37
|
disabled: s.disabled,
|
|
40
38
|
selection: s.selection,
|
|
41
39
|
precision: s.precision,
|
|
42
|
-
...
|
|
43
|
-
},
|
|
40
|
+
...g
|
|
41
|
+
}, u = a.useRef(null), w = a.useRef(null), o = ee(w, e.dir);
|
|
44
42
|
a.useImperativeHandle(u, () => ({
|
|
45
|
-
element:
|
|
43
|
+
element: w.current,
|
|
46
44
|
props: e
|
|
47
|
-
})), a.useImperativeHandle(
|
|
48
|
-
const
|
|
45
|
+
})), a.useImperativeHandle(v, () => u.current), te("rating", u, e, e.webMcp);
|
|
46
|
+
const V = a.useCallback(
|
|
49
47
|
(t, l) => {
|
|
50
48
|
e.onChange && u.current && e.onChange.call(void 0, {
|
|
51
49
|
value: t,
|
|
@@ -54,32 +52,32 @@ const A = {
|
|
|
54
52
|
});
|
|
55
53
|
},
|
|
56
54
|
[e.onChange]
|
|
57
|
-
),
|
|
55
|
+
), h = a.useMemo(() => e.min !== void 0 ? e.min : s.min, [e.min]), I = a.useMemo(() => e.max !== void 0 ? e.max : s.max, [e.max]), m = a.useMemo(() => e.precision || s.precision, [e.precision]), i = a.useMemo(() => e.step !== void 0 ? e.step : s.step, [e.step]), x = a.useMemo(() => e.readonly || s.readonly, [e.readonly]), k = a.useMemo(() => e.disabled || s.disabled, [e.disabled]), q = a.useMemo(() => e.item || s.item, [e.item]), [H, p] = W(
|
|
58
56
|
e.defaultValue !== void 0 ? e.defaultValue : s.defaultValue,
|
|
59
57
|
{
|
|
60
58
|
state: e.value,
|
|
61
|
-
min:
|
|
62
|
-
max:
|
|
63
|
-
step:
|
|
59
|
+
min: h,
|
|
60
|
+
max: I,
|
|
61
|
+
step: m === "half" ? i / 2 : i
|
|
64
62
|
},
|
|
65
|
-
|
|
66
|
-
), [
|
|
63
|
+
V
|
|
64
|
+
), [T, N] = W(null, {
|
|
67
65
|
state: e.value,
|
|
68
|
-
min:
|
|
69
|
-
max:
|
|
70
|
-
step:
|
|
71
|
-
precision:
|
|
72
|
-
}),
|
|
66
|
+
min: h,
|
|
67
|
+
max: I,
|
|
68
|
+
step: m === "half" ? i / 2 : i,
|
|
69
|
+
precision: m
|
|
70
|
+
}), d = a.useMemo(
|
|
73
71
|
() => e.value !== void 0 ? e.value : H,
|
|
74
72
|
[e.value, H]
|
|
75
|
-
), C = a.useMemo(() =>
|
|
73
|
+
), C = a.useMemo(() => T, [T]), O = a.useMemo(
|
|
76
74
|
() => e.selection || s.selection,
|
|
77
75
|
[e.selection]
|
|
78
|
-
), M = a.useMemo(() => i / (
|
|
76
|
+
), M = a.useMemo(() => i / (m === "half" ? 2 : 1), [i, m]), G = a.useCallback(
|
|
79
77
|
(t) => {
|
|
80
|
-
if (!(!t.target || !t.target.element ||
|
|
81
|
-
if (
|
|
82
|
-
const l = t.target.element.getBoundingClientRect(), R =
|
|
78
|
+
if (!(!t.target || !t.target.element || x || k)) {
|
|
79
|
+
if (m === "half") {
|
|
80
|
+
const l = t.target.element.getBoundingClientRect(), R = K(o || "ltr", l, t.syntheticEvent.clientX) ? D(t.target.value - i / 2, M) : t.target.value;
|
|
83
81
|
p({ type: r.select, payload: R, event: t.syntheticEvent });
|
|
84
82
|
} else
|
|
85
83
|
p({
|
|
@@ -89,7 +87,7 @@ const A = {
|
|
|
89
87
|
});
|
|
90
88
|
if (e.onClick) {
|
|
91
89
|
const l = {
|
|
92
|
-
value:
|
|
90
|
+
value: d,
|
|
93
91
|
target: u.current,
|
|
94
92
|
syntheticEvent: t.syntheticEvent
|
|
95
93
|
};
|
|
@@ -97,10 +95,10 @@ const A = {
|
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
},
|
|
100
|
-
[e.onClick, p,
|
|
101
|
-
),
|
|
98
|
+
[e.onClick, p, d]
|
|
99
|
+
), _ = a.useCallback(
|
|
102
100
|
(t) => {
|
|
103
|
-
if (!(
|
|
101
|
+
if (!(x || k)) {
|
|
104
102
|
switch (t.keyCode) {
|
|
105
103
|
case E.right:
|
|
106
104
|
t.preventDefault(), p({
|
|
@@ -134,14 +132,14 @@ const A = {
|
|
|
134
132
|
break;
|
|
135
133
|
}
|
|
136
134
|
e.onKeyDown && e.onKeyDown.call(void 0, {
|
|
137
|
-
value:
|
|
135
|
+
value: d,
|
|
138
136
|
target: u.current,
|
|
139
137
|
syntheticEvent: t
|
|
140
138
|
});
|
|
141
139
|
}
|
|
142
140
|
},
|
|
143
|
-
[e.onKeyDown, p,
|
|
144
|
-
),
|
|
141
|
+
[e.onKeyDown, p, d]
|
|
142
|
+
), j = a.useCallback(
|
|
145
143
|
(t) => {
|
|
146
144
|
if (e.onFocus) {
|
|
147
145
|
const l = {
|
|
@@ -152,7 +150,7 @@ const A = {
|
|
|
152
150
|
}
|
|
153
151
|
},
|
|
154
152
|
[e.onFocus]
|
|
155
|
-
),
|
|
153
|
+
), J = a.useCallback(
|
|
156
154
|
(t) => {
|
|
157
155
|
if (e.onBlur) {
|
|
158
156
|
const l = {
|
|
@@ -163,28 +161,28 @@ const A = {
|
|
|
163
161
|
}
|
|
164
162
|
},
|
|
165
163
|
[e.onBlur]
|
|
166
|
-
),
|
|
164
|
+
), Q = a.useCallback(
|
|
167
165
|
(t) => {
|
|
168
166
|
if (!(!t.target || !t.target.element))
|
|
169
|
-
if (
|
|
170
|
-
const l = t.target.element.getBoundingClientRect(), R =
|
|
171
|
-
|
|
167
|
+
if (m === "half") {
|
|
168
|
+
const l = t.target.element.getBoundingClientRect(), R = K(o || "ltr", l, t.syntheticEvent.clientX) ? t.target.value - i / 2 : t.target.value;
|
|
169
|
+
N({ type: r.select, payload: R, event: t.syntheticEvent });
|
|
172
170
|
} else
|
|
173
|
-
|
|
171
|
+
N({
|
|
174
172
|
type: r.select,
|
|
175
173
|
payload: t.target.value,
|
|
176
174
|
event: t.syntheticEvent
|
|
177
175
|
});
|
|
178
176
|
},
|
|
179
|
-
[
|
|
180
|
-
),
|
|
181
|
-
|
|
182
|
-
}, []),
|
|
183
|
-
for (let t =
|
|
184
|
-
const l = D(t +
|
|
185
|
-
|
|
177
|
+
[m, i, o]
|
|
178
|
+
), U = a.useCallback((t) => {
|
|
179
|
+
N({ type: r.reset, event: t.syntheticEvent });
|
|
180
|
+
}, []), P = [], Y = ie(D(I - h, M), i);
|
|
181
|
+
for (let t = h || i; t <= I; t = D(t + i, M)) {
|
|
182
|
+
const l = D(t + Y, M), f = m === "half" ? re(l, C !== null ? C : d !== null ? d : 0, i) : !1, R = F(l, d, i, O), B = F(l, C !== null ? C : d, i, O), b = F(l, C, i, O);
|
|
183
|
+
P.push(
|
|
186
184
|
/* @__PURE__ */ a.createElement(
|
|
187
|
-
|
|
185
|
+
q,
|
|
188
186
|
{
|
|
189
187
|
key: l,
|
|
190
188
|
value: l,
|
|
@@ -193,24 +191,24 @@ const A = {
|
|
|
193
191
|
icon: e.icon,
|
|
194
192
|
svgIcon: e.svgIcon,
|
|
195
193
|
half: f,
|
|
196
|
-
selected: R ||
|
|
194
|
+
selected: R || B,
|
|
197
195
|
hovered: b,
|
|
198
|
-
onClick:
|
|
199
|
-
onMouseMove:
|
|
200
|
-
onMouseLeave:
|
|
196
|
+
onClick: G,
|
|
197
|
+
onMouseMove: Q,
|
|
198
|
+
onMouseLeave: U
|
|
201
199
|
},
|
|
202
200
|
f && /* @__PURE__ */ a.createElement("span", { className: "k-rating-precision-complement" }, !(e.icon || e.svgIconOutline) && /* @__PURE__ */ a.createElement(
|
|
203
201
|
y,
|
|
204
202
|
{
|
|
205
203
|
name: "star",
|
|
206
|
-
icon:
|
|
204
|
+
icon: A,
|
|
207
205
|
style: { clipPath: `${o === "rtl" ? "inset(0 50% 0 0)" : "inset(0 0 0 50%)"}` },
|
|
208
206
|
size: "xlarge"
|
|
209
207
|
}
|
|
210
208
|
), (e.icon || e.svgIconOutline) && /* @__PURE__ */ a.createElement(
|
|
211
209
|
y,
|
|
212
210
|
{
|
|
213
|
-
name:
|
|
211
|
+
name: z(`${e.icon}-outline`),
|
|
214
212
|
icon: e.svgIconOutline,
|
|
215
213
|
size: "xlarge"
|
|
216
214
|
}
|
|
@@ -219,23 +217,23 @@ const A = {
|
|
|
219
217
|
y,
|
|
220
218
|
{
|
|
221
219
|
name: "star",
|
|
222
|
-
icon:
|
|
220
|
+
icon: S,
|
|
223
221
|
style: { clipPath: `${o === "rtl" ? "inset(0 0 0 50%)" : "inset(0 50% 0 0)"}` },
|
|
224
222
|
size: "xlarge"
|
|
225
223
|
}
|
|
226
224
|
), (e.icon || e.svgIcon) && /* @__PURE__ */ a.createElement(
|
|
227
225
|
y,
|
|
228
226
|
{
|
|
229
|
-
name: e.icon ?
|
|
227
|
+
name: e.icon ? z(e.icon) : void 0,
|
|
230
228
|
icon: e.svgIcon,
|
|
231
229
|
size: "xlarge"
|
|
232
230
|
}
|
|
233
231
|
)),
|
|
234
232
|
f && /* @__PURE__ */ a.createElement("span", { style: { width: "24px", height: "24px", display: "block" } }),
|
|
235
|
-
!f && !(e.icon || e.svgIcon) && (b ||
|
|
233
|
+
!f && !(e.icon || e.svgIcon) && (b || B && !b) && /* @__PURE__ */ a.createElement(y, { name: "star", icon: S, size: "xlarge" }) || !(e.icon || e.svgIcon) && !b && !B && /* @__PURE__ */ a.createElement(y, { name: "star", icon: A, size: "xlarge" }) || (e.icon || e.svgIcon) && (b || B && !b) && /* @__PURE__ */ a.createElement(y, { name: e.icon, icon: e.svgIcon, size: "xlarge" }) || (e.icon || e.svgIcon) && !b && /* @__PURE__ */ a.createElement(
|
|
236
234
|
y,
|
|
237
235
|
{
|
|
238
|
-
name:
|
|
236
|
+
name: z(`${e.icon}-outline`),
|
|
239
237
|
icon: e.svgIconOutline,
|
|
240
238
|
size: "xlarge"
|
|
241
239
|
}
|
|
@@ -248,49 +246,50 @@ const A = {
|
|
|
248
246
|
{
|
|
249
247
|
id: e.id,
|
|
250
248
|
style: e.style,
|
|
251
|
-
ref:
|
|
249
|
+
ref: w,
|
|
252
250
|
role: "slider",
|
|
253
251
|
dir: o,
|
|
254
|
-
tabIndex:
|
|
255
|
-
className:
|
|
252
|
+
tabIndex: ne(e.tabIndex, e.disabled, void 0),
|
|
253
|
+
className: ae(
|
|
256
254
|
"k-rating",
|
|
257
255
|
{
|
|
258
256
|
"k-rtl": o === "rtl",
|
|
259
|
-
"k-readonly":
|
|
257
|
+
"k-readonly": x,
|
|
260
258
|
"k-disabled": k
|
|
261
259
|
},
|
|
262
260
|
e.className
|
|
263
261
|
),
|
|
264
|
-
onKeyDown:
|
|
265
|
-
onFocus:
|
|
266
|
-
onBlur:
|
|
267
|
-
"aria-valuemin":
|
|
268
|
-
"aria-valuemax":
|
|
269
|
-
"aria-valuenow":
|
|
262
|
+
onKeyDown: _,
|
|
263
|
+
onFocus: j,
|
|
264
|
+
onBlur: J,
|
|
265
|
+
"aria-valuemin": h,
|
|
266
|
+
"aria-valuemax": I,
|
|
267
|
+
"aria-valuenow": d !== null ? d : void 0,
|
|
270
268
|
"aria-disabled": k ? "true" : void 0,
|
|
271
|
-
"aria-
|
|
269
|
+
"aria-readonly": x ? "true" : void 0,
|
|
270
|
+
"aria-label": e.ariaLabel,
|
|
272
271
|
"aria-labelledby": e.ariaLabelledBy,
|
|
273
272
|
"aria-describedby": e.ariaDescribedBy
|
|
274
273
|
},
|
|
275
|
-
/* @__PURE__ */ a.createElement("input", { type: "hidden", id: "rating", readOnly:
|
|
276
|
-
/* @__PURE__ */ a.createElement("span", { className: "k-rating-container" },
|
|
274
|
+
/* @__PURE__ */ a.createElement("input", { type: "hidden", id: "rating", readOnly: x, disabled: k }),
|
|
275
|
+
/* @__PURE__ */ a.createElement("span", { className: "k-rating-container" }, P),
|
|
277
276
|
e.label && /* @__PURE__ */ a.createElement("span", { className: "k-rating-label" }, e.label)
|
|
278
277
|
);
|
|
279
|
-
}),
|
|
278
|
+
}), ue = {
|
|
280
279
|
id: c.string,
|
|
281
280
|
dir: c.oneOf(["ltr", "rtl"]),
|
|
282
281
|
selection: c.oneOf(["continues", "single"]),
|
|
283
282
|
precision: c.oneOf(["item", "half"]),
|
|
284
|
-
value: (n,
|
|
285
|
-
`Invalid prop + ${
|
|
283
|
+
value: (n, v, g) => n.value && n.min && n.max && n.step && !(n.precision === "half" ? L(n.min, n.max, n.step / 2, n.value) : L(n.min, n.max, n.step, n.value)) && n.precision === "half" ? new Error(
|
|
284
|
+
`Invalid prop + ${v} supplied to ${g}.
|
|
286
285
|
The value of the { value } property is not correct, please check your values.
|
|
287
286
|
`
|
|
288
287
|
) : null,
|
|
289
288
|
defaultValue: c.number,
|
|
290
289
|
min: c.number,
|
|
291
290
|
max: c.number,
|
|
292
|
-
step: (n,
|
|
293
|
-
`Invalid prop + ${
|
|
291
|
+
step: (n, v, g) => n.step !== void 0 && n.step <= 0 ? new Error(
|
|
292
|
+
`Invalid prop + ${v} supplied to ${g}.
|
|
294
293
|
The value of the { step } property is cannot be equal or less than "0", please check your values.
|
|
295
294
|
`
|
|
296
295
|
) : null,
|
|
@@ -299,24 +298,24 @@ const A = {
|
|
|
299
298
|
readonly: c.bool,
|
|
300
299
|
disabled: c.bool,
|
|
301
300
|
icon: c.string,
|
|
302
|
-
svgIcon:
|
|
303
|
-
svgIconOutline:
|
|
301
|
+
svgIcon: $,
|
|
302
|
+
svgIconOutline: $,
|
|
304
303
|
ariaDescribedBy: c.string
|
|
305
304
|
}, s = {
|
|
306
305
|
dir: "ltr",
|
|
307
306
|
min: 0,
|
|
308
307
|
max: 5,
|
|
309
308
|
step: 1,
|
|
310
|
-
item:
|
|
309
|
+
item: se,
|
|
311
310
|
defaultValue: null,
|
|
312
311
|
readonly: !1,
|
|
313
312
|
disabled: !1,
|
|
314
313
|
selection: "continues",
|
|
315
314
|
precision: "item"
|
|
316
315
|
};
|
|
317
|
-
|
|
318
|
-
|
|
316
|
+
X.displayName = "KendoReactRating";
|
|
317
|
+
X.propTypes = ue;
|
|
319
318
|
export {
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
X as Rating,
|
|
320
|
+
ce as RatingPropsContext
|
|
322
321
|
};
|
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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ze=require("@progress/kendo-inputs-common"),D=require("@progress/kendo-react-buttons"),a=require("@progress/kendo-react-common"),Oe=require("@progress/kendo-react-dialogs"),Ee=require("@progress/kendo-react-intl"),s=require("prop-types"),xe=require("react"),u=require("../messages/index.js"),te=require("../package-metadata.js"),Me=require("./utils/index.js"),_=require("@progress/kendo-svg-icons");function Le(c){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const g in c)if(g!=="default"){const v=Object.getOwnPropertyDescriptor(c,g);Object.defineProperty(k,g,v.get?v:{enumerable:!0,get:()=>c[g]})}}return k.default=c,Object.freeze(k)}const n=Le(xe),Ie=250,Pe=84,oe=3,ae=2,Re="#000000",we="#ffffff",ne=c=>c!==void 0,se=a.createPropsContext(),x=n.forwardRef((c,k)=>{const g=!a.validatePackage(te.packageMetadata,{component:"Signature"}),v=a.getLicenseMessage(te.packageMetadata),N=a.usePropsContext(se,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,...N}),[N]),y=Ee.useLocalization(),m=n.useRef(null),C=n.useRef(null),F=n.useRef(null),j=n.useRef(null),M=n.useRef(null),[r,re]=n.useState(),[h,W]=n.useState(!1),[S,G]=n.useState(),[ie,le]=n.useState(),A=ne(e.value)?e.value:S,[ce,ue]=n.useState(!1),b=ne(e.open),f=b?e.open:ce,de=e.disabled||e.maximized||!e.maximizable,pe=e.disabled||!e.maximized,me=!(!(e.value||S)||e.disabled||e.readOnly),V=y.toLanguageString(u.signatureMaximize,u.messages[u.signatureMaximize]),U=y.toLanguageString(u.signatureMinimize,u.messages[u.signatureMinimize]),H=y.toLanguageString(u.signatureClear,u.messages[u.signatureClear]),ge=y.toLanguageString(u.signatureCanvas,u.messages[u.signatureCanvas]),L=e.popupScale||oe,I=e.exportScale||ae,P=t=>{G(t),e.onChange&&e.onChange({value:t})},fe=t=>{r==null||r.loadImage(t.value),P(t.value)};n.useEffect(()=>{e.value!==S&&(G(e.value),r==null||r.loadImage(e.value))},[e.value]);const ke=()=>{r==null||r.clear(),P()},z=n.useCallback(t=>{b||ue(t)},[b]),be=t=>{var o,i;Y(t),(i=((o=M.current)==null?void 0:o.element)||C.current)==null||i.focus()},R=n.useCallback(()=>{let t=Re;return!e.color&&typeof document!="undefined"&&m.current&&(t=getComputedStyle(m.current).color),e.color||t},[e.color]),w=n.useCallback(()=>{let t=we;return!e.backgroundColor&&typeof document!="undefined"&&m.current&&(t=getComputedStyle(m.current).backgroundColor),e.backgroundColor||t},[e.backgroundColor]),$=()=>({scale:e.maximized?e.popupScale:1,color:R(),backgroundColor:w(),strokeWidth:e.strokeWidth,smooth:e.smooth,readonly:e.readOnly||e.disabled}),K=async t=>{const{width:o,height:i}=t;return await(r==null?void 0:r.exportImage({width:o*I,height:i*I}))};n.useEffect(()=>{const t=C.current,o=new ze.SignaturePad(t,$());return A&&o.loadImage(A),re(o),()=>o.destroy()},[]),n.useEffect(()=>{r==null||r.setOptions({onChange:async()=>P(await K(Z()))})},[r]),a.useIsomorphicLayoutEffect(()=>r==null?void 0:r.setOptions($()),[e.readOnly,e.disabled,e.color,e.backgroundColor,e.strokeWidth,e.smooth]),n.useEffect(()=>{var i,p;const t=(p=(i=F.current)==null?void 0:i.element)==null?void 0:p.querySelector(".k-overlay");if(!t)return;const o=()=>z(!1);return t.addEventListener("click",o),()=>t.removeEventListener("click",o)},[f]),n.useEffect(()=>{if(!f||typeof document=="undefined")return;const t=o=>{var i,p;o.key==="Escape"&&(z(!1),(p=(i=M.current)==null?void 0:i.element)==null||p.focus())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[f]),n.useEffect(()=>{var t,o;e.maximized&&((o=(t=j.current)==null?void 0:t.element)==null||o.focus())},[]);const q=n.useCallback(()=>{var t;return(t=C.current)==null?void 0:t.focus()},[]),O=n.useCallback(()=>e.value,[e.value]),X=n.useCallback(()=>e.name,[e.name]),E=n.useCallback(()=>e.required,[e.required]),T=n.useCallback(()=>{const t=e.validationMessage!==void 0,i=!O(),p=e.valid!==void 0?e.valid:!E()||!i;return{customError:t,valid:p,valueMissing:i}},[e.validationMessage,e.valid,O,E]),B=n.useCallback(()=>e.validityStyles,[e.validityStyles]),J=n.useCallback(()=>e,[e]),d=n.useCallback(()=>{const t={element:m.current,focus:q};return Object.defineProperty(t,"name",{get:X}),Object.defineProperty(t,"value",{get:O}),Object.defineProperty(t,"validity",{get:T}),Object.defineProperty(t,"validityStyles",{get:B}),Object.defineProperty(t,"required",{get:E}),Object.defineProperty(t,"props",{get:J}),Object.defineProperty(t,"color",{get:R}),Object.defineProperty(t,"backgroundColor",{get:w}),t},[X,O,T,B,E,q,J,R,w]);n.useImperativeHandle(k,d);const Q=n.useRef(null);n.useImperativeHandle(Q,d),a.useWebMcpRegister("signature",Q,e,e.webMcp);const ve=n.useCallback(t=>{h||e.maximized||(W(!0),a.dispatchEvent(e.onFocus,t,d(),{}))},[h,e.onFocus,d]),ye=n.useCallback(t=>{Me.hasParent(t.relatedTarget,m.current)||(W(!1),a.dispatchEvent(e.onBlur,t,d(),{}))},[h,e.onBlur,d]),Ce=n.useCallback(async t=>{le(await K(ee())),z(!0),a.dispatchEvent(e.onOpen,t,d(),{})},[f,b,e.onOpen,e.value,S,d]),Y=n.useCallback(t=>{z(!1),a.dispatchEvent(e.onClose,t,d(),{})},[f,b,e.onClose,d]),he=()=>{ke(),q()},Z=()=>{var i,p;const t=e.width||((i=m.current)==null?void 0:i.offsetWidth)||Ie,o=e.height||((p=m.current)==null?void 0:p.offsetHeight)||Pe;return{width:t,height:o}},ee=()=>{const{width:t,height:o}=Z();return{width:t*L,height:o*L}},Se=!B()||T().valid;return n.createElement("div",{ref:m,dir:e.dir,style:{width:e.width,height:e.height,...e.style},className:a.classNames("k-input","k-signature",{"k-signature-maximized":e.maximized,[`k-signature-${a.kendoThemeMaps.sizeMap[e.size]||e.size}`]:e.size,[`k-signature-${e.fillMode}`]:e.fillMode,[`k-input-${e.fillMode}`]:e.fillMode,[`k-rounded-${a.kendoThemeMaps.roundedMap[e.rounded]||e.rounded}`]:e.rounded,"k-invalid":!Se,"k-required":e.required,"k-disabled":e.disabled,"k-focus":h},e.className),onFocus:ve,onBlur:ye},n.createElement("div",{className:"k-signature-canvas",ref:C,role:"img",tabIndex:a.getTabIndex(e.tabIndex,e.disabled),id:e.id,"aria-label":e.ariaLabel||ge,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,style:e.inputStyle}),n.createElement("div",{className:"k-signature-actions k-signature-actions-top"},n.createElement(D.Button,{type:"button",className:a.classNames("k-signature-action","k-signature-maximize",{"k-hidden":de}),ref:M,icon:"hyperlink-open",svgIcon:_.hyperlinkOpenIcon,size:e.size,rounded:e.rounded,fillMode:"flat",onClick:Ce,"aria-label":V,title:V}),n.createElement(D.Button,{type:"button",className:a.classNames("k-signature-action","k-signature-minimize k-flip-h k-flip-v",{"k-hidden":pe}),ref:j,icon:"hyperlink-open",svgIcon:_.hyperlinkOpenIcon,size:e.size,rounded:e.rounded,fillMode:"flat",onClick:Y,"aria-label":U,title:U})),!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(D.Button,{type:"button",className:"k-signature-action k-signature-clear",icon:"x",svgIcon:_.xIcon,size:e.size,rounded:e.rounded,fillMode:"flat",onClick:he,"aria-label":H,title:H})),f&&n.createElement(Oe.Dialog,{ref:F},n.createElement(x,{...e,...ee(),value:ie,maximized:!0,exportScale:1/L*I,open:!1,onChange:fe,onClose:be})),g&&n.createElement(a.WatermarkOverlay,{message:v}))});x.propTypes={value:s.string,width:s.number,height:s.number,tabIndex:s.number,dir:s.string,ariaDescribedBy:s.string,ariaLabelledBy:s.string,ariaLabel:s.string,readOnly:s.bool,disabled:s.bool,validationMessage:s.string,required:s.bool,onChange:s.func,onFocus:s.func,onBlur:s.func,onOpen:s.func,onClose:s.func,size:s.oneOf(["small","medium","large"]),rounded:s.oneOf(["small","medium","large","none"]),fillMode:s.oneOf(["solid","flat","outline"])};const l={strokeWidth:1,smooth:!1,popupScale:oe,exportScale:ae,maximizable:!0,disabled:!1,required:!1,validityStyles:!0,onChange:c=>a.noop,onFocus:c=>a.noop,onBlur:c=>a.noop,onOpen:c=>a.noop,onClose:c=>a.noop,size:void 0,rounded:void 0,fillMode:void 0};x.displayName="KendoSignature";exports.Signature=x;exports.SignaturePropsContext=se;
|