@progress/kendo-react-inputs 14.5.0-develop.12 → 14.5.0-develop.14
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/MaskedTextBoxMcpWrapper.d.ts +17 -0
- package/MaskedTextBoxMcpWrapper.js +8 -0
- package/MaskedTextBoxMcpWrapper.mjs +18 -0
- package/colors/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +194 -183
- package/colors/interfaces/ColorPickerProps.d.ts +6 -1
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +5 -1
- package/index.d.ts +5 -1
- package/index.js +1 -1
- package/index.mjs +92 -89
- package/maskedtextbox/MaskedTextBoxProps.d.ts +6 -1
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +170 -168
- package/numerictextbox/interfaces/NumericTextBoxProps.d.ts +6 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +10 -10
- package/range-slider/RangeSlider.d.ts +6 -1
- package/range-slider/RangeSlider.js +2 -2
- package/range-slider/RangeSlider.mjs +43 -43
- package/rating/Rating.d.ts +6 -1
- package/rating/Rating.js +2 -2
- package/rating/Rating.mjs +62 -62
- package/signature/Signature.js +1 -1
- package/signature/Signature.mjs +94 -92
- package/signature/interfaces/SignatureProps.d.ts +6 -1
- package/slider/Slider.d.ts +6 -1
- package/slider/Slider.js +1 -1
- package/slider/Slider.mjs +131 -134
- package/switch/Switch.d.ts +6 -1
- package/switch/Switch.js +1 -1
- package/switch/Switch.mjs +88 -86
- package/textarea/TextArea.js +1 -1
- package/textarea/TextArea.mjs +97 -95
- package/textarea/interfaces/TextAreaProps.d.ts +6 -1
- package/textbox/Textbox.d.ts +20 -1
- package/textbox/Textbox.js +1 -1
- package/textbox/Textbox.mjs +92 -81
package/slider/Slider.mjs
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as r from "react";
|
|
9
|
-
import { useState as L, useRef as R, useMemo as N, useEffect as
|
|
10
|
-
import
|
|
11
|
-
import { withPropsContext as ue, dispatchEvent as fe, Keys as m,
|
|
12
|
-
import { LocalizationService as
|
|
13
|
-
import { sliderDragTitle as
|
|
14
|
-
import { SLIDER_LABEL_ATTRIBUTE as
|
|
9
|
+
import { useState as L, useRef as R, useMemo as N, useEffect as H, useCallback as c, useImperativeHandle as me } from "react";
|
|
10
|
+
import a from "prop-types";
|
|
11
|
+
import { withPropsContext as ue, dispatchEvent as fe, Keys as m, useWebMcpRegister as ge, classNames as ve, Draggable as he, getTabIndex as be, createPropsContext as ye } from "@progress/kendo-react-common";
|
|
12
|
+
import { LocalizationService as ke, registerForLocalization as xe } from "@progress/kendo-react-intl";
|
|
13
|
+
import { sliderDragTitle as O, messages as z, sliderDecreaseValue as W, sliderIncreaseValue as X } from "../messages/index.mjs";
|
|
14
|
+
import { SLIDER_LABEL_ATTRIBUTE as Se } from "./SliderLabel.mjs";
|
|
15
15
|
import { Button as _ } from "@progress/kendo-react-buttons";
|
|
16
|
-
import { chevronUpIcon as j, chevronLeftIcon as G, chevronDownIcon as
|
|
16
|
+
import { chevronUpIcon as j, chevronLeftIcon as G, chevronDownIcon as Y, chevronRightIcon as J } from "@progress/kendo-svg-icons";
|
|
17
17
|
const g = {
|
|
18
18
|
step: 1,
|
|
19
19
|
largeStep: 10,
|
|
@@ -21,164 +21,161 @@ const g = {
|
|
|
21
21
|
vertical: !1,
|
|
22
22
|
disabled: !1,
|
|
23
23
|
tabIndex: 0
|
|
24
|
-
}, B = r.forwardRef((
|
|
25
|
-
var
|
|
24
|
+
}, B = r.forwardRef((e, V) => {
|
|
25
|
+
var K, U, q;
|
|
26
26
|
const {
|
|
27
27
|
step: u = g.step,
|
|
28
28
|
largeStep: C = g.largeStep,
|
|
29
|
-
vertical:
|
|
29
|
+
vertical: i = g.vertical,
|
|
30
30
|
disabled: d = g.disabled,
|
|
31
31
|
tabIndex: Q = g.tabIndex
|
|
32
|
-
} =
|
|
33
|
-
const
|
|
34
|
-
return
|
|
35
|
-
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, [l, t.min, t.max]), f = (K = t.dir) != null ? K : I;
|
|
39
|
-
q(() => {
|
|
40
|
-
if (t.dir === void 0 && v.current) {
|
|
32
|
+
} = e, [Z, $] = L((K = e.defaultValue) != null ? K : e.min), [p, A] = L(!1), [I, ee] = L(e.dir), E = R(null), v = R(null), T = N(() => new ke(), []), F = R(null), D = e.value !== void 0, k = D && e.value !== void 0 ? e.value : Z, l = N(() => k < e.min ? e.min : k > e.max ? e.max : k, [k, e.min, e.max]), h = N(() => {
|
|
33
|
+
const t = e.max - e.min;
|
|
34
|
+
return t === 0 ? 0 : (l - e.min) / t * 100;
|
|
35
|
+
}, [l, e.min, e.max]), f = (U = e.dir) != null ? U : I;
|
|
36
|
+
H(() => {
|
|
37
|
+
if (e.dir === void 0 && v.current) {
|
|
41
38
|
const n = window.getComputedStyle(v.current).direction;
|
|
42
39
|
n !== I && ee(n);
|
|
43
40
|
}
|
|
44
|
-
}, [
|
|
45
|
-
const
|
|
46
|
-
let n =
|
|
41
|
+
}, [e.dir, I]);
|
|
42
|
+
const M = c((t) => {
|
|
43
|
+
let n = t;
|
|
47
44
|
for (; n; ) {
|
|
48
|
-
if (n.getAttribute(
|
|
45
|
+
if (n.getAttribute(Se))
|
|
49
46
|
return !0;
|
|
50
47
|
n = n.parentElement;
|
|
51
48
|
}
|
|
52
49
|
return !1;
|
|
53
|
-
}, []), s =
|
|
54
|
-
(
|
|
55
|
-
const
|
|
56
|
-
D || $(
|
|
50
|
+
}, []), s = c(
|
|
51
|
+
(t, n) => {
|
|
52
|
+
const o = Math.min(Math.max(n, e.min), e.max);
|
|
53
|
+
D || $(o), fe(e.onChange, t, F.current, { value: o });
|
|
57
54
|
},
|
|
58
|
-
[
|
|
59
|
-
), te =
|
|
60
|
-
|
|
61
|
-
}, []), ne =
|
|
62
|
-
|
|
63
|
-
}, []),
|
|
64
|
-
(
|
|
55
|
+
[e.min, e.max, e.onChange, D]
|
|
56
|
+
), te = c(() => {
|
|
57
|
+
A(!0);
|
|
58
|
+
}, []), ne = c(() => {
|
|
59
|
+
A(!1);
|
|
60
|
+
}, []), ie = c(
|
|
61
|
+
(t) => {
|
|
65
62
|
if (d)
|
|
66
63
|
return;
|
|
67
64
|
let n;
|
|
68
|
-
|
|
65
|
+
t.keyCode === m.left || t.keyCode === m.down ? n = l - (u || 0) : t.keyCode === m.right || t.keyCode === m.up ? n = l + (u || 0) : t.keyCode === m.pageDown ? n = l - (C || 0) : t.keyCode === m.pageUp ? n = l + (C || 0) : t.keyCode === m.home ? n = e.min : t.keyCode === m.end && (n = e.max), n !== void 0 && (t.preventDefault(), s(t, n));
|
|
69
66
|
},
|
|
70
|
-
[l, u, C,
|
|
71
|
-
),
|
|
72
|
-
(
|
|
73
|
-
|
|
67
|
+
[l, u, C, e.min, e.max, s, d]
|
|
68
|
+
), ae = c(
|
|
69
|
+
(t) => {
|
|
70
|
+
t.preventDefault(), !d && s(t, l - (u || 0));
|
|
74
71
|
},
|
|
75
72
|
[l, u, s, d]
|
|
76
|
-
), re =
|
|
77
|
-
(
|
|
78
|
-
|
|
73
|
+
), re = c(
|
|
74
|
+
(t) => {
|
|
75
|
+
t.preventDefault(), !d && s(t, l + (u || 0));
|
|
79
76
|
},
|
|
80
77
|
[l, u, s, d]
|
|
81
|
-
), x =
|
|
82
|
-
(
|
|
83
|
-
const n =
|
|
84
|
-
let
|
|
85
|
-
|
|
86
|
-
const b =
|
|
87
|
-
s(
|
|
78
|
+
), x = c(
|
|
79
|
+
(t) => {
|
|
80
|
+
const n = t.element.getBoundingClientRect();
|
|
81
|
+
let o;
|
|
82
|
+
i ? o = n.bottom - t.event.clientY : o = f === "rtl" ? n.right - t.event.clientX : t.event.clientX - n.left;
|
|
83
|
+
const b = i ? n.height : n.width, y = o / b;
|
|
84
|
+
s(t, e.min + y * (e.max - e.min));
|
|
88
85
|
},
|
|
89
|
-
[
|
|
90
|
-
), le =
|
|
91
|
-
(
|
|
92
|
-
|
|
86
|
+
[i, e.min, e.max, f, s]
|
|
87
|
+
), le = c(
|
|
88
|
+
(t) => {
|
|
89
|
+
M(t.event.originalEvent.target) || (t.event.isTouch && t.event.originalEvent.preventDefault(), x(t));
|
|
93
90
|
},
|
|
94
|
-
[
|
|
95
|
-
), ce =
|
|
96
|
-
(
|
|
97
|
-
|
|
91
|
+
[M, x]
|
|
92
|
+
), ce = c(
|
|
93
|
+
(t) => {
|
|
94
|
+
t.event.originalEvent.preventDefault(), x(t);
|
|
98
95
|
},
|
|
99
96
|
[x]
|
|
100
|
-
), S =
|
|
97
|
+
), S = c(() => {
|
|
101
98
|
v.current && v.current.focus();
|
|
102
|
-
}, []), oe =
|
|
103
|
-
(
|
|
104
|
-
if (!
|
|
105
|
-
return
|
|
106
|
-
let n,
|
|
107
|
-
return f === "rtl" ? (n =
|
|
99
|
+
}, []), oe = c(
|
|
100
|
+
(t) => {
|
|
101
|
+
if (!t.enabled)
|
|
102
|
+
return t.children;
|
|
103
|
+
let n, o, b, y;
|
|
104
|
+
return f === "rtl" ? (n = i ? j : G, o = i ? Y : J, b = i ? "chevron-up" : "chevron-left", y = i ? "chevron-down" : "chevron-right") : (n = i ? j : J, o = i ? Y : G, b = i ? "chevron-up" : "chevron-right", y = i ? "chevron-down" : "chevron-left"), /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
|
|
108
105
|
_,
|
|
109
106
|
{
|
|
110
107
|
className: "k-button-decrease",
|
|
111
108
|
rounded: "full",
|
|
112
109
|
icon: y,
|
|
113
|
-
svgIcon:
|
|
114
|
-
title:
|
|
115
|
-
onClick:
|
|
110
|
+
svgIcon: o,
|
|
111
|
+
title: t.decrementTitle,
|
|
112
|
+
onClick: t.decrement
|
|
116
113
|
}
|
|
117
|
-
),
|
|
114
|
+
), t.children, /* @__PURE__ */ r.createElement(
|
|
118
115
|
_,
|
|
119
116
|
{
|
|
120
117
|
className: "k-button-increase",
|
|
121
118
|
rounded: "full",
|
|
122
119
|
icon: b,
|
|
123
120
|
svgIcon: n,
|
|
124
|
-
title:
|
|
125
|
-
onClick:
|
|
121
|
+
title: t.incrementTitle,
|
|
122
|
+
onClick: t.increment
|
|
126
123
|
}
|
|
127
124
|
));
|
|
128
125
|
},
|
|
129
|
-
[f,
|
|
126
|
+
[f, i]
|
|
130
127
|
);
|
|
131
128
|
me(
|
|
132
|
-
|
|
129
|
+
V,
|
|
133
130
|
() => ({
|
|
134
|
-
props:
|
|
131
|
+
props: e,
|
|
135
132
|
sliderTrack: E.current,
|
|
136
133
|
focus: S
|
|
137
134
|
}),
|
|
138
|
-
[
|
|
139
|
-
),
|
|
140
|
-
|
|
141
|
-
props:
|
|
135
|
+
[e, S]
|
|
136
|
+
), ge("slider", V, e, e.webMcp), H(() => {
|
|
137
|
+
F.current = {
|
|
138
|
+
props: e,
|
|
142
139
|
sliderTrack: E.current,
|
|
143
140
|
focus: S
|
|
144
141
|
};
|
|
145
|
-
}, [
|
|
146
|
-
const de =
|
|
142
|
+
}, [e, S]);
|
|
143
|
+
const de = i ? { marginTop: "0.5rem", marginBottom: "0.5rem" } : { marginLeft: "0.5rem", marginRight: "0.5rem" }, se = i ? { paddingTop: 0, height: "100%" } : {};
|
|
147
144
|
let w;
|
|
148
|
-
return
|
|
145
|
+
return i ? w = { bottom: "calc(" + h + "%)", zIndex: 1 } : f === "rtl" ? w = { right: "calc(" + h + "% - 13px)", zIndex: 1 } : w = { left: "calc(" + h + "%)", zIndex: 1 }, /* @__PURE__ */ r.createElement(
|
|
149
146
|
"div",
|
|
150
147
|
{
|
|
151
148
|
ref: v,
|
|
152
149
|
dir: f,
|
|
153
|
-
id:
|
|
154
|
-
style: { gap: 0, ...
|
|
150
|
+
id: e.id,
|
|
151
|
+
style: { gap: 0, ...e.style },
|
|
155
152
|
onFocus: te,
|
|
156
153
|
onBlur: ne,
|
|
157
|
-
onKeyDown:
|
|
158
|
-
className:
|
|
154
|
+
onKeyDown: ie,
|
|
155
|
+
className: ve(
|
|
159
156
|
"k-slider",
|
|
160
157
|
{
|
|
161
158
|
"k-focus": p,
|
|
162
159
|
"k-disabled": d,
|
|
163
|
-
"k-slider-horizontal": !
|
|
164
|
-
"k-slider-vertical":
|
|
160
|
+
"k-slider-horizontal": !i,
|
|
161
|
+
"k-slider-vertical": i
|
|
165
162
|
},
|
|
166
|
-
|
|
163
|
+
e.className
|
|
167
164
|
)
|
|
168
165
|
},
|
|
169
166
|
oe({
|
|
170
|
-
enabled: (
|
|
171
|
-
decrement:
|
|
167
|
+
enabled: (q = e.buttons) != null ? q : g.buttons,
|
|
168
|
+
decrement: ae,
|
|
172
169
|
increment: re,
|
|
173
170
|
incrementTitle: T.toLanguageString(
|
|
174
171
|
X,
|
|
175
172
|
z[X]
|
|
176
173
|
),
|
|
177
174
|
decrementTitle: T.toLanguageString(
|
|
178
|
-
|
|
179
|
-
z[
|
|
175
|
+
W,
|
|
176
|
+
z[W]
|
|
180
177
|
),
|
|
181
|
-
children: /* @__PURE__ */ r.createElement(
|
|
178
|
+
children: /* @__PURE__ */ r.createElement(he, { onDrag: ce, onPress: le, autoScroll: !1 }, /* @__PURE__ */ r.createElement(
|
|
182
179
|
"div",
|
|
183
180
|
{
|
|
184
181
|
className: "k-slider-track-wrap",
|
|
@@ -189,48 +186,48 @@ const g = {
|
|
|
189
186
|
...de
|
|
190
187
|
}
|
|
191
188
|
},
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
e.children && /* @__PURE__ */ r.createElement("ul", { className: "k-reset k-slider-items", style: { margin: 0, ...se } }, r.Children.map(e.children, (t, n) => t && r.cloneElement(
|
|
190
|
+
t,
|
|
194
191
|
{
|
|
195
|
-
position: 100 * (
|
|
196
|
-
vertical:
|
|
192
|
+
position: 100 * (t.props.position - e.min) / (e.max - e.min),
|
|
193
|
+
vertical: i,
|
|
197
194
|
firstTick: n === 0,
|
|
198
|
-
lastTick: n === r.Children.count(
|
|
195
|
+
lastTick: n === r.Children.count(e.children) - 1
|
|
199
196
|
},
|
|
200
|
-
|
|
197
|
+
t.props.children
|
|
201
198
|
))),
|
|
202
199
|
/* @__PURE__ */ r.createElement(
|
|
203
200
|
"div",
|
|
204
201
|
{
|
|
205
202
|
className: "k-slider-track",
|
|
206
|
-
style:
|
|
203
|
+
style: i ? { bottom: 0, height: "100%" } : { [f === "rtl" ? "right" : "left"]: 0, width: "100%" },
|
|
207
204
|
ref: E
|
|
208
205
|
},
|
|
209
206
|
/* @__PURE__ */ r.createElement(
|
|
210
207
|
"div",
|
|
211
208
|
{
|
|
212
209
|
className: "k-slider-selection",
|
|
213
|
-
style:
|
|
210
|
+
style: i ? { height: h + "%" } : { width: h + "%" }
|
|
214
211
|
}
|
|
215
212
|
),
|
|
216
213
|
/* @__PURE__ */ r.createElement(
|
|
217
214
|
"span",
|
|
218
215
|
{
|
|
219
216
|
role: "slider",
|
|
220
|
-
"aria-valuemin":
|
|
221
|
-
"aria-valuemax":
|
|
217
|
+
"aria-valuemin": e.min,
|
|
218
|
+
"aria-valuemax": e.max,
|
|
222
219
|
"aria-valuenow": l,
|
|
223
220
|
"aria-valuetext": String(l),
|
|
224
|
-
"aria-orientation":
|
|
221
|
+
"aria-orientation": i ? "vertical" : void 0,
|
|
225
222
|
"aria-disabled": d ? "true" : void 0,
|
|
226
|
-
"aria-labelledby":
|
|
227
|
-
"aria-describedby":
|
|
228
|
-
"aria-label":
|
|
229
|
-
tabIndex:
|
|
223
|
+
"aria-labelledby": e.ariaLabelledBy,
|
|
224
|
+
"aria-describedby": e.ariaDescribedBy,
|
|
225
|
+
"aria-label": e.ariaLabel,
|
|
226
|
+
tabIndex: be(Q, d, void 0),
|
|
230
227
|
className: "k-draghandle k-draghandle-end",
|
|
231
228
|
title: T.toLanguageString(
|
|
232
|
-
|
|
233
|
-
z[
|
|
229
|
+
O,
|
|
230
|
+
z[O]
|
|
234
231
|
),
|
|
235
232
|
style: w
|
|
236
233
|
}
|
|
@@ -241,32 +238,32 @@ const g = {
|
|
|
241
238
|
);
|
|
242
239
|
});
|
|
243
240
|
B.displayName = "Slider";
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
value:
|
|
248
|
-
defaultValue:
|
|
249
|
-
min:
|
|
250
|
-
max:
|
|
251
|
-
step:
|
|
252
|
-
largeStep:
|
|
253
|
-
onChange:
|
|
254
|
-
style:
|
|
255
|
-
className:
|
|
256
|
-
buttons:
|
|
257
|
-
tabIndex:
|
|
258
|
-
disabled:
|
|
259
|
-
vertical:
|
|
260
|
-
id:
|
|
261
|
-
ariaDescribedBy:
|
|
262
|
-
ariaLabelledBy:
|
|
263
|
-
ariaLabel:
|
|
264
|
-
dir:
|
|
265
|
-
children:
|
|
241
|
+
const we = ye(), P = ue(we, B);
|
|
242
|
+
P.displayName = "KendoReactSlider";
|
|
243
|
+
P.propTypes = {
|
|
244
|
+
value: a.number,
|
|
245
|
+
defaultValue: a.number,
|
|
246
|
+
min: a.number.isRequired,
|
|
247
|
+
max: a.number.isRequired,
|
|
248
|
+
step: a.number,
|
|
249
|
+
largeStep: a.number,
|
|
250
|
+
onChange: a.func,
|
|
251
|
+
style: a.object,
|
|
252
|
+
className: a.string,
|
|
253
|
+
buttons: a.bool,
|
|
254
|
+
tabIndex: a.number,
|
|
255
|
+
disabled: a.bool,
|
|
256
|
+
vertical: a.bool,
|
|
257
|
+
id: a.string,
|
|
258
|
+
ariaDescribedBy: a.string,
|
|
259
|
+
ariaLabelledBy: a.string,
|
|
260
|
+
ariaLabel: a.string,
|
|
261
|
+
dir: a.oneOf(["ltr", "rtl"]),
|
|
262
|
+
children: a.node
|
|
266
263
|
};
|
|
267
|
-
|
|
264
|
+
xe(B);
|
|
268
265
|
export {
|
|
269
|
-
|
|
270
|
-
|
|
266
|
+
P as Slider,
|
|
267
|
+
we as SliderPropsContext,
|
|
271
268
|
B as SliderWithoutContext
|
|
272
269
|
};
|
package/switch/Switch.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { BaseEvent, FormComponentProps, FormComponentValidity } from '@progress/kendo-react-common';
|
|
8
|
+
import { BaseEvent, WebMcpProps, FormComponentProps, FormComponentValidity } from '@progress/kendo-react-common';
|
|
9
9
|
import { ToggleBaseProps } from '../interfaces/ToggleBaseProps';
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
/**
|
|
@@ -243,6 +243,11 @@ export interface SwitchProps extends ToggleBaseProps, FormComponentProps {
|
|
|
243
243
|
* ```
|
|
244
244
|
*/
|
|
245
245
|
ariaLabel?: string;
|
|
246
|
+
/**
|
|
247
|
+
* Enables Web MCP tool registration for this component.
|
|
248
|
+
* Requires a parent `WebMcpProvider` from `@progress/kendo-react-webmcp`.
|
|
249
|
+
*/
|
|
250
|
+
webMcp?: boolean | WebMcpProps;
|
|
246
251
|
}
|
|
247
252
|
/** @hidden */
|
|
248
253
|
export declare const SwitchWithoutContext: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<SwitchHandle>>;
|
package/switch/Switch.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 n=require("react"),t=require("prop-types"),i=require("@progress/kendo-react-common"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),t=require("prop-types"),i=require("@progress/kendo-react-common"),Y=require("@progress/kendo-react-intl"),b=require("../messages/index.js");function Z(e){const h=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const v=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(h,s,v.get?v:{enumerable:!0,get:()=>e[s]})}}return h.default=e,Object.freeze(h)}const d=Z(n),r={disabled:!1,defaultChecked:!1,size:void 0,trackRounded:void 0,thumbRounded:void 0,offLabel:"OFF",onBlur:i.noop,onFocus:i.noop,onLabel:"ON",validityStyles:!0},O=d.forwardRef((e,h)=>{var K;const{disabled:s=r.disabled,defaultChecked:v=r.defaultChecked,size:R=r.size,trackRounded:S=r.trackRounded,thumbRounded:M=r.thumbRounded,offLabel:q=r.offLabel,onBlur:L=r.onBlur,onFocus:E=r.onFocus,onLabel:B=r.onLabel}=e,[D,H]=n.useState(v||!1),[V,P]=n.useState(!1),u=n.useRef(null),o=n.useRef(null),k=n.useRef(null),y=n.useRef(void 0),N=n.useRef(!1),T=n.useRef(void 0),x=n.useMemo(()=>new Y.LocalizationService,[]),c=n.useMemo(()=>y.current!==void 0?y.current:e.checked!==void 0?e.checked:D,[e.checked,D]),g=n.useMemo(()=>{var C,z;const a=e.validationMessage!==void 0,l=(C=e.valid)!=null?C:e.required?!!c:!0,w=(z=e.valid)!=null?z:l;return{customError:a,valid:w,valueMissing:c===null}},[e.valid,e.validationMessage,e.required,c]),W=(K=e.validityStyles)!=null?K:r.validityStyles;n.useEffect(()=>{var a;(a=k.current)!=null&&a.setCustomValidity&&k.current.setCustomValidity(g.valid?"":e.validationMessage||x.toLanguageString(b.switchValidation,b.messages[b.switchValidation]))},[g,e.validationMessage,x]),n.useEffect(()=>{u.current&&(T.current=e.dir||getComputedStyle(u.current).direction||void 0)},[e.dir]);const f=n.useCallback(()=>({props:e,get element(){return u.current},get actionElement(){return o.current},focus:()=>{var a;(a=o.current)==null||a.focus()},get value(){return c},get name(){return e.name},get validity(){return g}}),[e,c,g]),m=n.useCallback((a,l)=>{H(a),y.current=a,i.dispatchEvent(e.onChange,l,{...f(),value:a},{value:a}),y.current=void 0},[e.onChange,f]);n.useEffect(()=>{const a=e.name||e.id,l=i.subscribeToKendoPaste(o.current,{fieldName:a,onValueChange:w=>{if(w!==c){const C={target:o.current,currentTarget:o.current,nativeEvent:new Event("change",{bubbles:!0})};m(w,C)}}});return()=>{l==null||l.unsubscribe()}},[e.name,e.id,c,m]);const _=n.useCallback(a=>{if(a.target===k.current){if(N.current){N.current=!1;return}}else N.current=!0;m(!c,a)},[c,m]),$=n.useCallback(a=>{if(s)return;const{keyCode:l}=a;(l===i.Keys.space||l===i.Keys.enter)&&(m(!c,a),a.preventDefault())},[s,c,m]),A=n.useCallback(a=>{s||(P(!0),E&&E(a))},[s,E]),G=n.useCallback(a=>{s||(P(!1),L&&L(a))},[s,L]);n.useImperativeHandle(h,f,[f]);const F=n.useRef(null);n.useImperativeHandle(F,f,[f]),i.useWebMcpRegister("switch",F,e,e.webMcp);const J=T.current||e.dir||u.current&&getComputedStyle(u.current).direction||void 0,Q=!W||g.valid,U=i.classNames("k-switch",{[`k-switch-${i.kendoThemeMaps.sizeMap[R]||R}`]:R,"k-switch-on":c,"k-switch-off":!c,"k-focus":V,"k-disabled":s,"k-invalid":!Q},e.className),X=d.createElement("input",{type:"checkbox",checked:e.checked,ref:k,tabIndex:-1,"aria-hidden":!0,"aria-label":e.ariaLabel||x.toLanguageString(b.switchAriaLabel,b.messages[b.switchAriaLabel]),value:c,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"},onChange:i.noop,name:e.name||void 0});return d.createElement("span",{ref:o,role:"switch","aria-checked":c,"aria-disabled":s||void 0,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-label":e.ariaLabel,"aria-required":e.required,className:U,dir:J,onKeyDown:$,onClick:_,onBlur:G,onFocus:A,tabIndex:i.getTabIndex(e.tabIndex,s,void 0),accessKey:e.accessKey,id:e.id},d.createElement("span",{className:i.classNames("k-switch-track",{[`k-rounded-${i.kendoThemeMaps.roundedMap[S]||S}`]:S}),ref:u},X,B?d.createElement("span",{className:"k-switch-label-on"},B):"",q?d.createElement("span",{className:"k-switch-label-off"},q):""),d.createElement("span",{className:"k-switch-thumb-wrap"},d.createElement("span",{className:i.classNames("k-switch-thumb",{[`k-rounded-${i.kendoThemeMaps.roundedMap[M]||M}`]:M})})))});O.displayName="Switch";const j=i.createPropsContext(),I=i.withIdHOC(i.withPropsContext(j,O));I.displayName="KendoReactSwitch";I.propTypes={accessKey:t.string,checked:t.bool,className:t.string,defaultChecked:t.bool,defaultValue:t.any,disabled:t.bool,dir:t.string,id:t.string,size:t.oneOf(["small","medium","large"]),trackRounded:t.oneOf(["small","medium","large","full"]),thumbRounded:t.oneOf(["small","medium","large","full"]),ariaDescribedBy:t.string,ariaLabelledBy:t.string,ariaLabel:t.string,offLabel:t.node,onBlur:t.func,onChange:t.func,onFocus:t.func,onLabel:t.node,tabIndex:t.number,value:t.any,name:t.string,required:t.bool,valid:t.bool,validationMessage:t.string,validityStyles:t.bool};exports.Switch=I;exports.SwitchPropsContext=j;exports.SwitchWithoutContext=O;
|