@progress/kendo-react-inputs 13.4.0-develop.2 → 13.4.0-develop.4
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 +23 -23
- package/checkbox/interfaces/CheckboxProps.d.ts +1 -1
- package/colors/ColorGradient.mjs +4 -4
- package/colors/ColorInput.d.ts +1 -1
- package/colors/ColorPicker.js +1 -1
- package/colors/ColorPicker.mjs +12 -12
- package/colors/FlatColorPicker.d.ts +1 -1
- package/colors/FlatColorPicker.mjs +11 -11
- package/colors/HexInput.d.ts +1 -1
- package/colors/interfaces/ColorGradientProps.d.ts +1 -1
- package/colors/interfaces/ColorPickerProps.d.ts +1 -1
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +1 -1
- package/index.d.ts +1 -1
- package/input/Input.mjs +13 -13
- package/maskedtextbox/MaskedTextBox.d.ts +1 -1
- package/maskedtextbox/MaskedTextBox.js +1 -1
- package/maskedtextbox/MaskedTextBox.mjs +15 -15
- package/maskedtextbox/MaskedTextBoxProps.d.ts +1 -1
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +40 -40
- package/numerictextbox/interfaces/NumericTextBoxProps.d.ts +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +10 -10
- package/radiobutton/RadioButton.mjs +18 -18
- package/radiobutton/RadioGroup.mjs +15 -15
- package/range-slider/RangeSlider.mjs +15 -15
- package/rating/Rating.mjs +12 -12
- package/rating/RatingItem.mjs +4 -4
- package/signature/Signature.js +1 -1
- package/signature/Signature.mjs +13 -13
- package/signature/interfaces/SignatureProps.d.ts +1 -1
- package/slider/Slider.d.ts +12 -78
- package/slider/Slider.js +1 -1
- package/slider/Slider.mjs +241 -191
- package/switch/Switch.d.ts +11 -126
- package/switch/Switch.js +1 -1
- package/switch/Switch.mjs +187 -209
- package/textarea/TextArea.js +1 -1
- package/textarea/TextArea.mjs +21 -21
- package/textarea/interfaces/TextAreaProps.d.ts +1 -1
- package/textbox/Textbox.d.ts +2 -1
- package/textbox/Textbox.js +1 -1
- package/textbox/Textbox.mjs +19 -19
package/switch/Switch.d.ts
CHANGED
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import { BaseEvent, FormComponent, FormComponentProps, FormComponentValidity } from '@progress/kendo-react-common';
|
|
8
|
+
import { BaseEvent, FormComponentProps, FormComponentValidity } from '@progress/kendo-react-common';
|
|
10
9
|
import { ToggleBaseProps } from '../interfaces/ToggleBaseProps.js';
|
|
11
10
|
import * as React from 'react';
|
|
12
11
|
/**
|
|
13
12
|
* The arguments for the `onChange` Switch event.
|
|
14
13
|
*/
|
|
15
|
-
export interface SwitchChangeEvent extends BaseEvent<
|
|
14
|
+
export interface SwitchChangeEvent extends BaseEvent<SwitchHandle> {
|
|
16
15
|
/**
|
|
17
16
|
* The new value of the Switch.
|
|
18
17
|
*/
|
|
@@ -103,7 +102,7 @@ export interface SwitchProps extends ToggleBaseProps, FormComponentProps {
|
|
|
103
102
|
* - large
|
|
104
103
|
* - null—Does not set a size `className`.
|
|
105
104
|
*
|
|
106
|
-
* @default
|
|
105
|
+
* @default undefined (theme-controlled)
|
|
107
106
|
* @example
|
|
108
107
|
* ```jsx
|
|
109
108
|
* <Switch size="large" />
|
|
@@ -126,7 +125,7 @@ export interface SwitchProps extends ToggleBaseProps, FormComponentProps {
|
|
|
126
125
|
* <Switch trackRounded="medium" />
|
|
127
126
|
* ```
|
|
128
127
|
*/
|
|
129
|
-
trackRounded?: 'small' | 'medium' | 'large' | 'full';
|
|
128
|
+
trackRounded?: 'small' | 'medium' | 'large' | 'full' | 'none';
|
|
130
129
|
/**
|
|
131
130
|
* Configures the `thumbRounded` property of the Switch.
|
|
132
131
|
*
|
|
@@ -143,7 +142,7 @@ export interface SwitchProps extends ToggleBaseProps, FormComponentProps {
|
|
|
143
142
|
* <Switch thumbRounded="full" />
|
|
144
143
|
* ```
|
|
145
144
|
*/
|
|
146
|
-
thumbRounded?: 'small' | 'medium' | 'large' | 'full';
|
|
145
|
+
thumbRounded?: 'small' | 'medium' | 'large' | 'full' | 'none';
|
|
147
146
|
/**
|
|
148
147
|
* Identifies the element(s) which will describe the component.
|
|
149
148
|
* For example these elements could contain error or hint message.
|
|
@@ -236,124 +235,8 @@ export interface SwitchProps extends ToggleBaseProps, FormComponentProps {
|
|
|
236
235
|
*/
|
|
237
236
|
ariaLabel?: string;
|
|
238
237
|
}
|
|
239
|
-
/**
|
|
240
|
-
* @hidden
|
|
241
|
-
*/
|
|
242
|
-
export interface SwitchState {
|
|
243
|
-
checked: boolean;
|
|
244
|
-
focused: boolean;
|
|
245
|
-
}
|
|
246
238
|
/** @hidden */
|
|
247
|
-
export declare
|
|
248
|
-
static displayName: string;
|
|
249
|
-
/**
|
|
250
|
-
* Gets the value of the Switch.
|
|
251
|
-
*/
|
|
252
|
-
get value(): boolean;
|
|
253
|
-
get element(): HTMLSpanElement | null;
|
|
254
|
-
get actionElement(): HTMLSpanElement | null;
|
|
255
|
-
/**
|
|
256
|
-
* Gets the `name` property of the Switch.
|
|
257
|
-
*/
|
|
258
|
-
get name(): string | undefined;
|
|
259
|
-
/**
|
|
260
|
-
* Represents the validity state into which the Switch is set.
|
|
261
|
-
*/
|
|
262
|
-
get validity(): FormComponentValidity;
|
|
263
|
-
/**
|
|
264
|
-
* @hidden
|
|
265
|
-
*/
|
|
266
|
-
protected get validityStyles(): boolean;
|
|
267
|
-
/**
|
|
268
|
-
* @hidden
|
|
269
|
-
*/
|
|
270
|
-
protected get required(): boolean;
|
|
271
|
-
/**
|
|
272
|
-
* @hidden
|
|
273
|
-
*/
|
|
274
|
-
protected setValidity: () => void;
|
|
275
|
-
protected limit: (offset: number, drag: HTMLSpanElement, wrapper: HTMLSpanElement) => number;
|
|
276
|
-
protected toggle: (value: boolean, event: any) => void;
|
|
277
|
-
/**
|
|
278
|
-
* @hidden
|
|
279
|
-
*/
|
|
280
|
-
static propTypes: {
|
|
281
|
-
accessKey: PropTypes.Requireable<string>;
|
|
282
|
-
checked: PropTypes.Requireable<boolean>;
|
|
283
|
-
className: PropTypes.Requireable<string>;
|
|
284
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
285
|
-
defaultChecked: PropTypes.Requireable<boolean>;
|
|
286
|
-
size: PropTypes.Requireable<"small" | "medium" | "large" | undefined>;
|
|
287
|
-
trackRounded: PropTypes.Requireable<"small" | "medium" | "large" | "full" | undefined>;
|
|
288
|
-
thumbRounded: PropTypes.Requireable<"small" | "medium" | "large" | "full" | undefined>;
|
|
289
|
-
dir: PropTypes.Requireable<string>;
|
|
290
|
-
id: PropTypes.Requireable<string>;
|
|
291
|
-
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
292
|
-
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
293
|
-
offLabel: PropTypes.Requireable<string>;
|
|
294
|
-
required: PropTypes.Requireable<boolean>;
|
|
295
|
-
tabIndex: PropTypes.Requireable<number>;
|
|
296
|
-
valid: PropTypes.Requireable<boolean>;
|
|
297
|
-
validate: PropTypes.Requireable<boolean>;
|
|
298
|
-
validationMessage: PropTypes.Requireable<string>;
|
|
299
|
-
onBlur: PropTypes.Requireable<any>;
|
|
300
|
-
onChange: PropTypes.Requireable<any>;
|
|
301
|
-
onFocus: PropTypes.Requireable<any>;
|
|
302
|
-
onLabel: PropTypes.Requireable<string>;
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* @hidden
|
|
306
|
-
*/
|
|
307
|
-
static defaultProps: {
|
|
308
|
-
disabled: boolean;
|
|
309
|
-
defaultChecked: boolean;
|
|
310
|
-
size: undefined;
|
|
311
|
-
trackRounded: undefined;
|
|
312
|
-
thumbRounded: undefined;
|
|
313
|
-
offLabel: string;
|
|
314
|
-
onBlur: () => void;
|
|
315
|
-
onFocus: () => void;
|
|
316
|
-
onLabel: string;
|
|
317
|
-
validityStyles: boolean;
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* @hidden
|
|
321
|
-
*/
|
|
322
|
-
readonly state: SwitchState;
|
|
323
|
-
private _element;
|
|
324
|
-
private _wrapper;
|
|
325
|
-
private _input;
|
|
326
|
-
private _id;
|
|
327
|
-
private valueDuringOnChange;
|
|
328
|
-
private dir?;
|
|
329
|
-
private defaultValidationMessage;
|
|
330
|
-
private eventTimeStamp?;
|
|
331
|
-
/**
|
|
332
|
-
* @hidden
|
|
333
|
-
*/
|
|
334
|
-
constructor(props: SwitchProps);
|
|
335
|
-
/**
|
|
336
|
-
* @hidden
|
|
337
|
-
*/
|
|
338
|
-
componentDidMount(): void;
|
|
339
|
-
/**
|
|
340
|
-
* @hidden
|
|
341
|
-
*/
|
|
342
|
-
componentDidUpdate(): void;
|
|
343
|
-
/**
|
|
344
|
-
* @hidden
|
|
345
|
-
*/
|
|
346
|
-
focus: () => void;
|
|
347
|
-
/**
|
|
348
|
-
* @hidden
|
|
349
|
-
*/
|
|
350
|
-
render(): React.JSX.Element;
|
|
351
|
-
private dummyInput;
|
|
352
|
-
private handleClick;
|
|
353
|
-
private handleKeyDown;
|
|
354
|
-
private handleWrapperFocus;
|
|
355
|
-
private handleWrapperBlur;
|
|
356
|
-
}
|
|
239
|
+
export declare const SwitchWithoutContext: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<SwitchHandle>>;
|
|
357
240
|
/**
|
|
358
241
|
* Represents the PropsContext of the `Switch` component.
|
|
359
242
|
* Used for global configuration of all `Switch` instances.
|
|
@@ -364,7 +247,11 @@ export declare const SwitchPropsContext: React.Context<(p: SwitchProps) => Switc
|
|
|
364
247
|
/**
|
|
365
248
|
* Represent the `ref` of the Switch component.
|
|
366
249
|
*/
|
|
367
|
-
export interface SwitchHandle
|
|
250
|
+
export interface SwitchHandle {
|
|
251
|
+
/**
|
|
252
|
+
* The props of the SwitchHandle component.
|
|
253
|
+
*/
|
|
254
|
+
props: SwitchProps;
|
|
368
255
|
/**
|
|
369
256
|
* @hidden
|
|
370
257
|
*/
|
|
@@ -386,8 +273,6 @@ export interface SwitchHandle extends Pick<SwitchWithoutContext, keyof SwitchWit
|
|
|
386
273
|
*/
|
|
387
274
|
value: boolean;
|
|
388
275
|
}
|
|
389
|
-
/** @hidden */
|
|
390
|
-
export type Switch = SwitchHandle;
|
|
391
276
|
/**
|
|
392
277
|
* Represents the [KendoReact Switch component](https://www.telerik.com/kendo-react-ui/components/inputs/switch).
|
|
393
278
|
*
|
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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),X=require("prop-types"),i=require("@progress/kendo-react-common"),Y=require("@progress/kendo-react-intl"),S=require("../messages/index.js");function z(e){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const c in e)if(c!=="default"){const m=Object.getOwnPropertyDescriptor(e,c);Object.defineProperty(u,c,m.get?m:{enumerable:!0,get:()=>e[c]})}}return u.default=e,Object.freeze(u)}const d=z(n),t=z(X),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},M=d.forwardRef((e,u)=>{var P;const{disabled:c=l.disabled,defaultChecked:m=l.defaultChecked,size:v=l.size,trackRounded:y=l.trackRounded,thumbRounded:g=l.thumbRounded,offLabel:x=l.offLabel,onBlur:C=l.onBlur,onFocus:w=l.onFocus,onLabel:L=l.onLabel}=e,[E,j]=n.useState(m||!1),[V,O]=n.useState(!1),o=n.useRef(null),I=n.useRef(null),R=n.useRef(null),b=n.useRef(void 0),q=n.useRef(void 0),B=n.useRef(void 0),D=n.useMemo(()=>new Y.LocalizationService,[]),s=n.useMemo(()=>b.current!==void 0?b.current:e.checked!==void 0?e.checked:E,[e.checked,E]),f=n.useMemo(()=>{var T,F;const a=e.validationMessage!==void 0,r=(T=e.valid)!=null?T:e.required?!!s:!0,U=(F=e.valid)!=null?F:r;return{customError:a,valid:U,valueMissing:s===null}},[e.valid,e.validationMessage,e.required,s]),_=(P=e.validityStyles)!=null?P:l.validityStyles;n.useEffect(()=>{var a;(a=R.current)!=null&&a.setCustomValidity&&R.current.setCustomValidity(f.valid?"":e.validationMessage||D.toLanguageString(S.switchValidation,S.messages[S.switchValidation]))},[f,e.validationMessage,D]),n.useEffect(()=>{o.current&&(B.current=e.dir||getComputedStyle(o.current).direction||void 0)},[e.dir]);const h=n.useCallback(()=>({props:e,get element(){return o.current},get actionElement(){return I.current},get value(){return s},get name(){return e.name},get validity(){return f}}),[e,s,f]),k=n.useCallback((a,r)=>{j(a),b.current=a,i.dispatchEvent(e.onChange,r,{...h(),value:a},{value:a}),b.current=void 0},[e.onChange,h]),W=n.useCallback(a=>{q.current!==a.timeStamp&&(q.current=a.timeStamp,k(!s,a))},[s,k]),H=n.useCallback(a=>{if(c)return;const{keyCode:r}=a;(r===i.Keys.space||r===i.Keys.enter)&&(k(!s,a),a.preventDefault())},[c,s,k]),$=n.useCallback(a=>{c||(O(!0),w&&w(a))},[c,w]),p=n.useCallback(a=>{c||(O(!1),C&&C(a))},[c,C]);n.useImperativeHandle(u,h,[h]);const A=B.current||e.dir||o.current&&getComputedStyle(o.current).direction||void 0,G=!_||f.valid,J=i.classNames("k-switch",{[`k-switch-${i.kendoThemeMaps.sizeMap[v]||v}`]:v,"k-switch-on":s,"k-switch-off":!s,"k-focus":V,"k-disabled":c,"k-invalid":!G},e.className),Q=d.createElement("input",{type:"checkbox",checked:e.checked,ref:R,tabIndex:-1,"aria-hidden":!0,value:s,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:I,role:"switch","aria-checked":s,"aria-disabled":c||void 0,"aria-labelledby":e.ariaLabelledBy,"aria-describedby":e.ariaDescribedBy,"aria-label":e.ariaLabel,"aria-required":e.required,className:J,dir:A,onKeyDown:H,onClick:W,onBlur:p,onFocus:$,tabIndex:i.getTabIndex(e.tabIndex,c,void 0),accessKey:e.accessKey,id:e.id},d.createElement("span",{className:i.classNames("k-switch-track",{[`k-rounded-${i.kendoThemeMaps.roundedMap[y]||y}`]:y}),ref:o},Q,L?d.createElement("span",{className:"k-switch-label-on"},L):"",x?d.createElement("span",{className:"k-switch-label-off"},x):""),d.createElement("span",{className:"k-switch-thumb-wrap"},d.createElement("span",{className:i.classNames("k-switch-thumb",{[`k-rounded-${i.kendoThemeMaps.roundedMap[g]||g}`]:g})})))});M.displayName="Switch";const K=i.createPropsContext(),N=i.withIdHOC(i.withPropsContext(K,M));N.displayName="KendoReactSwitch";N.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=N;exports.SwitchPropsContext=K;exports.SwitchWithoutContext=M;
|
package/switch/Switch.mjs
CHANGED
|
@@ -5,232 +5,210 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
style: { opacity: 0, width: 1, border: 0, zIndex: -1, position: "absolute", left: "50%" },
|
|
41
|
-
onChange: h,
|
|
42
|
-
name: this.name || void 0
|
|
43
|
-
}
|
|
44
|
-
), this.handleClick = (e) => {
|
|
45
|
-
this.eventTimeStamp !== e.timeStamp && (this.eventTimeStamp = e.timeStamp, this.toggle(!this.value, e));
|
|
46
|
-
}, this.handleKeyDown = (e) => {
|
|
47
|
-
if (this.props.disabled)
|
|
48
|
-
return;
|
|
49
|
-
const { keyCode: i } = e;
|
|
50
|
-
(i === v.space || i === v.enter) && (this.toggle(!this.value, e), e.preventDefault());
|
|
51
|
-
}, this.handleWrapperFocus = (e) => {
|
|
52
|
-
if (this.props.disabled)
|
|
53
|
-
return;
|
|
54
|
-
this.setState({ focused: !0 });
|
|
55
|
-
const { onFocus: i } = this.props;
|
|
56
|
-
i && i.call(void 0, e);
|
|
57
|
-
}, this.handleWrapperBlur = (e) => {
|
|
58
|
-
if (this.props.disabled)
|
|
59
|
-
return;
|
|
60
|
-
this.setState({ focused: !1 });
|
|
61
|
-
const { onBlur: i } = this.props;
|
|
62
|
-
i && i.call(void 0, e);
|
|
63
|
-
}, this.state = {
|
|
64
|
-
checked: r.defaultChecked || a.defaultProps.defaultChecked,
|
|
65
|
-
focused: !1
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Gets the value of the Switch.
|
|
70
|
-
*/
|
|
71
|
-
get value() {
|
|
72
|
-
return this.valueDuringOnChange !== void 0 ? this.valueDuringOnChange : this.props.checked !== void 0 ? this.props.checked : this.state.checked;
|
|
73
|
-
}
|
|
74
|
-
get element() {
|
|
75
|
-
return this._element;
|
|
76
|
-
}
|
|
77
|
-
get actionElement() {
|
|
78
|
-
return this._wrapper;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Gets the `name` property of the Switch.
|
|
82
|
-
*/
|
|
83
|
-
get name() {
|
|
84
|
-
return this.props.name;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Represents the validity state into which the Switch is set.
|
|
88
|
-
*/
|
|
89
|
-
get validity() {
|
|
90
|
-
const r = this.props.validationMessage !== void 0, e = this.props.valid !== void 0 ? this.props.valid : this.props.required ? !!this.value : !0, i = this.props.valid !== void 0 ? this.props.valid : e;
|
|
8
|
+
import * as r from "react";
|
|
9
|
+
import { useState as q, useRef as o, useMemo as C, useEffect as P, useCallback as s, useImperativeHandle as ae } from "react";
|
|
10
|
+
import * as t from "prop-types";
|
|
11
|
+
import { withIdHOC as ne, withPropsContext as ie, createPropsContext as de, noop as L, dispatchEvent as re, Keys as T, classNames as R, kendoThemeMaps as S, getTabIndex as le } from "@progress/kendo-react-common";
|
|
12
|
+
import { LocalizationService as ce } from "@progress/kendo-react-intl";
|
|
13
|
+
import { switchValidation as V, messages as oe } from "../messages/index.mjs";
|
|
14
|
+
const i = {
|
|
15
|
+
disabled: !1,
|
|
16
|
+
defaultChecked: !1,
|
|
17
|
+
size: void 0,
|
|
18
|
+
trackRounded: void 0,
|
|
19
|
+
thumbRounded: void 0,
|
|
20
|
+
offLabel: "OFF",
|
|
21
|
+
onBlur: L,
|
|
22
|
+
onFocus: L,
|
|
23
|
+
onLabel: "ON",
|
|
24
|
+
validityStyles: !0
|
|
25
|
+
}, H = r.forwardRef((e, $) => {
|
|
26
|
+
var z;
|
|
27
|
+
const {
|
|
28
|
+
disabled: d = i.disabled,
|
|
29
|
+
defaultChecked: j = i.defaultChecked,
|
|
30
|
+
size: b = i.size,
|
|
31
|
+
trackRounded: v = i.trackRounded,
|
|
32
|
+
thumbRounded: y = i.thumbRounded,
|
|
33
|
+
offLabel: N = i.offLabel,
|
|
34
|
+
onBlur: k = i.onBlur,
|
|
35
|
+
onFocus: g = i.onFocus,
|
|
36
|
+
onLabel: x = i.onLabel
|
|
37
|
+
} = e, [E, A] = q(j || !1), [G, M] = q(!1), l = o(null), B = o(null), w = o(null), m = o(void 0), I = o(void 0), F = o(void 0), D = C(() => new ce(), []), n = C(() => m.current !== void 0 ? m.current : e.checked !== void 0 ? e.checked : E, [e.checked, E]), u = C(() => {
|
|
38
|
+
var K, O;
|
|
39
|
+
const a = e.validationMessage !== void 0, c = (K = e.valid) != null ? K : e.required ? !!n : !0, te = (O = e.valid) != null ? O : c;
|
|
91
40
|
return {
|
|
92
|
-
customError:
|
|
93
|
-
valid:
|
|
94
|
-
valueMissing:
|
|
41
|
+
customError: a,
|
|
42
|
+
valid: te,
|
|
43
|
+
valueMissing: n === null
|
|
95
44
|
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
45
|
+
}, [e.valid, e.validationMessage, e.required, n]), J = (z = e.validityStyles) != null ? z : i.validityStyles;
|
|
46
|
+
P(() => {
|
|
47
|
+
var a;
|
|
48
|
+
(a = w.current) != null && a.setCustomValidity && w.current.setCustomValidity(
|
|
49
|
+
u.valid ? "" : e.validationMessage || D.toLanguageString(V, oe[V])
|
|
50
|
+
);
|
|
51
|
+
}, [u, e.validationMessage, D]), P(() => {
|
|
52
|
+
l.current && (F.current = e.dir || getComputedStyle(l.current).direction || void 0);
|
|
53
|
+
}, [e.dir]);
|
|
54
|
+
const f = s(() => ({
|
|
55
|
+
props: e,
|
|
56
|
+
get element() {
|
|
57
|
+
return l.current;
|
|
58
|
+
},
|
|
59
|
+
get actionElement() {
|
|
60
|
+
return B.current;
|
|
61
|
+
},
|
|
62
|
+
get value() {
|
|
63
|
+
return n;
|
|
64
|
+
},
|
|
65
|
+
get name() {
|
|
66
|
+
return e.name;
|
|
67
|
+
},
|
|
68
|
+
get validity() {
|
|
69
|
+
return u;
|
|
70
|
+
}
|
|
71
|
+
}), [e, n, u]), h = s(
|
|
72
|
+
(a, c) => {
|
|
73
|
+
A(a), m.current = a, re(
|
|
74
|
+
e.onChange,
|
|
75
|
+
c,
|
|
76
|
+
{ ...f(), value: a },
|
|
77
|
+
{ value: a }
|
|
78
|
+
), m.current = void 0;
|
|
79
|
+
},
|
|
80
|
+
[e.onChange, f]
|
|
81
|
+
), Q = s(
|
|
82
|
+
(a) => {
|
|
83
|
+
I.current !== a.timeStamp && (I.current = a.timeStamp, h(!n, a));
|
|
84
|
+
},
|
|
85
|
+
[n, h]
|
|
86
|
+
), U = s(
|
|
87
|
+
(a) => {
|
|
88
|
+
if (d)
|
|
89
|
+
return;
|
|
90
|
+
const { keyCode: c } = a;
|
|
91
|
+
(c === T.space || c === T.enter) && (h(!n, a), a.preventDefault());
|
|
92
|
+
},
|
|
93
|
+
[d, n, h]
|
|
94
|
+
), X = s(
|
|
95
|
+
(a) => {
|
|
96
|
+
d || (M(!0), g && g(a));
|
|
97
|
+
},
|
|
98
|
+
[d, g]
|
|
99
|
+
), Y = s(
|
|
100
|
+
(a) => {
|
|
101
|
+
d || (M(!1), k && k(a));
|
|
102
|
+
},
|
|
103
|
+
[d, k]
|
|
104
|
+
);
|
|
105
|
+
ae($, f, [f]);
|
|
106
|
+
const Z = F.current || e.dir || l.current && getComputedStyle(l.current).direction || void 0, _ = !J || u.valid, p = R(
|
|
107
|
+
"k-switch",
|
|
108
|
+
{
|
|
109
|
+
[`k-switch-${S.sizeMap[b] || b}`]: b,
|
|
110
|
+
"k-switch-on": n,
|
|
111
|
+
"k-switch-off": !n,
|
|
112
|
+
"k-focus": G,
|
|
113
|
+
"k-disabled": d,
|
|
114
|
+
"k-invalid": !_
|
|
115
|
+
},
|
|
116
|
+
e.className
|
|
117
|
+
), ee = /* @__PURE__ */ r.createElement(
|
|
118
|
+
"input",
|
|
119
|
+
{
|
|
120
|
+
type: "checkbox",
|
|
121
|
+
checked: e.checked,
|
|
122
|
+
ref: w,
|
|
123
|
+
tabIndex: -1,
|
|
124
|
+
"aria-hidden": !0,
|
|
125
|
+
value: n,
|
|
126
|
+
style: { opacity: 0, width: 1, border: 0, zIndex: -1, position: "absolute", left: "50%" },
|
|
127
|
+
onChange: L,
|
|
128
|
+
name: e.name || void 0
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
return /* @__PURE__ */ r.createElement(
|
|
132
|
+
"span",
|
|
133
|
+
{
|
|
134
|
+
ref: B,
|
|
135
|
+
role: "switch",
|
|
136
|
+
"aria-checked": n,
|
|
137
|
+
"aria-disabled": d || void 0,
|
|
138
|
+
"aria-labelledby": e.ariaLabelledBy,
|
|
139
|
+
"aria-describedby": e.ariaDescribedBy,
|
|
140
|
+
"aria-label": e.ariaLabel,
|
|
141
|
+
"aria-required": e.required,
|
|
142
|
+
className: p,
|
|
143
|
+
dir: Z,
|
|
144
|
+
onKeyDown: U,
|
|
145
|
+
onClick: Q,
|
|
146
|
+
onBlur: Y,
|
|
147
|
+
onFocus: X,
|
|
148
|
+
tabIndex: le(e.tabIndex, d, void 0),
|
|
149
|
+
accessKey: e.accessKey,
|
|
150
|
+
id: e.id
|
|
151
|
+
},
|
|
152
|
+
/* @__PURE__ */ r.createElement(
|
|
153
|
+
"span",
|
|
129
154
|
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"k-disabled": i,
|
|
135
|
-
"k-invalid": !y
|
|
155
|
+
className: R("k-switch-track", {
|
|
156
|
+
[`k-rounded-${S.roundedMap[v] || v}`]: v
|
|
157
|
+
}),
|
|
158
|
+
ref: l
|
|
136
159
|
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
"aria-describedby": this.props.ariaDescribedBy,
|
|
143
|
-
"aria-label": this.props.ariaLabel,
|
|
144
|
-
"aria-required": this.props.required
|
|
145
|
-
};
|
|
146
|
-
return /* @__PURE__ */ s.createElement(
|
|
160
|
+
ee,
|
|
161
|
+
x ? /* @__PURE__ */ r.createElement("span", { className: "k-switch-label-on" }, x) : "",
|
|
162
|
+
N ? /* @__PURE__ */ r.createElement("span", { className: "k-switch-label-off" }, N) : ""
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ r.createElement("span", { className: "k-switch-thumb-wrap" }, /* @__PURE__ */ r.createElement(
|
|
147
165
|
"span",
|
|
148
166
|
{
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"span",
|
|
166
|
-
{
|
|
167
|
-
className: p("k-switch-track", {
|
|
168
|
-
[`k-rounded-${c.roundedMap[d] || d}`]: d
|
|
169
|
-
}),
|
|
170
|
-
ref: (n) => {
|
|
171
|
-
this._element = n;
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
this.dummyInput(this.value),
|
|
175
|
-
f ? /* @__PURE__ */ s.createElement("span", { className: "k-switch-label-on" }, f) : "",
|
|
176
|
-
m ? /* @__PURE__ */ s.createElement("span", { className: "k-switch-label-off" }, m) : ""
|
|
177
|
-
),
|
|
178
|
-
/* @__PURE__ */ s.createElement("span", { className: "k-switch-thumb-wrap" }, /* @__PURE__ */ s.createElement(
|
|
179
|
-
"span",
|
|
180
|
-
{
|
|
181
|
-
className: p("k-switch-thumb", {
|
|
182
|
-
[`k-rounded-${c.roundedMap[o] || o}`]: o
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
))
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
a.displayName = "Switch", a.propTypes = {
|
|
167
|
+
className: R("k-switch-thumb", {
|
|
168
|
+
[`k-rounded-${S.roundedMap[y] || y}`]: y
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
))
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
H.displayName = "Switch";
|
|
175
|
+
const se = de(), W = ne(
|
|
176
|
+
ie(
|
|
177
|
+
se,
|
|
178
|
+
H
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
W.displayName = "KendoReactSwitch";
|
|
182
|
+
W.propTypes = {
|
|
190
183
|
accessKey: t.string,
|
|
191
184
|
checked: t.bool,
|
|
192
185
|
className: t.string,
|
|
193
|
-
disabled: t.bool,
|
|
194
186
|
defaultChecked: t.bool,
|
|
187
|
+
defaultValue: t.any,
|
|
188
|
+
disabled: t.bool,
|
|
189
|
+
dir: t.string,
|
|
190
|
+
id: t.string,
|
|
195
191
|
size: t.oneOf(["small", "medium", "large"]),
|
|
196
192
|
trackRounded: t.oneOf(["small", "medium", "large", "full"]),
|
|
197
193
|
thumbRounded: t.oneOf(["small", "medium", "large", "full"]),
|
|
198
|
-
dir: t.string,
|
|
199
|
-
id: t.string,
|
|
200
|
-
ariaLabelledBy: t.string,
|
|
201
194
|
ariaDescribedBy: t.string,
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
ariaLabelledBy: t.string,
|
|
196
|
+
ariaLabel: t.string,
|
|
197
|
+
offLabel: t.node,
|
|
198
|
+
onBlur: t.func,
|
|
199
|
+
onChange: t.func,
|
|
200
|
+
onFocus: t.func,
|
|
201
|
+
onLabel: t.node,
|
|
204
202
|
tabIndex: t.number,
|
|
203
|
+
value: t.any,
|
|
204
|
+
name: t.string,
|
|
205
|
+
required: t.bool,
|
|
205
206
|
valid: t.bool,
|
|
206
|
-
validate: t.bool,
|
|
207
207
|
validationMessage: t.string,
|
|
208
|
-
|
|
209
|
-
onChange: t.any,
|
|
210
|
-
onFocus: t.any,
|
|
211
|
-
onLabel: t.string
|
|
212
|
-
}, a.defaultProps = {
|
|
213
|
-
disabled: !1,
|
|
214
|
-
defaultChecked: !1,
|
|
215
|
-
size: void 0,
|
|
216
|
-
trackRounded: void 0,
|
|
217
|
-
thumbRounded: void 0,
|
|
218
|
-
offLabel: "OFF",
|
|
219
|
-
onBlur: h,
|
|
220
|
-
onFocus: h,
|
|
221
|
-
onLabel: "ON",
|
|
222
|
-
validityStyles: !0
|
|
208
|
+
validityStyles: t.bool
|
|
223
209
|
};
|
|
224
|
-
let u = a;
|
|
225
|
-
const B = N(), O = C(
|
|
226
|
-
S(
|
|
227
|
-
B,
|
|
228
|
-
u
|
|
229
|
-
)
|
|
230
|
-
);
|
|
231
|
-
O.displayName = "KendoReactSwitch";
|
|
232
210
|
export {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
211
|
+
W as Switch,
|
|
212
|
+
se as SwitchPropsContext,
|
|
213
|
+
H as SwitchWithoutContext
|
|
236
214
|
};
|