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