@progress/kendo-react-inputs 14.5.0-develop.1 → 14.5.0-develop.10

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/switch/Switch.mjs CHANGED
@@ -6,11 +6,11 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  import * as d from "react";
9
- import { useState as q, useRef as u, useMemo as E, useEffect as N, useCallback as m, useImperativeHandle as ie } from "react";
10
- import a from "prop-types";
11
- import { withIdHOC as re, withPropsContext as ce, noop as B, dispatchEvent as de, subscribeToKendoPaste as le, Keys as V, classNames as x, kendoThemeMaps as M, getTabIndex as oe, createPropsContext as se } from "@progress/kendo-react-common";
9
+ import { useState as q, useRef as u, useMemo as N, useEffect as x, useCallback as f, useImperativeHandle as ie } from "react";
10
+ import t from "prop-types";
11
+ import { withIdHOC as re, withPropsContext as ce, noop as I, dispatchEvent as de, subscribeToKendoPaste as le, Keys as H, classNames as M, kendoThemeMaps as B, getTabIndex as se, createPropsContext as oe } from "@progress/kendo-react-common";
12
12
  import { LocalizationService as ue } from "@progress/kendo-react-intl";
13
- import { switchValidation as H, messages as W, switchAriaLabel as $ } from "../messages/index.mjs";
13
+ import { switchValidation as V, messages as W, switchAriaLabel as $ } from "../messages/index.mjs";
14
14
  const r = {
15
15
  disabled: !1,
16
16
  defaultChecked: !1,
@@ -18,50 +18,50 @@ const r = {
18
18
  trackRounded: void 0,
19
19
  thumbRounded: void 0,
20
20
  offLabel: "OFF",
21
- onBlur: B,
22
- onFocus: B,
21
+ onBlur: I,
22
+ onFocus: I,
23
23
  onLabel: "ON",
24
24
  validityStyles: !0
25
25
  }, A = d.forwardRef((e, G) => {
26
- var T;
26
+ var P;
27
27
  const {
28
28
  disabled: c = r.disabled,
29
29
  defaultChecked: J = r.defaultChecked,
30
- size: y = r.size,
31
- trackRounded: k = r.trackRounded,
32
- thumbRounded: w = r.thumbRounded,
33
- offLabel: I = r.offLabel,
34
- onBlur: C = r.onBlur,
35
- onFocus: S = r.onFocus,
36
- onLabel: F = r.onLabel
37
- } = e, [D, Q] = q(J || !1), [U, K] = q(!1), l = u(null), o = u(null), R = u(null), b = u(void 0), z = u(void 0), O = u(void 0), L = E(() => new ue(), []), n = E(() => b.current !== void 0 ? b.current : e.checked !== void 0 ? e.checked : D, [e.checked, D]), f = E(() => {
38
- var g, P;
39
- const t = e.validationMessage !== void 0, i = (g = e.valid) != null ? g : e.required ? !!n : !0, v = (P = e.valid) != null ? P : i;
30
+ size: k = r.size,
31
+ trackRounded: w = r.trackRounded,
32
+ thumbRounded: C = r.thumbRounded,
33
+ offLabel: F = r.offLabel,
34
+ onBlur: R = r.onBlur,
35
+ onFocus: L = r.onFocus,
36
+ onLabel: D = r.onLabel
37
+ } = e, [K, Q] = q(J || !1), [U, z] = q(!1), l = u(null), s = u(null), b = u(null), h = u(void 0), S = u(!1), O = u(void 0), E = N(() => new ue(), []), n = N(() => h.current !== void 0 ? h.current : e.checked !== void 0 ? e.checked : K, [e.checked, K]), m = N(() => {
38
+ var y, T;
39
+ const a = e.validationMessage !== void 0, i = (y = e.valid) != null ? y : e.required ? !!n : !0, g = (T = e.valid) != null ? T : i;
40
40
  return {
41
- customError: t,
42
- valid: v,
41
+ customError: a,
42
+ valid: g,
43
43
  valueMissing: n === null
44
44
  };
45
- }, [e.valid, e.validationMessage, e.required, n]), X = (T = e.validityStyles) != null ? T : r.validityStyles;
46
- N(() => {
47
- var t;
48
- (t = R.current) != null && t.setCustomValidity && R.current.setCustomValidity(
49
- f.valid ? "" : e.validationMessage || L.toLanguageString(H, W[H])
45
+ }, [e.valid, e.validationMessage, e.required, n]), X = (P = e.validityStyles) != null ? P : r.validityStyles;
46
+ x(() => {
47
+ var a;
48
+ (a = b.current) != null && a.setCustomValidity && b.current.setCustomValidity(
49
+ m.valid ? "" : e.validationMessage || E.toLanguageString(V, W[V])
50
50
  );
51
- }, [f, e.validationMessage, L]), N(() => {
51
+ }, [m, e.validationMessage, E]), x(() => {
52
52
  l.current && (O.current = e.dir || getComputedStyle(l.current).direction || void 0);
53
53
  }, [e.dir]);
54
- const h = m(() => ({
54
+ const v = f(() => ({
55
55
  props: e,
56
56
  get element() {
57
57
  return l.current;
58
58
  },
59
59
  get actionElement() {
60
- return o.current;
60
+ return s.current;
61
61
  },
62
62
  focus: () => {
63
- var t;
64
- (t = o.current) == null || t.focus();
63
+ var a;
64
+ (a = s.current) == null || a.focus();
65
65
  },
66
66
  get value() {
67
67
  return n;
@@ -70,66 +70,73 @@ const r = {
70
70
  return e.name;
71
71
  },
72
72
  get validity() {
73
- return f;
73
+ return m;
74
74
  }
75
- }), [e, n, f]), s = m(
76
- (t, i) => {
77
- Q(t), b.current = t, de(
75
+ }), [e, n, m]), o = f(
76
+ (a, i) => {
77
+ Q(a), h.current = a, de(
78
78
  e.onChange,
79
79
  i,
80
- { ...h(), value: t },
81
- { value: t }
82
- ), b.current = void 0;
80
+ { ...v(), value: a },
81
+ { value: a }
82
+ ), h.current = void 0;
83
83
  },
84
- [e.onChange, h]
84
+ [e.onChange, v]
85
85
  );
86
- N(() => {
87
- const t = e.name || e.id, i = le(o.current, {
88
- fieldName: t,
89
- onValueChange: (v) => {
90
- if (v !== n) {
91
- const g = {
92
- target: o.current,
93
- currentTarget: o.current,
86
+ x(() => {
87
+ const a = e.name || e.id, i = le(s.current, {
88
+ fieldName: a,
89
+ onValueChange: (g) => {
90
+ if (g !== n) {
91
+ const y = {
92
+ target: s.current,
93
+ currentTarget: s.current,
94
94
  nativeEvent: new Event("change", { bubbles: !0 })
95
95
  };
96
- s(v, g);
96
+ o(g, y);
97
97
  }
98
98
  }
99
99
  });
100
100
  return () => {
101
101
  i == null || i.unsubscribe();
102
102
  };
103
- }, [e.name, e.id, n, s]);
104
- const Y = m(
105
- (t) => {
106
- z.current !== t.timeStamp && (z.current = t.timeStamp, s(!n, t));
103
+ }, [e.name, e.id, n, o]);
104
+ const Y = f(
105
+ (a) => {
106
+ if (a.target === b.current) {
107
+ if (S.current) {
108
+ S.current = !1;
109
+ return;
110
+ }
111
+ } else
112
+ S.current = !0;
113
+ o(!n, a);
107
114
  },
108
- [n, s]
109
- ), Z = m(
110
- (t) => {
115
+ [n, o]
116
+ ), Z = f(
117
+ (a) => {
111
118
  if (c)
112
119
  return;
113
- const { keyCode: i } = t;
114
- (i === V.space || i === V.enter) && (s(!n, t), t.preventDefault());
120
+ const { keyCode: i } = a;
121
+ (i === H.space || i === H.enter) && (o(!n, a), a.preventDefault());
115
122
  },
116
- [c, n, s]
117
- ), _ = m(
118
- (t) => {
119
- c || (K(!0), S && S(t));
123
+ [c, n, o]
124
+ ), _ = f(
125
+ (a) => {
126
+ c || (z(!0), L && L(a));
120
127
  },
121
- [c, S]
122
- ), p = m(
123
- (t) => {
124
- c || (K(!1), C && C(t));
128
+ [c, L]
129
+ ), p = f(
130
+ (a) => {
131
+ c || (z(!1), R && R(a));
125
132
  },
126
- [c, C]
133
+ [c, R]
127
134
  );
128
- ie(G, h, [h]);
129
- const ee = O.current || e.dir || l.current && getComputedStyle(l.current).direction || void 0, te = !X || f.valid, ae = x(
135
+ ie(G, v, [v]);
136
+ const ee = O.current || e.dir || l.current && getComputedStyle(l.current).direction || void 0, te = !X || m.valid, ae = M(
130
137
  "k-switch",
131
138
  {
132
- [`k-switch-${M.sizeMap[y] || y}`]: y,
139
+ [`k-switch-${B.sizeMap[k] || k}`]: k,
133
140
  "k-switch-on": n,
134
141
  "k-switch-off": !n,
135
142
  "k-focus": U,
@@ -142,20 +149,20 @@ const r = {
142
149
  {
143
150
  type: "checkbox",
144
151
  checked: e.checked,
145
- ref: R,
152
+ ref: b,
146
153
  tabIndex: -1,
147
154
  "aria-hidden": !0,
148
- "aria-label": e.ariaLabel || L.toLanguageString($, W[$]),
155
+ "aria-label": e.ariaLabel || E.toLanguageString($, W[$]),
149
156
  value: n,
150
157
  style: { opacity: 0, width: 1, border: 0, zIndex: -1, position: "absolute", left: "50%" },
151
- onChange: B,
158
+ onChange: I,
152
159
  name: e.name || void 0
153
160
  }
154
161
  );
155
162
  return /* @__PURE__ */ d.createElement(
156
163
  "span",
157
164
  {
158
- ref: o,
165
+ ref: s,
159
166
  role: "switch",
160
167
  "aria-checked": n,
161
168
  "aria-disabled": c || void 0,
@@ -169,70 +176,70 @@ const r = {
169
176
  onClick: Y,
170
177
  onBlur: p,
171
178
  onFocus: _,
172
- tabIndex: oe(e.tabIndex, c, void 0),
179
+ tabIndex: se(e.tabIndex, c, void 0),
173
180
  accessKey: e.accessKey,
174
181
  id: e.id
175
182
  },
176
183
  /* @__PURE__ */ d.createElement(
177
184
  "span",
178
185
  {
179
- className: x("k-switch-track", {
180
- [`k-rounded-${M.roundedMap[k] || k}`]: k
186
+ className: M("k-switch-track", {
187
+ [`k-rounded-${B.roundedMap[w] || w}`]: w
181
188
  }),
182
189
  ref: l
183
190
  },
184
191
  ne,
185
- F ? /* @__PURE__ */ d.createElement("span", { className: "k-switch-label-on" }, F) : "",
186
- I ? /* @__PURE__ */ d.createElement("span", { className: "k-switch-label-off" }, I) : ""
192
+ D ? /* @__PURE__ */ d.createElement("span", { className: "k-switch-label-on" }, D) : "",
193
+ F ? /* @__PURE__ */ d.createElement("span", { className: "k-switch-label-off" }, F) : ""
187
194
  ),
188
195
  /* @__PURE__ */ d.createElement("span", { className: "k-switch-thumb-wrap" }, /* @__PURE__ */ d.createElement(
189
196
  "span",
190
197
  {
191
- className: x("k-switch-thumb", {
192
- [`k-rounded-${M.roundedMap[w] || w}`]: w
198
+ className: M("k-switch-thumb", {
199
+ [`k-rounded-${B.roundedMap[C] || C}`]: C
193
200
  })
194
201
  }
195
202
  ))
196
203
  );
197
204
  });
198
205
  A.displayName = "Switch";
199
- const me = se(), j = re(
206
+ const fe = oe(), j = re(
200
207
  ce(
201
- me,
208
+ fe,
202
209
  A
203
210
  )
204
211
  );
205
212
  j.displayName = "KendoReactSwitch";
206
213
  j.propTypes = {
207
- accessKey: a.string,
208
- checked: a.bool,
209
- className: a.string,
210
- defaultChecked: a.bool,
211
- defaultValue: a.any,
212
- disabled: a.bool,
213
- dir: a.string,
214
- id: a.string,
215
- size: a.oneOf(["small", "medium", "large"]),
216
- trackRounded: a.oneOf(["small", "medium", "large", "full"]),
217
- thumbRounded: a.oneOf(["small", "medium", "large", "full"]),
218
- ariaDescribedBy: a.string,
219
- ariaLabelledBy: a.string,
220
- ariaLabel: a.string,
221
- offLabel: a.node,
222
- onBlur: a.func,
223
- onChange: a.func,
224
- onFocus: a.func,
225
- onLabel: a.node,
226
- tabIndex: a.number,
227
- value: a.any,
228
- name: a.string,
229
- required: a.bool,
230
- valid: a.bool,
231
- validationMessage: a.string,
232
- validityStyles: a.bool
214
+ accessKey: t.string,
215
+ checked: t.bool,
216
+ className: t.string,
217
+ defaultChecked: t.bool,
218
+ defaultValue: t.any,
219
+ disabled: t.bool,
220
+ dir: t.string,
221
+ id: t.string,
222
+ size: t.oneOf(["small", "medium", "large"]),
223
+ trackRounded: t.oneOf(["small", "medium", "large", "full"]),
224
+ thumbRounded: t.oneOf(["small", "medium", "large", "full"]),
225
+ ariaDescribedBy: t.string,
226
+ ariaLabelledBy: t.string,
227
+ ariaLabel: t.string,
228
+ offLabel: t.node,
229
+ onBlur: t.func,
230
+ onChange: t.func,
231
+ onFocus: t.func,
232
+ onLabel: t.node,
233
+ tabIndex: t.number,
234
+ value: t.any,
235
+ name: t.string,
236
+ required: t.bool,
237
+ valid: t.bool,
238
+ validationMessage: t.string,
239
+ validityStyles: t.bool
233
240
  };
234
241
  export {
235
242
  j as Switch,
236
- me as SwitchPropsContext,
243
+ fe as SwitchPropsContext,
237
244
  A as SwitchWithoutContext
238
245
  };