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