@progress/kendo-react-inputs 14.5.0-develop.14 → 14.5.0-develop.15

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 (39) hide show
  1. package/checkbox/Checkbox.js +1 -1
  2. package/checkbox/Checkbox.mjs +64 -64
  3. package/colors/ColorGradient.js +1 -1
  4. package/colors/ColorGradient.mjs +74 -72
  5. package/colors/ColorInput.js +1 -1
  6. package/colors/ColorInput.mjs +57 -45
  7. package/colors/ColorPalette.js +1 -1
  8. package/colors/ColorPalette.mjs +84 -81
  9. package/colors/ColorPicker.js +1 -1
  10. package/colors/ColorPicker.mjs +162 -160
  11. package/colors/FlatColorPicker.js +1 -1
  12. package/colors/FlatColorPicker.mjs +86 -94
  13. package/dist/cdn/js/kendo-react-inputs.js +1 -1
  14. package/messages/index.d.ts +55 -0
  15. package/messages/index.js +1 -1
  16. package/messages/index.mjs +82 -60
  17. package/numerictextbox/NumericTextBox.js +1 -1
  18. package/numerictextbox/NumericTextBox.mjs +115 -115
  19. package/package-metadata.js +1 -1
  20. package/package-metadata.mjs +2 -2
  21. package/package.json +10 -10
  22. package/radiobutton/RadioButton.js +1 -1
  23. package/radiobutton/RadioButton.mjs +23 -20
  24. package/radiobutton/interfaces/RadioButtonProps.d.ts +7 -0
  25. package/range-slider/RangeSlider.d.ts +8 -0
  26. package/range-slider/RangeSlider.js +11 -11
  27. package/range-slider/RangeSlider.mjs +189 -186
  28. package/rating/Rating.js +2 -2
  29. package/rating/Rating.mjs +3 -3
  30. package/signature/Signature.js +1 -1
  31. package/signature/Signature.mjs +80 -84
  32. package/slider/Slider.js +1 -1
  33. package/slider/Slider.mjs +139 -131
  34. package/slider/SliderLabel.js +1 -1
  35. package/slider/SliderLabel.mjs +3 -2
  36. package/switch/Switch.js +1 -1
  37. package/switch/Switch.mjs +52 -54
  38. package/textarea/TextArea.js +1 -1
  39. package/textarea/TextArea.mjs +29 -31
package/slider/Slider.mjs CHANGED
@@ -6,43 +6,43 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  import * as r from "react";
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
- import { Button as _ } from "@progress/kendo-react-buttons";
16
- import { chevronUpIcon as j, chevronLeftIcon as G, chevronDownIcon as Y, chevronRightIcon as J } from "@progress/kendo-svg-icons";
17
- const g = {
9
+ import { useState as N, useRef as z, useMemo as B, useEffect as O, useCallback as c, useImperativeHandle as ue } from "react";
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";
12
+ import { LocalizationService as xe, registerForLocalization as Se } from "@progress/kendo-react-intl";
13
+ import { sliderAriaLabel as E, messages as x, sliderDragTitle as W, sliderDecreaseValue as X, sliderIncreaseValue as _ } from "../messages/index.mjs";
14
+ import { SLIDER_LABEL_ATTRIBUTE as we } from "./SliderLabel.mjs";
15
+ import { Button as j } from "@progress/kendo-react-buttons";
16
+ import { chevronUpIcon as G, chevronLeftIcon as Y, chevronDownIcon as J, chevronRightIcon as P } from "@progress/kendo-svg-icons";
17
+ const f = {
18
18
  step: 1,
19
19
  largeStep: 10,
20
20
  buttons: !1,
21
21
  vertical: !1,
22
22
  disabled: !1,
23
23
  tabIndex: 0
24
- }, B = r.forwardRef((e, V) => {
25
- var K, U, q;
24
+ }, V = r.forwardRef((e, A) => {
25
+ var U, q, H;
26
26
  const {
27
- step: u = g.step,
28
- largeStep: C = g.largeStep,
29
- vertical: i = g.vertical,
30
- disabled: d = g.disabled,
31
- tabIndex: Q = g.tabIndex
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(() => {
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] = N((U = e.defaultValue) != null ? U : e.min), [ee, F] = N(!1), [D, te] = N(e.dir), L = z(null), v = z(null), h = B(() => new xe(), []), M = z(null), R = e.value !== void 0, S = R && e.value !== void 0 ? e.value : $, l = B(() => S < e.min ? e.min : S > e.max ? e.max : S, [S, e.min, e.max]), b = B(() => {
33
33
  const t = e.max - e.min;
34
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(() => {
35
+ }, [l, e.min, e.max]), g = (q = e.dir) != null ? q : D;
36
+ O(() => {
37
37
  if (e.dir === void 0 && v.current) {
38
38
  const n = window.getComputedStyle(v.current).direction;
39
- n !== I && ee(n);
39
+ n !== D && te(n);
40
40
  }
41
- }, [e.dir, I]);
42
- const M = c((t) => {
41
+ }, [e.dir, D]);
42
+ const K = c((t) => {
43
43
  let n = t;
44
44
  for (; n; ) {
45
- if (n.getAttribute(Se))
45
+ if (n.getAttribute(we))
46
46
  return !0;
47
47
  n = n.parentElement;
48
48
  }
@@ -50,132 +50,133 @@ const g = {
50
50
  }, []), s = c(
51
51
  (t, n) => {
52
52
  const o = Math.min(Math.max(n, e.min), e.max);
53
- D || $(o), fe(e.onChange, t, F.current, { value: o });
53
+ R || p(o), fe(e.onChange, t, M.current, { value: o });
54
54
  },
55
- [e.min, e.max, e.onChange, D]
56
- ), te = c(() => {
57
- A(!0);
58
- }, []), ne = c(() => {
59
- A(!1);
55
+ [e.min, e.max, e.onChange, R]
56
+ ), ne = c(() => {
57
+ F(!0);
58
+ }, []), ae = c(() => {
59
+ F(!1);
60
60
  }, []), ie = c(
61
61
  (t) => {
62
62
  if (d)
63
63
  return;
64
64
  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 - (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));
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));
66
66
  },
67
- [l, u, C, e.min, e.max, s, d]
68
- ), ae = c(
67
+ [l, u, T, e.min, e.max, s, d]
68
+ ), re = c(
69
69
  (t) => {
70
70
  t.preventDefault(), !d && s(t, l - (u || 0));
71
71
  },
72
72
  [l, u, s, d]
73
- ), re = c(
73
+ ), le = c(
74
74
  (t) => {
75
75
  t.preventDefault(), !d && s(t, l + (u || 0));
76
76
  },
77
77
  [l, u, s, d]
78
- ), x = c(
78
+ ), w = c(
79
79
  (t) => {
80
80
  const n = t.element.getBoundingClientRect();
81
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));
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));
85
85
  },
86
- [i, e.min, e.max, f, s]
87
- ), le = c(
86
+ [a, e.min, e.max, g, s]
87
+ ), ce = c(
88
88
  (t) => {
89
- M(t.event.originalEvent.target) || (t.event.isTouch && t.event.originalEvent.preventDefault(), x(t));
89
+ K(t.event.originalEvent.target) || (t.event.isTouch && t.event.originalEvent.preventDefault(), w(t));
90
90
  },
91
- [M, x]
92
- ), ce = c(
91
+ [K, w]
92
+ ), oe = c(
93
93
  (t) => {
94
- t.event.originalEvent.preventDefault(), x(t);
94
+ t.event.originalEvent.preventDefault(), w(t);
95
95
  },
96
- [x]
97
- ), S = c(() => {
96
+ [w]
97
+ ), C = c(() => {
98
98
  v.current && v.current.focus();
99
- }, []), oe = c(
99
+ }, []), de = c(
100
100
  (t) => {
101
101
  if (!t.enabled)
102
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(
105
- _,
103
+ let n, o, y, k;
104
+ return g === "rtl" ? (n = a ? G : Y, o = a ? J : P, y = a ? "chevron-up" : "chevron-left", k = a ? "chevron-down" : "chevron-right") : (n = a ? G : P, o = a ? J : Y, y = a ? "chevron-up" : "chevron-right", k = a ? "chevron-down" : "chevron-left"), /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
105
+ j,
106
106
  {
107
107
  className: "k-button-decrease",
108
108
  rounded: "full",
109
- icon: y,
109
+ icon: k,
110
110
  svgIcon: o,
111
111
  title: t.decrementTitle,
112
112
  onClick: t.decrement
113
113
  }
114
114
  ), t.children, /* @__PURE__ */ r.createElement(
115
- _,
115
+ j,
116
116
  {
117
117
  className: "k-button-increase",
118
118
  rounded: "full",
119
- icon: b,
119
+ icon: y,
120
120
  svgIcon: n,
121
121
  title: t.incrementTitle,
122
122
  onClick: t.increment
123
123
  }
124
124
  ));
125
125
  },
126
- [f, i]
126
+ [g, a]
127
127
  );
128
- me(
129
- V,
128
+ ue(
129
+ A,
130
130
  () => ({
131
131
  props: e,
132
- sliderTrack: E.current,
133
- focus: S
132
+ sliderTrack: L.current,
133
+ focus: C
134
134
  }),
135
- [e, S]
136
- ), ge("slider", V, e, e.webMcp), H(() => {
137
- F.current = {
135
+ [e, C]
136
+ ), ve("slider", A, e, e.webMcp), O(() => {
137
+ M.current = {
138
138
  props: e,
139
- sliderTrack: E.current,
140
- focus: S
139
+ sliderTrack: L.current,
140
+ focus: C
141
141
  };
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%" } : {};
144
- let w;
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(
142
+ }, [e, C]);
143
+ 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 + "% - 13px)", zIndex: 1 } : I = { left: "calc(" + b + "%)", zIndex: 1 }, /* @__PURE__ */ r.createElement(
146
146
  "div",
147
147
  {
148
148
  ref: v,
149
- dir: f,
149
+ dir: g,
150
150
  id: e.id,
151
+ "aria-label": e.ariaLabel || h.toLanguageString(E, x[E]),
151
152
  style: { gap: 0, ...e.style },
152
- onFocus: te,
153
- onBlur: ne,
153
+ onFocus: ne,
154
+ onBlur: ae,
154
155
  onKeyDown: ie,
155
- className: ve(
156
+ className: he(
156
157
  "k-slider",
157
158
  {
158
- "k-focus": p,
159
+ "k-focus": ee,
159
160
  "k-disabled": d,
160
- "k-slider-horizontal": !i,
161
- "k-slider-vertical": i
161
+ "k-slider-horizontal": !a,
162
+ "k-slider-vertical": a
162
163
  },
163
164
  e.className
164
165
  )
165
166
  },
166
- oe({
167
- enabled: (q = e.buttons) != null ? q : g.buttons,
168
- decrement: ae,
169
- increment: re,
170
- incrementTitle: T.toLanguageString(
171
- X,
172
- z[X]
167
+ de({
168
+ enabled: (H = e.buttons) != null ? H : f.buttons,
169
+ decrement: re,
170
+ increment: le,
171
+ incrementTitle: h.toLanguageString(
172
+ _,
173
+ x[_]
173
174
  ),
174
- decrementTitle: T.toLanguageString(
175
- W,
176
- z[W]
175
+ decrementTitle: h.toLanguageString(
176
+ X,
177
+ x[X]
177
178
  ),
178
- children: /* @__PURE__ */ r.createElement(he, { onDrag: ce, onPress: le, autoScroll: !1 }, /* @__PURE__ */ r.createElement(
179
+ children: /* @__PURE__ */ r.createElement(be, { onDrag: oe, onPress: ce, autoScroll: !1 }, /* @__PURE__ */ r.createElement(
179
180
  "div",
180
181
  {
181
182
  className: "k-slider-track-wrap",
@@ -183,31 +184,39 @@ const g = {
183
184
  flexGrow: 1,
184
185
  position: "relative",
185
186
  touchAction: "none",
186
- ...de
187
+ ...se
187
188
  }
188
189
  },
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,
190
+ e.children && /* @__PURE__ */ r.createElement(
191
+ "ul",
191
192
  {
192
- position: 100 * (t.props.position - e.min) / (e.max - e.min),
193
- vertical: i,
194
- firstTick: n === 0,
195
- lastTick: n === r.Children.count(e.children) - 1
193
+ className: "k-reset k-slider-items",
194
+ "aria-hidden": "true",
195
+ style: { margin: 0, ...me }
196
196
  },
197
- t.props.children
198
- ))),
197
+ r.Children.map(e.children, (t, n) => t && r.cloneElement(
198
+ t,
199
+ {
200
+ position: 100 * (t.props.position - e.min) / (e.max - e.min),
201
+ vertical: a,
202
+ firstTick: n === 0,
203
+ lastTick: n === r.Children.count(e.children) - 1
204
+ },
205
+ t.props.children
206
+ ))
207
+ ),
199
208
  /* @__PURE__ */ r.createElement(
200
209
  "div",
201
210
  {
202
211
  className: "k-slider-track",
203
- style: i ? { bottom: 0, height: "100%" } : { [f === "rtl" ? "right" : "left"]: 0, width: "100%" },
204
- ref: E
212
+ style: a ? { bottom: 0, height: "100%" } : { [g === "rtl" ? "right" : "left"]: 0, width: "100%" },
213
+ ref: L
205
214
  },
206
215
  /* @__PURE__ */ r.createElement(
207
216
  "div",
208
217
  {
209
218
  className: "k-slider-selection",
210
- style: i ? { height: h + "%" } : { width: h + "%" }
219
+ style: a ? { height: b + "%" } : { width: b + "%" }
211
220
  }
212
221
  ),
213
222
  /* @__PURE__ */ r.createElement(
@@ -217,19 +226,18 @@ const g = {
217
226
  "aria-valuemin": e.min,
218
227
  "aria-valuemax": e.max,
219
228
  "aria-valuenow": l,
220
- "aria-valuetext": String(l),
221
- "aria-orientation": i ? "vertical" : void 0,
229
+ "aria-orientation": a ? "vertical" : void 0,
222
230
  "aria-disabled": d ? "true" : void 0,
223
231
  "aria-labelledby": e.ariaLabelledBy,
224
232
  "aria-describedby": e.ariaDescribedBy,
225
- "aria-label": e.ariaLabel,
226
- tabIndex: be(Q, d, void 0),
233
+ "aria-label": e.ariaLabel || h.toLanguageString(E, x[E]),
234
+ tabIndex: ye(Z, d, void 0),
227
235
  className: "k-draghandle k-draghandle-end",
228
- title: T.toLanguageString(
229
- O,
230
- z[O]
236
+ title: h.toLanguageString(
237
+ W,
238
+ x[W]
231
239
  ),
232
- style: w
240
+ style: I
233
241
  }
234
242
  )
235
243
  )
@@ -237,33 +245,33 @@ const g = {
237
245
  })
238
246
  );
239
247
  });
240
- B.displayName = "Slider";
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
248
+ V.displayName = "Slider";
249
+ const Ce = ke(), Q = ge(Ce, V);
250
+ Q.displayName = "KendoReactSlider";
251
+ Q.propTypes = {
252
+ value: i.number,
253
+ defaultValue: i.number,
254
+ min: i.number.isRequired,
255
+ max: i.number.isRequired,
256
+ step: i.number,
257
+ largeStep: i.number,
258
+ onChange: i.func,
259
+ style: i.object,
260
+ className: i.string,
261
+ buttons: i.bool,
262
+ tabIndex: i.number,
263
+ disabled: i.bool,
264
+ vertical: i.bool,
265
+ id: i.string,
266
+ ariaDescribedBy: i.string,
267
+ ariaLabelledBy: i.string,
268
+ ariaLabel: i.string,
269
+ dir: i.oneOf(["ltr", "rtl"]),
270
+ children: i.node
263
271
  };
264
- xe(B);
272
+ Se(V);
265
273
  export {
266
- P as Slider,
267
- we as SliderPropsContext,
268
- B as SliderWithoutContext
274
+ Q as Slider,
275
+ Ce as SliderPropsContext,
276
+ V as SliderWithoutContext
269
277
  };
@@ -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 i=require("react"),n=require("@progress/kendo-react-common");function s(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const l in e)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(t,l,a.get?a:{enumerable:!0,get:()=>e[l]})}}return t.default=e,Object.freeze(t)}const c=s(i),r="data-slider-label",o=e=>{const t=c.useRef(null);return n.useDir(t),c.createElement("li",{ref:t,className:n.classNames("k-tick",{"k-tick-large":e.children,"k-first":e.firstTick,"k-last":e.lastTick}),title:e.title},e.children&&c.createElement("span",{[r]:!0,className:"k-label",onClick:e.onClick},e.children))};exports.SLIDER_LABEL_ATTRIBUTE=r;exports.SliderLabel=o;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),a=require("@progress/kendo-react-common");function s(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const l in e)if(l!=="default"){const n=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(t,l,n.get?n:{enumerable:!0,get:()=>e[l]})}}return t.default=e,Object.freeze(t)}const c=s(i),r="data-slider-label",o=e=>{const t=c.useRef(null);return a.useDir(t),c.createElement("li",{ref:t,role:"presentation",className:a.classNames("k-tick",{"k-tick-large":e.children,"k-first":e.firstTick,"k-last":e.lastTick}),title:e.title},e.children&&c.createElement("span",{[r]:!0,className:"k-label",onClick:e.onClick},e.children))};exports.SLIDER_LABEL_ATTRIBUTE=r;exports.SliderLabel=o;
@@ -7,12 +7,13 @@
7
7
  */
8
8
  import * as l from "react";
9
9
  import { useDir as a, classNames as i } from "@progress/kendo-react-common";
10
- const c = "data-slider-label", s = (e) => {
10
+ const c = "data-slider-label", n = (e) => {
11
11
  const t = l.useRef(null);
12
12
  return a(t), /* @__PURE__ */ l.createElement(
13
13
  "li",
14
14
  {
15
15
  ref: t,
16
+ role: "presentation",
16
17
  className: i("k-tick", {
17
18
  "k-tick-large": e.children,
18
19
  "k-first": e.firstTick,
@@ -25,5 +26,5 @@ const c = "data-slider-label", s = (e) => {
25
26
  };
26
27
  export {
27
28
  c as SLIDER_LABEL_ATTRIBUTE,
28
- s as SliderLabel
29
+ n as SliderLabel
29
30
  };
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"),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;
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;