@progress/kendo-react-inputs 15.1.1-develop.3 → 15.2.0-develop.2
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 +72 -70
- 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 +203 -195
- package/colors/FlatColorPicker.d.ts +4 -4
- package/colors/FlatColorPicker.js +1 -1
- package/colors/FlatColorPicker.mjs +30 -26
- 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/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/slider/Slider.d.ts +12 -0
- package/slider/Slider.js +1 -1
- package/slider/Slider.mjs +69 -64
- package/switch/Switch.d.ts +15 -0
- package/switch/Switch.js +1 -1
- package/switch/Switch.mjs +87 -82
- 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/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"),
|
|
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;
|