@progress/kendo-react-inputs 8.2.0-develop.1 → 8.2.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/checkbox/Checkbox.js +1 -1
- package/checkbox/Checkbox.mjs +115 -112
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +28 -0
- package/index.d.ts +28 -0
- package/input/Input.js +1 -1
- package/input/Input.mjs +47 -43
- package/maskedtextbox/MaskedTextBox.js +1 -1
- package/maskedtextbox/MaskedTextBox.mjs +61 -57
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +89 -86
- package/package-metadata.mjs +1 -1
- package/package.json +8 -8
- package/textarea/TextArea.js +1 -1
- package/textarea/TextArea.mjs +96 -92
- package/textbox/Textbox.js +1 -1
- package/textbox/Textbox.mjs +54 -50
package/index.d.mts
CHANGED
|
@@ -169,6 +169,10 @@ export declare interface CheckboxProps extends ToggleBaseProps, FormComponentPro
|
|
|
169
169
|
* Defaults to `0`.
|
|
170
170
|
*/
|
|
171
171
|
tabIndex?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the Checkbox. (Defaults to `false`)
|
|
174
|
+
*/
|
|
175
|
+
autoFocus?: boolean;
|
|
172
176
|
/**
|
|
173
177
|
* The event handler that will be fired when the user edits the value.
|
|
174
178
|
*/
|
|
@@ -1319,6 +1323,10 @@ export declare interface InputProps extends Omit_2<React_2.InputHTMLAttributes<H
|
|
|
1319
1323
|
* Defines a string value that labels an interactive element.
|
|
1320
1324
|
*/
|
|
1321
1325
|
ariaLabel?: string;
|
|
1326
|
+
/**
|
|
1327
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the Input. (Defaults to `false`)
|
|
1328
|
+
*/
|
|
1329
|
+
autoFocus?: boolean;
|
|
1322
1330
|
/**
|
|
1323
1331
|
* Triggered after value change.
|
|
1324
1332
|
*/
|
|
@@ -1463,6 +1471,7 @@ export declare class InputWithoutContext extends React_2.Component<InputProps, I
|
|
|
1463
1471
|
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
1464
1472
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
1465
1473
|
ariaLabel: PropTypes.Requireable<string>;
|
|
1474
|
+
autoFocus: PropTypes.Requireable<boolean>;
|
|
1466
1475
|
};
|
|
1467
1476
|
/**
|
|
1468
1477
|
* @hidden
|
|
@@ -1471,6 +1480,7 @@ export declare class InputWithoutContext extends React_2.Component<InputProps, I
|
|
|
1471
1480
|
defaultValue: string;
|
|
1472
1481
|
required: boolean;
|
|
1473
1482
|
validityStyles: boolean;
|
|
1483
|
+
autoFocus: boolean;
|
|
1474
1484
|
};
|
|
1475
1485
|
private _input;
|
|
1476
1486
|
private get _inputId();
|
|
@@ -1796,6 +1806,10 @@ export declare interface MaskedTextBoxProps extends FormComponentProps {
|
|
|
1796
1806
|
* @default `solid`
|
|
1797
1807
|
*/
|
|
1798
1808
|
fillMode?: null | 'solid' | 'flat' | 'outline';
|
|
1809
|
+
/**
|
|
1810
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the MaskedTextBox. (Defaults to `false`)
|
|
1811
|
+
*/
|
|
1812
|
+
autoFocus?: boolean;
|
|
1799
1813
|
}
|
|
1800
1814
|
|
|
1801
1815
|
/**
|
|
@@ -1858,6 +1872,7 @@ export declare class MaskedTextBoxWithoutContext extends React_2.Component<Maske
|
|
|
1858
1872
|
size: PropTypes.Requireable<"small" | "large" | "medium" | null | undefined>;
|
|
1859
1873
|
rounded: PropTypes.Requireable<"small" | "large" | "medium" | "full" | null | undefined>;
|
|
1860
1874
|
fillMode: PropTypes.Requireable<"flat" | "solid" | "outline" | null | undefined>;
|
|
1875
|
+
autoFocus: PropTypes.Requireable<boolean>;
|
|
1861
1876
|
};
|
|
1862
1877
|
/**
|
|
1863
1878
|
* @hidden
|
|
@@ -1877,6 +1892,7 @@ export declare class MaskedTextBoxWithoutContext extends React_2.Component<Maske
|
|
|
1877
1892
|
size: "small" | "large" | "medium" | null | undefined;
|
|
1878
1893
|
rounded: "small" | "large" | "medium" | "full" | null | undefined;
|
|
1879
1894
|
fillMode: "flat" | "solid" | "outline" | null | undefined;
|
|
1895
|
+
autoFocus: boolean;
|
|
1880
1896
|
};
|
|
1881
1897
|
/**
|
|
1882
1898
|
* @hidden
|
|
@@ -2229,6 +2245,10 @@ export declare interface NumericTextBoxProps extends FormComponentProps, Omit<(R
|
|
|
2229
2245
|
* Represents the input element `style` HTML attribute.
|
|
2230
2246
|
*/
|
|
2231
2247
|
inputStyle?: React.CSSProperties;
|
|
2248
|
+
/**
|
|
2249
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the NumericTextBox. (Defaults to `false`)
|
|
2250
|
+
*/
|
|
2251
|
+
autoFocus?: boolean;
|
|
2232
2252
|
}
|
|
2233
2253
|
|
|
2234
2254
|
/**
|
|
@@ -4187,6 +4207,10 @@ export declare interface TextAreaProps extends FormComponentProps, Omit_5<React.
|
|
|
4187
4207
|
* ```
|
|
4188
4208
|
*/
|
|
4189
4209
|
resizable?: 'none' | 'vertical' | 'horizontal' | 'both';
|
|
4210
|
+
/**
|
|
4211
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the TextArea. (Defaults to `false`)
|
|
4212
|
+
*/
|
|
4213
|
+
autoFocus?: boolean;
|
|
4190
4214
|
}
|
|
4191
4215
|
|
|
4192
4216
|
/**
|
|
@@ -4273,6 +4297,10 @@ export declare interface TextBoxProps extends Omit<React_2.InputHTMLAttributes<H
|
|
|
4273
4297
|
* Sets a custom suffix to the TextBox component.
|
|
4274
4298
|
*/
|
|
4275
4299
|
suffix?: CustomComponent<any>;
|
|
4300
|
+
/**
|
|
4301
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the TextBox. (Defaults to `false`)
|
|
4302
|
+
*/
|
|
4303
|
+
autoFocus?: boolean;
|
|
4276
4304
|
}
|
|
4277
4305
|
|
|
4278
4306
|
/**
|
package/index.d.ts
CHANGED
|
@@ -169,6 +169,10 @@ export declare interface CheckboxProps extends ToggleBaseProps, FormComponentPro
|
|
|
169
169
|
* Defaults to `0`.
|
|
170
170
|
*/
|
|
171
171
|
tabIndex?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the Checkbox. (Defaults to `false`)
|
|
174
|
+
*/
|
|
175
|
+
autoFocus?: boolean;
|
|
172
176
|
/**
|
|
173
177
|
* The event handler that will be fired when the user edits the value.
|
|
174
178
|
*/
|
|
@@ -1319,6 +1323,10 @@ export declare interface InputProps extends Omit_2<React_2.InputHTMLAttributes<H
|
|
|
1319
1323
|
* Defines a string value that labels an interactive element.
|
|
1320
1324
|
*/
|
|
1321
1325
|
ariaLabel?: string;
|
|
1326
|
+
/**
|
|
1327
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the Input. (Defaults to `false`)
|
|
1328
|
+
*/
|
|
1329
|
+
autoFocus?: boolean;
|
|
1322
1330
|
/**
|
|
1323
1331
|
* Triggered after value change.
|
|
1324
1332
|
*/
|
|
@@ -1463,6 +1471,7 @@ export declare class InputWithoutContext extends React_2.Component<InputProps, I
|
|
|
1463
1471
|
ariaLabelledBy: PropTypes.Requireable<string>;
|
|
1464
1472
|
ariaDescribedBy: PropTypes.Requireable<string>;
|
|
1465
1473
|
ariaLabel: PropTypes.Requireable<string>;
|
|
1474
|
+
autoFocus: PropTypes.Requireable<boolean>;
|
|
1466
1475
|
};
|
|
1467
1476
|
/**
|
|
1468
1477
|
* @hidden
|
|
@@ -1471,6 +1480,7 @@ export declare class InputWithoutContext extends React_2.Component<InputProps, I
|
|
|
1471
1480
|
defaultValue: string;
|
|
1472
1481
|
required: boolean;
|
|
1473
1482
|
validityStyles: boolean;
|
|
1483
|
+
autoFocus: boolean;
|
|
1474
1484
|
};
|
|
1475
1485
|
private _input;
|
|
1476
1486
|
private get _inputId();
|
|
@@ -1796,6 +1806,10 @@ export declare interface MaskedTextBoxProps extends FormComponentProps {
|
|
|
1796
1806
|
* @default `solid`
|
|
1797
1807
|
*/
|
|
1798
1808
|
fillMode?: null | 'solid' | 'flat' | 'outline';
|
|
1809
|
+
/**
|
|
1810
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the MaskedTextBox. (Defaults to `false`)
|
|
1811
|
+
*/
|
|
1812
|
+
autoFocus?: boolean;
|
|
1799
1813
|
}
|
|
1800
1814
|
|
|
1801
1815
|
/**
|
|
@@ -1858,6 +1872,7 @@ export declare class MaskedTextBoxWithoutContext extends React_2.Component<Maske
|
|
|
1858
1872
|
size: PropTypes.Requireable<"small" | "large" | "medium" | null | undefined>;
|
|
1859
1873
|
rounded: PropTypes.Requireable<"small" | "large" | "medium" | "full" | null | undefined>;
|
|
1860
1874
|
fillMode: PropTypes.Requireable<"flat" | "solid" | "outline" | null | undefined>;
|
|
1875
|
+
autoFocus: PropTypes.Requireable<boolean>;
|
|
1861
1876
|
};
|
|
1862
1877
|
/**
|
|
1863
1878
|
* @hidden
|
|
@@ -1877,6 +1892,7 @@ export declare class MaskedTextBoxWithoutContext extends React_2.Component<Maske
|
|
|
1877
1892
|
size: "small" | "large" | "medium" | null | undefined;
|
|
1878
1893
|
rounded: "small" | "large" | "medium" | "full" | null | undefined;
|
|
1879
1894
|
fillMode: "flat" | "solid" | "outline" | null | undefined;
|
|
1895
|
+
autoFocus: boolean;
|
|
1880
1896
|
};
|
|
1881
1897
|
/**
|
|
1882
1898
|
* @hidden
|
|
@@ -2229,6 +2245,10 @@ export declare interface NumericTextBoxProps extends FormComponentProps, Omit<(R
|
|
|
2229
2245
|
* Represents the input element `style` HTML attribute.
|
|
2230
2246
|
*/
|
|
2231
2247
|
inputStyle?: React.CSSProperties;
|
|
2248
|
+
/**
|
|
2249
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the NumericTextBox. (Defaults to `false`)
|
|
2250
|
+
*/
|
|
2251
|
+
autoFocus?: boolean;
|
|
2232
2252
|
}
|
|
2233
2253
|
|
|
2234
2254
|
/**
|
|
@@ -4187,6 +4207,10 @@ export declare interface TextAreaProps extends FormComponentProps, Omit_5<React.
|
|
|
4187
4207
|
* ```
|
|
4188
4208
|
*/
|
|
4189
4209
|
resizable?: 'none' | 'vertical' | 'horizontal' | 'both';
|
|
4210
|
+
/**
|
|
4211
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the TextArea. (Defaults to `false`)
|
|
4212
|
+
*/
|
|
4213
|
+
autoFocus?: boolean;
|
|
4190
4214
|
}
|
|
4191
4215
|
|
|
4192
4216
|
/**
|
|
@@ -4273,6 +4297,10 @@ export declare interface TextBoxProps extends Omit<React_2.InputHTMLAttributes<H
|
|
|
4273
4297
|
* Sets a custom suffix to the TextBox component.
|
|
4274
4298
|
*/
|
|
4275
4299
|
suffix?: CustomComponent<any>;
|
|
4300
|
+
/**
|
|
4301
|
+
* Represents the `autoFocus` HTML attribute that will be applied to the input element of the TextBox. (Defaults to `false`)
|
|
4302
|
+
*/
|
|
4303
|
+
autoFocus?: boolean;
|
|
4276
4304
|
}
|
|
4277
4305
|
|
|
4278
4306
|
/**
|
package/input/Input.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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),a=require("prop-types"),n=require("@progress/kendo-react-common"),k=require("@progress/kendo-react-labels"),O=require("../package-metadata.js");function P(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const u=P(S),s=class s extends u.Component{constructor(e){super(e),this._input=null,this.focus=()=>{this._input&&this._input.focus()},this.isInvalid=t=>{let i=!1;for(let r in t)t.hasOwnProperty(r)&&(i=i||!!t[r]);return i},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&(this.validity.valid||!this.validityStyles?this._input.classList.remove("k-invalid"):this._input.classList.add("k-invalid"),this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||""))},this.handleChange=t=>{this.setState({value:t.target.value}),this.valueDuringOnChange=t.target.value,this.props.onChange&&this.props.onChange.call(void 0,{syntheticEvent:t,nativeEvent:t.nativeEvent,value:t.target.value,target:this}),this.valueDuringOnChange=void 0},this.handleAutoFill=t=>{if(t.animationName==="autoFillStart"){let i=t.target.parentNode;i&&i.classList.contains("k-empty")&&i.classList.remove("k-empty")}},n.validatePackage(O.packageMetadata),this.state={value:this.props.defaultValue||s.defaultProps.defaultValue}}get _inputId(){return this.props.id}get element(){return this._input}get value(){return this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value}get name(){return this.props.name}get validity(){const e={badInput:this._input?this._input.validity.badInput:!1,patternMismatch:this._input?this._input.validity.patternMismatch:!1,rangeOverflow:this._input?this._input.validity.rangeOverflow:!1,rangeUnderflow:this._input?this._input.validity.rangeUnderflow:!1,stepMismatch:this._input?this._input.validity.stepMismatch:!1,tooLong:this._input?this._input.validity.tooLong:!1,typeMismatch:this._input?this._input.validity.typeMismatch:!1,valueMissing:this._input?this._input.validity.valueMissing:!1};return{...e,customError:this.props.validationMessage!==void 0,valid:this.props.valid!==void 0?this.props.valid:this._input?!this.isInvalid(e):!0}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:s.defaultProps.validityStyles}componentDidMount(){this.forceUpdate()}componentDidUpdate(){this.setValidity()}render(){const{className:e,label:t,labelClassName:i,id:r,validationMessage:I,defaultValue:L,valid:D,visited:N,touched:V,modified:w,autoFocus:f,ariaLabelledBy:m,ariaDescribedBy:b,validityStyles:q,style:p,ariaLabel:_,...o}=this.props,h=r||this._inputId,c=!this.validityStyles||this.validity.valid,C=n.classNames(e,"k-input k-input-md k-rounded-md k-input-solid"),v=u.createElement("input",{"aria-labelledby":m,"aria-describedby":b,"aria-disabled":this.props.disabled||void 0,"aria-invalid":!c||void 0,"aria-label":_||void 0,...o,style:t?void 0:p,value:this.value,id:h,autoFocus:f,className:C,onChange:this.handleChange,onAnimationStart:this.handleAutoFill,ref:M=>{this._input=M}});return t?u.createElement(k.FloatingLabel,{label:t,labelClassName:i,editorId:h,editorValue:String(this.value),editorValid:c,editorDisabled:o.disabled,editorPlaceholder:o.placeholder,children:v,style:p,dir:o.dir}):v}};s.displayName="Input",s.propTypes={label:a.string,labelClassName:a.string,validationMessage:a.string,required:a.bool,validate:a.bool,id:a.string,ariaLabelledBy:a.string,ariaDescribedBy:a.string,ariaLabel:a.string,autoFocus:a.bool},s.defaultProps={defaultValue:"",required:!1,validityStyles:!0,autoFocus:!1};let d=s;const g=n.createPropsContext(),y=n.withIdHOC(n.withPropsContext(g,d));y.displayName="KendoReactInput";exports.Input=y;exports.InputPropsContext=g;exports.InputWithoutContext=d;
|
package/input/Input.mjs
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
9
|
import * as r from "react";
|
|
10
|
-
import
|
|
11
|
-
import { validatePackage as
|
|
12
|
-
import { FloatingLabel as
|
|
13
|
-
import { packageMetadata as
|
|
10
|
+
import t from "prop-types";
|
|
11
|
+
import { validatePackage as b, classNames as _, createPropsContext as C, withIdHOC as M, withPropsContext as S } from "@progress/kendo-react-common";
|
|
12
|
+
import { FloatingLabel as L } from "@progress/kendo-react-labels";
|
|
13
|
+
import { packageMetadata as V } from "../package-metadata.mjs";
|
|
14
14
|
const e = class e extends r.Component {
|
|
15
15
|
constructor(s) {
|
|
16
16
|
super(s), this._input = null, this.focus = () => {
|
|
17
17
|
this._input && this._input.focus();
|
|
18
18
|
}, this.isInvalid = (i) => {
|
|
19
|
-
let
|
|
19
|
+
let a = !1;
|
|
20
20
|
for (let l in i)
|
|
21
|
-
i.hasOwnProperty(l) && (
|
|
22
|
-
return
|
|
21
|
+
i.hasOwnProperty(l) && (a = a || !!i[l]);
|
|
22
|
+
return a;
|
|
23
23
|
}, this.setValidity = () => {
|
|
24
24
|
this._input && this._input.setCustomValidity && (this.validity.valid || !this.validityStyles ? this._input.classList.remove("k-invalid") : this._input.classList.add("k-invalid"), this._input.setCustomValidity(
|
|
25
25
|
this.validity.valid ? "" : this.props.validationMessage || ""
|
|
@@ -35,10 +35,10 @@ const e = class e extends r.Component {
|
|
|
35
35
|
}), this.valueDuringOnChange = void 0;
|
|
36
36
|
}, this.handleAutoFill = (i) => {
|
|
37
37
|
if (i.animationName === "autoFillStart") {
|
|
38
|
-
let
|
|
39
|
-
|
|
38
|
+
let a = i.target.parentNode;
|
|
39
|
+
a && a.classList.contains("k-empty") && a.classList.remove("k-empty");
|
|
40
40
|
}
|
|
41
|
-
},
|
|
41
|
+
}, b(V), this.state = {
|
|
42
42
|
value: this.props.defaultValue || e.defaultProps.defaultValue
|
|
43
43
|
};
|
|
44
44
|
}
|
|
@@ -108,46 +108,48 @@ const e = class e extends r.Component {
|
|
|
108
108
|
const {
|
|
109
109
|
className: s,
|
|
110
110
|
label: i,
|
|
111
|
-
labelClassName:
|
|
111
|
+
labelClassName: a,
|
|
112
112
|
id: l,
|
|
113
|
-
validationMessage:
|
|
114
|
-
defaultValue:
|
|
115
|
-
valid:
|
|
113
|
+
validationMessage: P,
|
|
114
|
+
defaultValue: D,
|
|
115
|
+
valid: I,
|
|
116
116
|
// Removed to support direct use in Form Field component
|
|
117
|
-
visited:
|
|
118
|
-
touched:
|
|
119
|
-
modified:
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
visited: O,
|
|
118
|
+
touched: w,
|
|
119
|
+
modified: F,
|
|
120
|
+
autoFocus: v,
|
|
121
|
+
ariaLabelledBy: c,
|
|
122
|
+
ariaDescribedBy: y,
|
|
122
123
|
validityStyles: E,
|
|
123
124
|
style: o,
|
|
124
|
-
ariaLabel:
|
|
125
|
+
ariaLabel: g,
|
|
125
126
|
...n
|
|
126
|
-
} = this.props, p = l || this._inputId, u = !this.validityStyles || this.validity.valid,
|
|
127
|
+
} = this.props, p = l || this._inputId, u = !this.validityStyles || this.validity.valid, m = _(s, "k-input k-input-md k-rounded-md k-input-solid"), h = /* @__PURE__ */ r.createElement(
|
|
127
128
|
"input",
|
|
128
129
|
{
|
|
129
|
-
"aria-labelledby":
|
|
130
|
-
"aria-describedby":
|
|
130
|
+
"aria-labelledby": c,
|
|
131
|
+
"aria-describedby": y,
|
|
131
132
|
"aria-disabled": this.props.disabled || void 0,
|
|
132
133
|
"aria-invalid": !u || void 0,
|
|
133
|
-
"aria-label":
|
|
134
|
+
"aria-label": g || void 0,
|
|
134
135
|
...n,
|
|
135
136
|
style: i ? void 0 : o,
|
|
136
137
|
value: this.value,
|
|
137
138
|
id: p,
|
|
138
|
-
|
|
139
|
+
autoFocus: v,
|
|
140
|
+
className: m,
|
|
139
141
|
onChange: this.handleChange,
|
|
140
142
|
onAnimationStart: this.handleAutoFill,
|
|
141
|
-
ref: (
|
|
142
|
-
this._input =
|
|
143
|
+
ref: (f) => {
|
|
144
|
+
this._input = f;
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
);
|
|
146
148
|
return i ? /* @__PURE__ */ r.createElement(
|
|
147
|
-
|
|
149
|
+
L,
|
|
148
150
|
{
|
|
149
151
|
label: i,
|
|
150
|
-
labelClassName:
|
|
152
|
+
labelClassName: a,
|
|
151
153
|
editorId: p,
|
|
152
154
|
editorValue: String(this.value),
|
|
153
155
|
editorValid: u,
|
|
@@ -161,25 +163,27 @@ const e = class e extends r.Component {
|
|
|
161
163
|
}
|
|
162
164
|
};
|
|
163
165
|
e.displayName = "Input", e.propTypes = {
|
|
164
|
-
label:
|
|
165
|
-
labelClassName:
|
|
166
|
-
validationMessage:
|
|
167
|
-
required:
|
|
168
|
-
validate:
|
|
169
|
-
id:
|
|
170
|
-
ariaLabelledBy:
|
|
171
|
-
ariaDescribedBy:
|
|
172
|
-
ariaLabel:
|
|
166
|
+
label: t.string,
|
|
167
|
+
labelClassName: t.string,
|
|
168
|
+
validationMessage: t.string,
|
|
169
|
+
required: t.bool,
|
|
170
|
+
validate: t.bool,
|
|
171
|
+
id: t.string,
|
|
172
|
+
ariaLabelledBy: t.string,
|
|
173
|
+
ariaDescribedBy: t.string,
|
|
174
|
+
ariaLabel: t.string,
|
|
175
|
+
autoFocus: t.bool
|
|
173
176
|
}, e.defaultProps = {
|
|
174
177
|
defaultValue: "",
|
|
175
178
|
required: !1,
|
|
176
|
-
validityStyles: !0
|
|
179
|
+
validityStyles: !0,
|
|
180
|
+
autoFocus: !1
|
|
177
181
|
};
|
|
178
182
|
let d = e;
|
|
179
|
-
const
|
|
180
|
-
|
|
183
|
+
const k = C(), N = M(S(k, d));
|
|
184
|
+
N.displayName = "KendoReactInput";
|
|
181
185
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
N as Input,
|
|
187
|
+
k as InputPropsContext,
|
|
184
188
|
d as InputWithoutContext
|
|
185
189
|
};
|
|
@@ -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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),e=require("prop-types"),C=require("./masking.service.js"),c=require("./utils.js"),o=require("@progress/kendo-react-common"),_=require("@progress/kendo-react-labels"),S=require("../package-metadata.js");function O(h){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(s,t,i.get?i:{enumerable:!0,get:()=>h[t]})}}return s.default=h,Object.freeze(s)}const u=O(x),l=class l extends u.Component{constructor(s){super(s),this.state={},this._inputId=`k-${this.props.id}`,this._service=new C.MaskingService,this._isPasted=!1,this._selection=[null,null],this._input=null,this.focus=()=>{this._input&&this._input.focus()},this.pasteHandler=t=>{const{selectionStart:i,selectionEnd:r}=t.target;r!==i&&(this._isPasted=!0,this._selection=[i||0,r||0])},this.onChangeHandler=t=>{const i=t.currentTarget,r=i.value,n=this._selection[0]||0,a=this._selection[1]||0;if(!this.props.mask){this._isPasted=!1,this._selection=[null,null],this.triggerOnChange(r,t);return}const p=this.value;let d;if(this._isPasted){this._isPasted=!1;const v=p.length-a,g=r.length-v;d=this._service.maskInRange(r.slice(n,g),p,n,a)}else d=this._service.maskInput(r,p,i.selectionStart||0);this._selection=[d.selection,d.selection],this.triggerOnChange(d.value,t)},this.focusHandler=t=>{this.state.focused||(this.setState({focused:!0}),this.props.onFocus&&this.props.onFocus.call(void 0,{target:this,syntheticEvent:t,nativeEvent:t.nativeEvent}))},this.blurHandler=t=>{this.state.focused&&(this.setState({focused:!1}),this.props.onBlur&&this.props.onBlur.call(void 0,{target:this,syntheticEvent:t,nativeEvent:t.nativeEvent}))},this.setValidity=()=>{this.element&&this.element.setCustomValidity(this.validity.valid?"":this.props.validationMessage||"")},o.validatePackage(S.packageMetadata)}get element(){return this._input}get value(){return this._valueDuringOnChange!==void 0?this._valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value!==void 0?this.state.value:this.props.defaultValue!==void 0?this.props.defaultValue:""}get rawValue(){return this._service.rawValue(this.value)}get validity(){const s=this.value,t=this._service.validationValue(s),i=this.props.validationMessage!==void 0,r=this.props.valid!==void 0?this.props.valid:(!this.required||!!t)&&(!this.props.maskValidation||!this.props.prompt||s.indexOf(this.props.prompt)===-1);return{customError:i,valid:r,valueMissing:!t}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:l.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:l.defaultProps.required}get name(){return this.props.name}componentDidUpdate(s,t){if(this.element&&this.state.focused&&t.focused){let[i,r]=this._selection;const n=s.selection,a=this.props.selection;(!n&&a||n&&a&&(n.start!==a.start||n.end!==a.end))&&(i=a.start,r=a.end),i!==null&&r!==null&&this.element.setSelectionRange(i,r)}c.maskingChanged(s,this.props)&&this.updateService(),this.setValidity()}componentDidMount(){this.updateService(),this.setValidity()}render(){const{size:s=l.defaultProps.size,fillMode:t=l.defaultProps.fillMode,rounded:i=l.defaultProps.rounded,autoFocus:r=l.defaultProps.autoFocus}=this.props,n=this.props.id||this._inputId,a=!this.validityStyles||this.validity.valid,p=this.props.style||{},{prefix:d=l.defaultProps.prefix,suffix:v=l.defaultProps.suffix}=this.props,[g]=o.useCustomComponent(d),[k]=o.useCustomComponent(v),m=u.createElement("span",{dir:this.props.dir,className:o.classNames("k-maskedtextbox k-input",{[`k-input-${o.kendoThemeMaps.sizeMap[s]||s}`]:s,[`k-input-${t}`]:t,[`k-rounded-${o.kendoThemeMaps.roundedMap[i]||i}`]:i,"k-invalid":!a,"k-required":this.required,"k-disabled":this.props.disabled},this.props.className),style:this.props.label?p:{width:this.props.width,...p}},u.createElement(g,null),u.createElement("input",{type:"text",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",autoFocus:r,spellCheck:!1,className:"k-input-inner",value:this.value,id:n,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,"aria-placeholder":this.props.mask,name:this.props.name,tabIndex:o.getTabIndex(this.props.tabIndex,this.props.disabled,!0),accessKey:this.props.accessKey,title:this.props.title,disabled:this.props.disabled||void 0,readOnly:this.props.readonly||void 0,placeholder:this.props.placeholder,ref:P=>this._input=P,onChange:this.onChangeHandler,onPaste:this.pasteHandler,onFocus:this.focusHandler,onBlur:this.blurHandler,onDragStart:c.returnFalse,onDrop:c.returnFalse}),u.createElement(k,null));return this.props.label?u.createElement(_.FloatingLabel,{label:this.props.label,editorId:n,editorValue:this.value,editorValid:a,editorDisabled:this.props.disabled,editorPlaceholder:this.props.placeholder,children:m,style:{width:this.props.width},dir:this.props.dir}):m}triggerOnChange(s,t){if(this.setState({value:s}),this.props.onChange){this._valueDuringOnChange=s;const i={syntheticEvent:t,nativeEvent:t.nativeEvent,selectionStart:this._selection[0],selectionEnd:this._selection[1],target:this,value:this.value};this.props.onChange.call(void 0,i),this._valueDuringOnChange=void 0}}updateService(s){const t=Object.assign({includeLiterals:this.props.includeLiterals,mask:this.props.mask,prompt:this.props.prompt,promptPlaceholder:this.props.promptPlaceholder,rules:this.rules},s);this._service.update(t)}get rules(){return Object.assign({},c.defaultRules,this.props.rules)}};l.displayName="MaskedTextBox",l.propTypes={value:e.string,defaultValue:e.string,placeholder:e.string,title:e.string,dir:e.string,id:e.string,style:e.object,className:e.string,prefix:e.any,suffix:e.any,ariaLabelledBy:e.string,ariaDescribedBy:e.string,width:e.oneOfType([e.string,e.number]),tabIndex:e.number,accessKey:e.string,disabled:e.bool,readonly:e.bool,prompt:e.string,promptPlaceholder:e.string,includeLiterals:e.bool,maskValidation:e.bool,mask:e.string,rules:function(s,t,i){const r=s.rules;return r!==void 0&&!Object.entries(r).some(a=>typeof a!="string"||!(r[a]instanceof RegExp))?new Error("Invalid prop `"+t+"` supplied to `"+i+"`. Validation failed."):null},selection:e.shape({start:e.number.isRequired,end:e.number.isRequired}),name:e.string,label:e.string,validationMessage:e.string,required:e.bool,valid:e.bool,validityStyles:e.bool,onChange:e.func,size:e.oneOf([null,"small","medium","large"]),rounded:e.oneOf([null,"small","medium","large","full"]),fillMode:e.oneOf([null,"solid","flat","outline"]),autoFocus:e.bool},l.defaultProps={prompt:"_",promptPlaceholder:" ",includeLiterals:!1,maskValidation:!0,rules:c.defaultRules,required:!1,validityStyles:!0,prefix:s=>null,suffix:s=>null,size:"medium",rounded:"medium",fillMode:"solid",autoFocus:!1};let f=l;const y=o.createPropsContext(),b=o.withIdHOC(o.withPropsContext(y,f));b.displayName="KendoReactMaskedTextBox";exports.MaskedTextBox=b;exports.MaskedTextBoxPropsContext=y;exports.MaskedTextBoxWithoutContext=f;
|
|
@@ -6,35 +6,35 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
9
|
+
import * as d from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
|
-
import { MaskingService as
|
|
12
|
-
import { defaultRules as v, maskingChanged as
|
|
13
|
-
import { validatePackage as
|
|
14
|
-
import { FloatingLabel as
|
|
15
|
-
import { packageMetadata as
|
|
16
|
-
const l = class l extends
|
|
11
|
+
import { MaskingService as P } from "./masking.service.mjs";
|
|
12
|
+
import { defaultRules as v, maskingChanged as _, returnFalse as m } from "./utils.mjs";
|
|
13
|
+
import { validatePackage as C, useCustomComponent as g, classNames as S, kendoThemeMaps as y, getTabIndex as x, createPropsContext as E, withIdHOC as V, withPropsContext as O } from "@progress/kendo-react-common";
|
|
14
|
+
import { FloatingLabel as M } from "@progress/kendo-react-labels";
|
|
15
|
+
import { packageMetadata as I } from "../package-metadata.mjs";
|
|
16
|
+
const l = class l extends d.Component {
|
|
17
17
|
constructor(s) {
|
|
18
|
-
super(s), this.state = {}, this._inputId = `k-${this.props.id}`, this._service = new
|
|
18
|
+
super(s), this.state = {}, this._inputId = `k-${this.props.id}`, this._service = new P(), this._isPasted = !1, this._selection = [null, null], this._input = null, this.focus = () => {
|
|
19
19
|
this._input && this._input.focus();
|
|
20
20
|
}, this.pasteHandler = (t) => {
|
|
21
|
-
const { selectionStart:
|
|
22
|
-
|
|
21
|
+
const { selectionStart: i, selectionEnd: r } = t.target;
|
|
22
|
+
r !== i && (this._isPasted = !0, this._selection = [i || 0, r || 0]);
|
|
23
23
|
}, this.onChangeHandler = (t) => {
|
|
24
|
-
const
|
|
24
|
+
const i = t.currentTarget, r = i.value, o = this._selection[0] || 0, a = this._selection[1] || 0;
|
|
25
25
|
if (!this.props.mask) {
|
|
26
|
-
this._isPasted = !1, this._selection = [null, null], this.triggerOnChange(
|
|
26
|
+
this._isPasted = !1, this._selection = [null, null], this.triggerOnChange(r, t);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
let
|
|
29
|
+
const p = this.value;
|
|
30
|
+
let n;
|
|
31
31
|
if (this._isPasted) {
|
|
32
32
|
this._isPasted = !1;
|
|
33
|
-
const u =
|
|
34
|
-
|
|
33
|
+
const u = p.length - a, h = r.length - u;
|
|
34
|
+
n = this._service.maskInRange(r.slice(o, h), p, o, a);
|
|
35
35
|
} else
|
|
36
|
-
|
|
37
|
-
this._selection = [
|
|
36
|
+
n = this._service.maskInput(r, p, i.selectionStart || 0);
|
|
37
|
+
this._selection = [n.selection, n.selection], this.triggerOnChange(n.value, t);
|
|
38
38
|
}, this.focusHandler = (t) => {
|
|
39
39
|
this.state.focused || (this.setState({ focused: !0 }), this.props.onFocus && this.props.onFocus.call(void 0, {
|
|
40
40
|
target: this,
|
|
@@ -51,7 +51,7 @@ const l = class l extends p.Component {
|
|
|
51
51
|
this.element && this.element.setCustomValidity(
|
|
52
52
|
this.validity.valid ? "" : this.props.validationMessage || ""
|
|
53
53
|
);
|
|
54
|
-
},
|
|
54
|
+
}, C(I);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Gets the element of the MaskedTextBox.
|
|
@@ -103,10 +103,10 @@ const l = class l extends p.Component {
|
|
|
103
103
|
* Represents the validity state into which the MaskedTextBox is set.
|
|
104
104
|
*/
|
|
105
105
|
get validity() {
|
|
106
|
-
const s = this.value, t = this._service.validationValue(s),
|
|
106
|
+
const s = this.value, t = this._service.validationValue(s), i = this.props.validationMessage !== void 0, r = this.props.valid !== void 0 ? this.props.valid : (!this.required || !!t) && (!this.props.maskValidation || !this.props.prompt || s.indexOf(this.props.prompt) === -1);
|
|
107
107
|
return {
|
|
108
|
-
customError:
|
|
109
|
-
valid:
|
|
108
|
+
customError: i,
|
|
109
|
+
valid: r,
|
|
110
110
|
valueMissing: !t
|
|
111
111
|
};
|
|
112
112
|
}
|
|
@@ -133,11 +133,11 @@ const l = class l extends p.Component {
|
|
|
133
133
|
*/
|
|
134
134
|
componentDidUpdate(s, t) {
|
|
135
135
|
if (this.element && this.state.focused && t.focused) {
|
|
136
|
-
let [
|
|
137
|
-
const
|
|
138
|
-
(!
|
|
136
|
+
let [i, r] = this._selection;
|
|
137
|
+
const o = s.selection, a = this.props.selection;
|
|
138
|
+
(!o && a || o && a && (o.start !== a.start || o.end !== a.end)) && (i = a.start, r = a.end), i !== null && r !== null && this.element.setSelectionRange(i, r);
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
_(s, this.props) && this.updateService(), this.setValidity();
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* @hidden
|
|
@@ -152,51 +152,53 @@ const l = class l extends p.Component {
|
|
|
152
152
|
const {
|
|
153
153
|
size: s = l.defaultProps.size,
|
|
154
154
|
fillMode: t = l.defaultProps.fillMode,
|
|
155
|
-
rounded:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
rounded: i = l.defaultProps.rounded,
|
|
156
|
+
autoFocus: r = l.defaultProps.autoFocus
|
|
157
|
+
} = this.props, o = this.props.id || this._inputId, a = !this.validityStyles || this.validity.valid, p = this.props.style || {}, {
|
|
158
|
+
prefix: n = l.defaultProps.prefix,
|
|
159
|
+
suffix: u = l.defaultProps.suffix
|
|
160
|
+
} = this.props, [h] = g(n), [b] = g(u), f = /* @__PURE__ */ d.createElement(
|
|
160
161
|
"span",
|
|
161
162
|
{
|
|
162
163
|
dir: this.props.dir,
|
|
163
|
-
className:
|
|
164
|
+
className: S(
|
|
164
165
|
"k-maskedtextbox k-input",
|
|
165
166
|
{
|
|
166
167
|
[`k-input-${y.sizeMap[s] || s}`]: s,
|
|
167
168
|
[`k-input-${t}`]: t,
|
|
168
|
-
[`k-rounded-${y.roundedMap[
|
|
169
|
-
"k-invalid": !
|
|
169
|
+
[`k-rounded-${y.roundedMap[i] || i}`]: i,
|
|
170
|
+
"k-invalid": !a,
|
|
170
171
|
"k-required": this.required,
|
|
171
172
|
"k-disabled": this.props.disabled
|
|
172
173
|
},
|
|
173
174
|
this.props.className
|
|
174
175
|
),
|
|
175
|
-
style: this.props.label ?
|
|
176
|
+
style: this.props.label ? p : { width: this.props.width, ...p }
|
|
176
177
|
},
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
/* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ d.createElement(h, null),
|
|
179
|
+
/* @__PURE__ */ d.createElement(
|
|
179
180
|
"input",
|
|
180
181
|
{
|
|
181
182
|
type: "text",
|
|
182
183
|
autoComplete: "off",
|
|
183
184
|
autoCorrect: "off",
|
|
184
185
|
autoCapitalize: "off",
|
|
186
|
+
autoFocus: r,
|
|
185
187
|
spellCheck: !1,
|
|
186
188
|
className: "k-input-inner",
|
|
187
189
|
value: this.value,
|
|
188
|
-
id:
|
|
190
|
+
id: o,
|
|
189
191
|
"aria-labelledby": this.props.ariaLabelledBy,
|
|
190
192
|
"aria-describedby": this.props.ariaDescribedBy,
|
|
191
193
|
"aria-placeholder": this.props.mask,
|
|
192
194
|
name: this.props.name,
|
|
193
|
-
tabIndex:
|
|
195
|
+
tabIndex: x(this.props.tabIndex, this.props.disabled, !0),
|
|
194
196
|
accessKey: this.props.accessKey,
|
|
195
197
|
title: this.props.title,
|
|
196
198
|
disabled: this.props.disabled || void 0,
|
|
197
199
|
readOnly: this.props.readonly || void 0,
|
|
198
200
|
placeholder: this.props.placeholder,
|
|
199
|
-
ref: (
|
|
201
|
+
ref: (k) => this._input = k,
|
|
200
202
|
onChange: this.onChangeHandler,
|
|
201
203
|
onPaste: this.pasteHandler,
|
|
202
204
|
onFocus: this.focusHandler,
|
|
@@ -205,15 +207,15 @@ const l = class l extends p.Component {
|
|
|
205
207
|
onDrop: m
|
|
206
208
|
}
|
|
207
209
|
),
|
|
208
|
-
/* @__PURE__ */
|
|
210
|
+
/* @__PURE__ */ d.createElement(b, null)
|
|
209
211
|
);
|
|
210
|
-
return this.props.label ? /* @__PURE__ */
|
|
211
|
-
|
|
212
|
+
return this.props.label ? /* @__PURE__ */ d.createElement(
|
|
213
|
+
M,
|
|
212
214
|
{
|
|
213
215
|
label: this.props.label,
|
|
214
|
-
editorId:
|
|
216
|
+
editorId: o,
|
|
215
217
|
editorValue: this.value,
|
|
216
|
-
editorValid:
|
|
218
|
+
editorValid: a,
|
|
217
219
|
editorDisabled: this.props.disabled,
|
|
218
220
|
editorPlaceholder: this.props.placeholder,
|
|
219
221
|
children: f,
|
|
@@ -227,7 +229,7 @@ const l = class l extends p.Component {
|
|
|
227
229
|
value: s
|
|
228
230
|
}), this.props.onChange) {
|
|
229
231
|
this._valueDuringOnChange = s;
|
|
230
|
-
const
|
|
232
|
+
const i = {
|
|
231
233
|
syntheticEvent: t,
|
|
232
234
|
nativeEvent: t.nativeEvent,
|
|
233
235
|
selectionStart: this._selection[0],
|
|
@@ -235,7 +237,7 @@ const l = class l extends p.Component {
|
|
|
235
237
|
target: this,
|
|
236
238
|
value: this.value
|
|
237
239
|
};
|
|
238
|
-
this.props.onChange.call(void 0,
|
|
240
|
+
this.props.onChange.call(void 0, i), this._valueDuringOnChange = void 0;
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
243
|
updateService(s) {
|
|
@@ -278,10 +280,10 @@ l.displayName = "MaskedTextBox", l.propTypes = {
|
|
|
278
280
|
includeLiterals: e.bool,
|
|
279
281
|
maskValidation: e.bool,
|
|
280
282
|
mask: e.string,
|
|
281
|
-
rules: function(s, t,
|
|
282
|
-
const
|
|
283
|
-
return
|
|
284
|
-
"Invalid prop `" + t + "` supplied to `" +
|
|
283
|
+
rules: function(s, t, i) {
|
|
284
|
+
const r = s.rules;
|
|
285
|
+
return r !== void 0 && !Object.entries(r).some((a) => typeof a != "string" || !(r[a] instanceof RegExp)) ? new Error(
|
|
286
|
+
"Invalid prop `" + t + "` supplied to `" + i + "`. Validation failed."
|
|
285
287
|
) : null;
|
|
286
288
|
},
|
|
287
289
|
selection: e.shape({
|
|
@@ -297,7 +299,8 @@ l.displayName = "MaskedTextBox", l.propTypes = {
|
|
|
297
299
|
onChange: e.func,
|
|
298
300
|
size: e.oneOf([null, "small", "medium", "large"]),
|
|
299
301
|
rounded: e.oneOf([null, "small", "medium", "large", "full"]),
|
|
300
|
-
fillMode: e.oneOf([null, "solid", "flat", "outline"])
|
|
302
|
+
fillMode: e.oneOf([null, "solid", "flat", "outline"]),
|
|
303
|
+
autoFocus: e.bool
|
|
301
304
|
}, l.defaultProps = {
|
|
302
305
|
prompt: "_",
|
|
303
306
|
promptPlaceholder: " ",
|
|
@@ -310,13 +313,14 @@ l.displayName = "MaskedTextBox", l.propTypes = {
|
|
|
310
313
|
suffix: (s) => null,
|
|
311
314
|
size: "medium",
|
|
312
315
|
rounded: "medium",
|
|
313
|
-
fillMode: "solid"
|
|
316
|
+
fillMode: "solid",
|
|
317
|
+
autoFocus: !1
|
|
314
318
|
};
|
|
315
319
|
let c = l;
|
|
316
|
-
const
|
|
317
|
-
|
|
320
|
+
const q = E(), w = V(O(q, c));
|
|
321
|
+
w.displayName = "KendoReactMaskedTextBox";
|
|
318
322
|
export {
|
|
319
|
-
|
|
320
|
-
|
|
323
|
+
w as MaskedTextBox,
|
|
324
|
+
q as MaskedTextBoxPropsContext,
|
|
321
325
|
c as MaskedTextBoxWithoutContext
|
|
322
326
|
};
|