@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/signature/Signature.mjs
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { SignaturePad as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { validatePackage as
|
|
11
|
-
import { Dialog as
|
|
12
|
-
import { useLocalization as
|
|
8
|
+
import { SignaturePad as we } from "@progress/kendo-inputs-common";
|
|
9
|
+
import { Button as T } from "@progress/kendo-react-buttons";
|
|
10
|
+
import { validatePackage as Ie, getLicenseMessage as Pe, usePropsContext as Re, noop as f, useIsomorphicLayoutEffect as Te, useWebMcpRegister as Be, dispatchEvent as S, classNames as B, kendoThemeMaps as Z, getTabIndex as De, WatermarkOverlay as Fe, createPropsContext as _e } from "@progress/kendo-react-common";
|
|
11
|
+
import { Dialog as We } from "@progress/kendo-react-dialogs";
|
|
12
|
+
import { useLocalization as Ne } from "@progress/kendo-react-intl";
|
|
13
13
|
import a from "prop-types";
|
|
14
14
|
import * as o from "react";
|
|
15
|
-
import { signatureMaximize as
|
|
16
|
-
import { packageMetadata as
|
|
17
|
-
import { hasParent as
|
|
18
|
-
import { hyperlinkOpenIcon as
|
|
19
|
-
const
|
|
20
|
-
const
|
|
15
|
+
import { signatureMaximize as ee, messages as z, signatureMinimize as te, signatureClear as oe, signatureCanvas as ne } from "../messages/index.mjs";
|
|
16
|
+
import { packageMetadata as ae } from "../package-metadata.mjs";
|
|
17
|
+
import { hasParent as qe } from "./utils/index.mjs";
|
|
18
|
+
import { hyperlinkOpenIcon as re, xIcon as Ge } from "@progress/kendo-svg-icons";
|
|
19
|
+
const Ae = 250, Ve = 84, se = 3, le = 2, je = "#000000", Ue = "#ffffff", ie = (d) => d !== void 0, He = _e(), D = o.forwardRef((d, ce) => {
|
|
20
|
+
const ue = !Ie(ae, { component: "Signature" }), de = Pe(ae), F = Re(He, d), e = o.useMemo(
|
|
21
21
|
() => ({
|
|
22
22
|
strokeWidth: s.strokeWidth,
|
|
23
23
|
smooth: s.smooth,
|
|
@@ -38,240 +38,243 @@ const qe = 250, Ge = 84, ne = 3, ae = 2, Ae = "#000000", Ve = "#ffffff", oe = (d
|
|
|
38
38
|
...F
|
|
39
39
|
}),
|
|
40
40
|
[F]
|
|
41
|
-
),
|
|
41
|
+
), g = Ne(), u = o.useRef(null), b = o.useRef(null), _ = o.useRef(null), W = o.useRef(null), E = o.useRef(null), [r, me] = o.useState(), [k, N] = o.useState(!1), [v, q] = o.useState(), [pe, fe] = o.useState(), G = ie(e.value) ? e.value : v, [ge, be] = o.useState(!1), p = ie(e.open), m = p ? e.open : ge, ke = e.disabled || e.maximized || !e.maximizable, ve = e.disabled || !e.maximized, ye = !(!(e.value || v) || e.disabled || e.readOnly), A = g.toLanguageString(ee, z[ee]), V = g.toLanguageString(te, z[te]), j = g.toLanguageString(oe, z[oe]), Ce = g.toLanguageString(ne, z[ne]), O = e.popupScale || se, x = e.exportScale || le, M = (t) => {
|
|
42
42
|
q(t), e.onChange && e.onChange({ value: t });
|
|
43
|
-
},
|
|
44
|
-
r == null || r.loadImage(t.value),
|
|
43
|
+
}, he = (t) => {
|
|
44
|
+
r == null || r.loadImage(t.value), M(t.value);
|
|
45
45
|
};
|
|
46
46
|
o.useEffect(() => {
|
|
47
|
-
e.value !==
|
|
47
|
+
e.value !== v && (q(e.value), r == null || r.loadImage(e.value));
|
|
48
48
|
}, [e.value]);
|
|
49
|
-
const
|
|
50
|
-
r == null || r.clear(),
|
|
51
|
-
},
|
|
49
|
+
const Se = () => {
|
|
50
|
+
r == null || r.clear(), M();
|
|
51
|
+
}, y = o.useCallback(
|
|
52
52
|
(t) => {
|
|
53
|
-
p ||
|
|
53
|
+
p || be(t);
|
|
54
54
|
},
|
|
55
55
|
[p]
|
|
56
|
-
),
|
|
56
|
+
), ze = (t) => {
|
|
57
57
|
var n, i;
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
let t =
|
|
58
|
+
J(t), (i = ((n = E.current) == null ? void 0 : n.element) || b.current) == null || i.focus();
|
|
59
|
+
}, L = o.useCallback(() => {
|
|
60
|
+
let t = je;
|
|
61
61
|
return !e.color && typeof document != "undefined" && u.current && (t = getComputedStyle(u.current).color), e.color || t;
|
|
62
|
-
}, [e.color]),
|
|
63
|
-
let t =
|
|
62
|
+
}, [e.color]), w = o.useCallback(() => {
|
|
63
|
+
let t = Ue;
|
|
64
64
|
return !e.backgroundColor && typeof document != "undefined" && u.current && (t = getComputedStyle(u.current).backgroundColor), e.backgroundColor || t;
|
|
65
|
-
}, [e.backgroundColor]),
|
|
65
|
+
}, [e.backgroundColor]), U = () => ({
|
|
66
66
|
scale: e.maximized ? e.popupScale : 1,
|
|
67
|
-
color:
|
|
68
|
-
backgroundColor:
|
|
67
|
+
color: L(),
|
|
68
|
+
backgroundColor: w(),
|
|
69
69
|
strokeWidth: e.strokeWidth,
|
|
70
70
|
smooth: e.smooth,
|
|
71
71
|
readonly: e.readOnly || e.disabled
|
|
72
|
-
}),
|
|
72
|
+
}), H = async (t) => {
|
|
73
73
|
const { width: n, height: i } = t;
|
|
74
74
|
return await (r == null ? void 0 : r.exportImage({
|
|
75
|
-
width: n *
|
|
76
|
-
height: i *
|
|
75
|
+
width: n * x,
|
|
76
|
+
height: i * x
|
|
77
77
|
}));
|
|
78
78
|
};
|
|
79
79
|
o.useEffect(() => {
|
|
80
|
-
const t =
|
|
81
|
-
return G && n.loadImage(G),
|
|
80
|
+
const t = b.current, n = new we(t, U());
|
|
81
|
+
return G && n.loadImage(G), me(n), () => n.destroy();
|
|
82
82
|
}, []), o.useEffect(() => {
|
|
83
83
|
r == null || r.setOptions({
|
|
84
|
-
onChange: async () =>
|
|
84
|
+
onChange: async () => M(await H(Q()))
|
|
85
85
|
});
|
|
86
|
-
}, [r]),
|
|
87
|
-
() => r == null ? void 0 : r.setOptions(
|
|
86
|
+
}, [r]), Te(
|
|
87
|
+
() => r == null ? void 0 : r.setOptions(U()),
|
|
88
88
|
[e.readOnly, e.disabled, e.color, e.backgroundColor, e.strokeWidth, e.smooth]
|
|
89
89
|
), o.useEffect(() => {
|
|
90
90
|
var i, c;
|
|
91
91
|
const t = (c = (i = _.current) == null ? void 0 : i.element) == null ? void 0 : c.querySelector(".k-overlay");
|
|
92
92
|
if (!t)
|
|
93
93
|
return;
|
|
94
|
-
const n = () =>
|
|
94
|
+
const n = () => y(!1);
|
|
95
95
|
return t.addEventListener("click", n), () => t.removeEventListener("click", n);
|
|
96
96
|
}, [m]), o.useEffect(() => {
|
|
97
97
|
if (!m || typeof document == "undefined")
|
|
98
98
|
return;
|
|
99
99
|
const t = (n) => {
|
|
100
100
|
var i, c;
|
|
101
|
-
n.key === "Escape" && (
|
|
101
|
+
n.key === "Escape" && (y(!1), (c = (i = E.current) == null ? void 0 : i.element) == null || c.focus());
|
|
102
102
|
};
|
|
103
103
|
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
104
104
|
}, [m]), o.useEffect(() => {
|
|
105
105
|
var t, n;
|
|
106
106
|
e.maximized && ((n = (t = W.current) == null ? void 0 : t.element) == null || n.focus());
|
|
107
107
|
}, []);
|
|
108
|
-
const
|
|
108
|
+
const I = o.useCallback(() => {
|
|
109
109
|
var t;
|
|
110
|
-
return (t =
|
|
111
|
-
}, []),
|
|
112
|
-
const t = e.validationMessage !== void 0, i = !
|
|
110
|
+
return (t = b.current) == null ? void 0 : t.focus();
|
|
111
|
+
}, []), C = o.useCallback(() => e.value, [e.value]), $ = o.useCallback(() => e.name, [e.name]), h = o.useCallback(() => e.required, [e.required]), P = o.useCallback(() => {
|
|
112
|
+
const t = e.validationMessage !== void 0, i = !C(), c = e.valid !== void 0 ? e.valid : !h() || !i;
|
|
113
113
|
return {
|
|
114
114
|
customError: t,
|
|
115
115
|
valid: c,
|
|
116
116
|
valueMissing: i
|
|
117
117
|
};
|
|
118
|
-
}, [e.validationMessage, e.valid,
|
|
118
|
+
}, [e.validationMessage, e.valid, C, h]), R = o.useCallback(() => e.validityStyles, [e.validityStyles]), K = o.useCallback(() => e, [e]), l = o.useCallback(() => {
|
|
119
119
|
const t = {
|
|
120
120
|
element: u.current,
|
|
121
|
-
focus:
|
|
121
|
+
focus: I
|
|
122
122
|
};
|
|
123
|
-
return Object.defineProperty(t, "name", { get:
|
|
123
|
+
return Object.defineProperty(t, "name", { get: $ }), Object.defineProperty(t, "value", { get: C }), Object.defineProperty(t, "validity", { get: P }), Object.defineProperty(t, "validityStyles", { get: R }), Object.defineProperty(t, "required", { get: h }), Object.defineProperty(t, "props", { get: K }), Object.defineProperty(t, "color", { get: L }), Object.defineProperty(t, "backgroundColor", { get: w }), t;
|
|
124
124
|
}, [
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
I,
|
|
125
|
+
$,
|
|
126
|
+
C,
|
|
128
127
|
P,
|
|
128
|
+
R,
|
|
129
129
|
h,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
I,
|
|
131
|
+
K,
|
|
132
|
+
L,
|
|
133
|
+
w
|
|
134
134
|
]);
|
|
135
|
-
o.useImperativeHandle(
|
|
136
|
-
const
|
|
137
|
-
o.useImperativeHandle(
|
|
138
|
-
const
|
|
135
|
+
o.useImperativeHandle(ce, l);
|
|
136
|
+
const X = o.useRef(null);
|
|
137
|
+
o.useImperativeHandle(X, l), Be("signature", X, e, e.webMcp);
|
|
138
|
+
const Ee = o.useCallback(
|
|
139
139
|
(t) => {
|
|
140
|
-
k || e.maximized || (N(!0),
|
|
140
|
+
k || e.maximized || (N(!0), S(e.onFocus, t, l(), {}));
|
|
141
141
|
},
|
|
142
142
|
[k, e.onFocus, l]
|
|
143
|
-
),
|
|
143
|
+
), Oe = o.useCallback(
|
|
144
144
|
(t) => {
|
|
145
|
-
|
|
145
|
+
qe(t.relatedTarget, u.current) || (N(!1), S(e.onBlur, t, l(), {}));
|
|
146
146
|
},
|
|
147
147
|
[k, e.onBlur, l]
|
|
148
|
-
),
|
|
148
|
+
), xe = o.useCallback(
|
|
149
149
|
async (t) => {
|
|
150
|
-
|
|
150
|
+
fe(await H(Y())), y(!0), S(e.onOpen, t, l(), {});
|
|
151
151
|
},
|
|
152
|
-
[m, p, e.onOpen, e.value,
|
|
153
|
-
),
|
|
152
|
+
[m, p, e.onOpen, e.value, v, l]
|
|
153
|
+
), J = o.useCallback(
|
|
154
154
|
(t) => {
|
|
155
|
-
|
|
155
|
+
y(!1), S(e.onClose, t, l(), {});
|
|
156
156
|
},
|
|
157
157
|
[m, p, e.onClose, l]
|
|
158
|
-
),
|
|
159
|
-
|
|
160
|
-
},
|
|
158
|
+
), Me = () => {
|
|
159
|
+
Se(), I();
|
|
160
|
+
}, Q = () => {
|
|
161
161
|
var i, c;
|
|
162
|
-
const t = e.width || ((i = u.current) == null ? void 0 : i.offsetWidth) ||
|
|
162
|
+
const t = e.width || ((i = u.current) == null ? void 0 : i.offsetWidth) || Ae, n = e.height || ((c = u.current) == null ? void 0 : c.offsetHeight) || Ve;
|
|
163
163
|
return {
|
|
164
164
|
width: t,
|
|
165
165
|
height: n
|
|
166
166
|
};
|
|
167
|
-
},
|
|
168
|
-
const { width: t, height: n } =
|
|
167
|
+
}, Y = () => {
|
|
168
|
+
const { width: t, height: n } = Q();
|
|
169
169
|
return {
|
|
170
|
-
width: t *
|
|
171
|
-
height: n *
|
|
170
|
+
width: t * O,
|
|
171
|
+
height: n * O
|
|
172
172
|
};
|
|
173
|
-
},
|
|
173
|
+
}, Le = !R() || P().valid;
|
|
174
174
|
return /* @__PURE__ */ o.createElement(
|
|
175
175
|
"div",
|
|
176
176
|
{
|
|
177
177
|
ref: u,
|
|
178
178
|
dir: e.dir,
|
|
179
179
|
style: { width: e.width, height: e.height, ...e.style },
|
|
180
|
-
className:
|
|
180
|
+
className: B(
|
|
181
181
|
"k-input",
|
|
182
182
|
"k-signature",
|
|
183
183
|
{
|
|
184
184
|
"k-signature-maximized": e.maximized,
|
|
185
|
-
[`k-signature-${
|
|
185
|
+
[`k-signature-${Z.sizeMap[e.size] || e.size}`]: e.size,
|
|
186
186
|
[`k-signature-${e.fillMode}`]: e.fillMode,
|
|
187
187
|
[`k-input-${e.fillMode}`]: e.fillMode,
|
|
188
|
-
[`k-rounded-${
|
|
189
|
-
"k-invalid": !
|
|
188
|
+
[`k-rounded-${Z.roundedMap[e.rounded] || e.rounded}`]: e.rounded,
|
|
189
|
+
"k-invalid": !Le,
|
|
190
190
|
"k-required": e.required,
|
|
191
191
|
"k-disabled": e.disabled,
|
|
192
192
|
"k-focus": k
|
|
193
193
|
},
|
|
194
194
|
e.className
|
|
195
195
|
),
|
|
196
|
-
onFocus:
|
|
197
|
-
onBlur:
|
|
196
|
+
onFocus: Ee,
|
|
197
|
+
onBlur: Oe
|
|
198
198
|
},
|
|
199
199
|
/* @__PURE__ */ o.createElement(
|
|
200
200
|
"div",
|
|
201
201
|
{
|
|
202
202
|
className: "k-signature-canvas",
|
|
203
|
-
ref:
|
|
203
|
+
ref: b,
|
|
204
204
|
role: "img",
|
|
205
|
-
tabIndex:
|
|
205
|
+
tabIndex: De(e.tabIndex, e.disabled),
|
|
206
206
|
id: e.id,
|
|
207
|
-
"aria-label": e.ariaLabel,
|
|
207
|
+
"aria-label": e.ariaLabel || Ce,
|
|
208
208
|
"aria-labelledby": e.ariaLabelledBy,
|
|
209
209
|
"aria-describedby": e.ariaDescribedBy,
|
|
210
210
|
style: e.inputStyle
|
|
211
211
|
}
|
|
212
212
|
),
|
|
213
213
|
/* @__PURE__ */ o.createElement("div", { className: "k-signature-actions k-signature-actions-top" }, /* @__PURE__ */ o.createElement(
|
|
214
|
-
|
|
214
|
+
T,
|
|
215
215
|
{
|
|
216
216
|
type: "button",
|
|
217
|
-
className:
|
|
218
|
-
"k-hidden":
|
|
217
|
+
className: B("k-signature-action", "k-signature-maximize", {
|
|
218
|
+
"k-hidden": ke
|
|
219
219
|
}),
|
|
220
|
-
ref:
|
|
220
|
+
ref: E,
|
|
221
221
|
icon: "hyperlink-open",
|
|
222
|
-
svgIcon:
|
|
222
|
+
svgIcon: re,
|
|
223
223
|
size: e.size,
|
|
224
224
|
rounded: e.rounded,
|
|
225
225
|
fillMode: "flat",
|
|
226
|
-
onClick:
|
|
227
|
-
|
|
226
|
+
onClick: xe,
|
|
227
|
+
"aria-label": A,
|
|
228
|
+
title: A
|
|
228
229
|
}
|
|
229
230
|
), /* @__PURE__ */ o.createElement(
|
|
230
|
-
|
|
231
|
+
T,
|
|
231
232
|
{
|
|
232
233
|
type: "button",
|
|
233
|
-
className:
|
|
234
|
-
"k-hidden":
|
|
234
|
+
className: B("k-signature-action", "k-signature-minimize k-flip-h k-flip-v", {
|
|
235
|
+
"k-hidden": ve
|
|
235
236
|
}),
|
|
236
237
|
ref: W,
|
|
237
238
|
icon: "hyperlink-open",
|
|
238
|
-
svgIcon:
|
|
239
|
+
svgIcon: re,
|
|
239
240
|
size: e.size,
|
|
240
241
|
rounded: e.rounded,
|
|
241
242
|
fillMode: "flat",
|
|
242
|
-
onClick:
|
|
243
|
-
|
|
243
|
+
onClick: J,
|
|
244
|
+
"aria-label": V,
|
|
245
|
+
title: V
|
|
244
246
|
}
|
|
245
247
|
)),
|
|
246
248
|
!e.hideLine && /* @__PURE__ */ o.createElement("div", { className: "k-signature-line", style: { zIndex: 2, pointerEvents: "none" } }),
|
|
247
|
-
/* @__PURE__ */ o.createElement("div", { className: "k-signature-actions k-signature-actions-bottom" },
|
|
248
|
-
|
|
249
|
+
/* @__PURE__ */ o.createElement("div", { className: "k-signature-actions k-signature-actions-bottom" }, ye && /* @__PURE__ */ o.createElement(
|
|
250
|
+
T,
|
|
249
251
|
{
|
|
250
252
|
type: "button",
|
|
251
253
|
className: "k-signature-action k-signature-clear",
|
|
252
254
|
icon: "x",
|
|
253
|
-
svgIcon:
|
|
255
|
+
svgIcon: Ge,
|
|
254
256
|
size: e.size,
|
|
255
257
|
rounded: e.rounded,
|
|
256
258
|
fillMode: "flat",
|
|
257
|
-
onClick:
|
|
258
|
-
|
|
259
|
+
onClick: Me,
|
|
260
|
+
"aria-label": j,
|
|
261
|
+
title: j
|
|
259
262
|
}
|
|
260
263
|
)),
|
|
261
|
-
m && /* @__PURE__ */ o.createElement(
|
|
264
|
+
m && /* @__PURE__ */ o.createElement(We, { ref: _ }, /* @__PURE__ */ o.createElement(
|
|
262
265
|
D,
|
|
263
266
|
{
|
|
264
267
|
...e,
|
|
265
|
-
...
|
|
266
|
-
value:
|
|
268
|
+
...Y(),
|
|
269
|
+
value: pe,
|
|
267
270
|
maximized: !0,
|
|
268
|
-
exportScale: 1 /
|
|
271
|
+
exportScale: 1 / O * x,
|
|
269
272
|
open: !1,
|
|
270
|
-
onChange:
|
|
271
|
-
onClose:
|
|
273
|
+
onChange: he,
|
|
274
|
+
onClose: ze
|
|
272
275
|
}
|
|
273
276
|
)),
|
|
274
|
-
|
|
277
|
+
ue && /* @__PURE__ */ o.createElement(Fe, { message: de })
|
|
275
278
|
);
|
|
276
279
|
});
|
|
277
280
|
D.propTypes = {
|
|
@@ -299,8 +302,8 @@ D.propTypes = {
|
|
|
299
302
|
const s = {
|
|
300
303
|
strokeWidth: 1,
|
|
301
304
|
smooth: !1,
|
|
302
|
-
popupScale:
|
|
303
|
-
exportScale:
|
|
305
|
+
popupScale: se,
|
|
306
|
+
exportScale: le,
|
|
304
307
|
maximizable: !0,
|
|
305
308
|
disabled: !1,
|
|
306
309
|
required: !1,
|
|
@@ -317,5 +320,5 @@ const s = {
|
|
|
317
320
|
D.displayName = "KendoSignature";
|
|
318
321
|
export {
|
|
319
322
|
D as Signature,
|
|
320
|
-
|
|
323
|
+
He as SignaturePropsContext
|
|
321
324
|
};
|
package/slider/Slider.d.ts
CHANGED
|
@@ -133,6 +133,18 @@ export interface SliderProps extends FormComponentProps {
|
|
|
133
133
|
* ```
|
|
134
134
|
*/
|
|
135
135
|
disabled?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Makes the Slider read-only when set to `true`. The Slider will remain focusable but its value cannot be changed by the user.
|
|
138
|
+
*
|
|
139
|
+
* @remarks
|
|
140
|
+
* This property is related to accessibility.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```jsx
|
|
144
|
+
* <Slider readOnly={true} min={0} max={100} />
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
readOnly?: boolean;
|
|
136
148
|
/**
|
|
137
149
|
* Changes the orientation of the Slider to vertical if set to `true`.
|
|
138
150
|
*
|
package/slider/Slider.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 a=require("react"),i=require("prop-types"),c=require("@progress/kendo-react-common"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),i=require("prop-types"),c=require("@progress/kendo-react-common"),_=require("@progress/kendo-react-intl"),m=require("../messages/index.js"),le=require("./SliderLabel.js"),F=require("@progress/kendo-react-buttons"),g=require("@progress/kendo-svg-icons");function ie(e){const y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const h=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(y,o,h.get?h:{enumerable:!0,get:()=>e[o]})}}return y.default=e,Object.freeze(y)}const r=ie(a),b={step:1,largeStep:10,buttons:!1,vertical:!1,disabled:!1,readOnly:!1,tabIndex:0},R=r.forwardRef((e,y)=>{var M,A,j;const{step:o=b.step,largeStep:h=b.largeStep,vertical:l=b.vertical,disabled:u=b.disabled,tabIndex:U=b.tabIndex,readOnly:z=b.readOnly}=e,[W,H]=a.useState((M=e.defaultValue)!=null?M:e.min),[X,q]=a.useState(!1),[E,G]=a.useState(e.dir),L=a.useRef(null),k=a.useRef(null),N=a.useMemo(()=>new _.LocalizationService,[]),B=a.useRef(null),O=e.value!==void 0,I=O&&e.value!==void 0?e.value:W,s=a.useMemo(()=>I<e.min?e.min:I>e.max?e.max:I,[I,e.min,e.max]),C=a.useMemo(()=>{const t=e.max-e.min;return t===0?0:(s-e.min)/t*100},[s,e.min,e.max]),v=(A=e.dir)!=null?A:E;a.useEffect(()=>{if(e.dir===void 0&&k.current){const n=window.getComputedStyle(k.current).direction;n!==E&&G(n)}},[e.dir,E]);const K=a.useCallback(t=>{let n=t;for(;n;){if(n.getAttribute(le.SLIDER_LABEL_ATTRIBUTE))return!0;n=n.parentElement}return!1},[]),f=a.useCallback((t,n)=>{const d=Math.min(Math.max(n,e.min),e.max);O||H(d),c.dispatchEvent(e.onChange,t,B.current,{value:d})},[e.min,e.max,e.onChange,O]),Y=a.useCallback(()=>{q(!0)},[]),J=a.useCallback(()=>{q(!1)},[]),Q=a.useCallback(t=>{if(u)return;let n;t.keyCode===c.Keys.left||t.keyCode===c.Keys.down?n=s-(o||0):t.keyCode===c.Keys.right||t.keyCode===c.Keys.up?n=s+(o||0):t.keyCode===c.Keys.pageDown?n=s-(h||0):t.keyCode===c.Keys.pageUp?n=s+(h||0):t.keyCode===c.Keys.home?n=e.min:t.keyCode===c.Keys.end&&(n=e.max),n!==void 0&&(t.preventDefault(),f(t,n))},[s,o,h,e.min,e.max,f,u]),Z=a.useCallback(t=>{t.preventDefault(),!u&&f(t,s-(o||0))},[s,o,f,u]),$=a.useCallback(t=>{t.preventDefault(),!u&&f(t,s+(o||0))},[s,o,f,u]),w=a.useCallback(t=>{const n=t.element.getBoundingClientRect();let d;l?d=n.bottom-t.event.clientY:d=v==="rtl"?n.right-t.event.clientX:t.event.clientX-n.left;const S=l?n.height:n.width,x=d/S;f(t,e.min+x*(e.max-e.min))},[l,e.min,e.max,v,f]),p=a.useCallback(t=>{K(t.event.originalEvent.target)||(t.event.isTouch&&t.event.originalEvent.preventDefault(),w(t))},[K,w]),ee=a.useCallback(t=>{t.event.originalEvent.preventDefault(),w(t)},[w]),D=a.useCallback(()=>{k.current&&k.current.focus()},[]),te=a.useCallback(t=>{if(!t.enabled)return t.children;let n,d,S,x;return v==="rtl"?(n=l?g.chevronUpIcon:g.chevronLeftIcon,d=l?g.chevronDownIcon:g.chevronRightIcon,S=l?"chevron-up":"chevron-left",x=l?"chevron-down":"chevron-right"):(n=l?g.chevronUpIcon:g.chevronRightIcon,d=l?g.chevronDownIcon:g.chevronLeftIcon,S=l?"chevron-up":"chevron-right",x=l?"chevron-down":"chevron-left"),r.createElement(r.Fragment,null,r.createElement(F.Button,{className:"k-button-decrease",rounded:"full",icon:x,svgIcon:d,title:t.decrementTitle,onClick:t.decrement}),t.children,r.createElement(F.Button,{className:"k-button-increase",rounded:"full",icon:S,svgIcon:n,title:t.incrementTitle,onClick:t.increment}))},[v,l]);a.useImperativeHandle(y,()=>({props:e,sliderTrack:L.current,focus:D}),[e,D]),c.useWebMcpRegister("slider",B,e,e.webMcp),a.useEffect(()=>{B.current={props:e,sliderTrack:L.current,focus:D}},[e,D]);const ne=l?{marginTop:"0.5rem",marginBottom:"0.5rem"}:{marginLeft:"0.5rem",marginRight:"0.5rem"},ae=l?{paddingTop:0,height:"100%"}:{};let T;return l?T={bottom:"calc("+C+"%)",zIndex:1}:v==="rtl"?T={right:"calc("+C+"%)",zIndex:1}:T={left:"calc("+C+"%)",zIndex:1},r.createElement("div",{ref:k,dir:v,id:e.id,"aria-label":e.ariaLabel,style:{gap:0,...e.style},onFocus:Y,onBlur:J,onKeyDown:Q,className:c.classNames("k-slider",{"k-focus":X,"k-disabled":u,"k-readonly":z,"k-slider-horizontal":!l,"k-slider-vertical":l},e.className)},te({enabled:(j=e.buttons)!=null?j:b.buttons,decrement:Z,increment:$,incrementTitle:N.toLanguageString(m.sliderIncreaseValue,m.messages[m.sliderIncreaseValue]),decrementTitle:N.toLanguageString(m.sliderDecreaseValue,m.messages[m.sliderDecreaseValue]),children:r.createElement(c.Draggable,{onDrag:ee,onPress:p,autoScroll:!1},r.createElement("div",{className:"k-slider-track-wrap",style:{flexGrow:1,position:"relative",touchAction:"none",...ne}},e.children&&r.createElement("ul",{className:"k-reset k-slider-items","aria-hidden":"true",style:{margin:0,...ae}},r.Children.map(e.children,(t,n)=>t&&r.cloneElement(t,{position:100*(t.props.position-e.min)/(e.max-e.min),vertical:l,firstTick:n===0,lastTick:n===r.Children.count(e.children)-1},t.props.children))),r.createElement("div",{className:"k-slider-track",style:l?{bottom:0,height:"100%"}:{[v==="rtl"?"right":"left"]:0,width:"100%"},ref:L},r.createElement("div",{className:"k-slider-selection",style:l?{height:C+"%"}:{width:C+"%"}}),r.createElement("span",{role:"slider","aria-valuemin":e.min,"aria-valuemax":e.max,"aria-valuenow":s,"aria-orientation":l?"vertical":void 0,"aria-disabled":u?"true":void 0,"aria-readonly":z?"true":void 0,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-label":e.ariaLabel,tabIndex:c.getTabIndex(U,u,void 0),className:"k-draghandle k-draghandle-end",title:N.toLanguageString(m.sliderDragTitle,m.messages[m.sliderDragTitle]),style:T}))))}))});R.displayName="Slider";const P=c.createPropsContext(),V=c.withPropsContext(P,R);V.displayName="KendoReactSlider";V.propTypes={value:i.number,defaultValue:i.number,min:i.number.isRequired,max:i.number.isRequired,step:i.number,largeStep:i.number,onChange:i.func,style:i.object,className:i.string,buttons:i.bool,tabIndex:i.number,disabled:i.bool,readOnly:i.bool,vertical:i.bool,id:i.string,ariaDescribedBy:i.string,ariaLabelledBy:i.string,ariaLabel:i.string,dir:i.oneOf(["ltr","rtl"]),children:i.node};_.registerForLocalization(R);exports.Slider=V;exports.SliderPropsContext=P;exports.SliderWithoutContext=R;
|