@progress/kendo-react-inputs 13.4.0-develop.3 → 13.4.0-develop.5

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/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 strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("react"),a=require("prop-types"),u=require("@progress/kendo-react-common"),W=require("@progress/kendo-react-labels");function X(i){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const o in i)if(o!=="default"){const c=Object.getOwnPropertyDescriptor(i,o);Object.defineProperty(s,o,c.get?c:{enumerable:!0,get:()=>i[o]})}}return s.default=i,Object.freeze(s)}const r=X(Q),m=r.forwardRef((i,s)=>{const c=r.useContext(O).call(void 0,i),[,R]=r.useReducer(t=>t,!0),n=u.applyDefaultProps(c,Y),{className:N,label:p,labelClassName:x,id:E,validationMessage:h,defaultValue:S,valid:C,unstyled:V,visited:Z,touched:$,modified:ee,autoFocus:w,ariaLabelledBy:D,ariaDescribedBy:q,validityStyles:I,style:P,ariaLabel:F,...U}=n,j=u.useUnstyled(),f=V||j;f&&f.uInput;const B=u.useId(),[T,_]=r.useState({value:S}),k=E||B,e=r.useRef(null),d=r.useRef(void 0),y=r.useRef(null),A=()=>{e.current&&e.current.focus()},b=()=>d.current!==void 0?d.current:n.value!==void 0?n.value:T.value,v=()=>{const t={badInput:e.current?e.current.validity.badInput:!1,patternMismatch:e.current?e.current.validity.patternMismatch:!1,rangeOverflow:e.current?e.current.validity.rangeOverflow:!1,rangeUnderflow:e.current?e.current.validity.rangeUnderflow:!1,stepMismatch:e.current?e.current.validity.stepMismatch:!1,tooLong:e.current?e.current.validity.tooLong:!1,typeMismatch:e.current?e.current.validity.typeMismatch:!1,valueMissing:e.current?e.current.validity.valueMissing:!1};return{...t,customError:h!==void 0,valid:C!==void 0?C:e.current?!G(t):!0}};r.useImperativeHandle(y,()=>({element:e.current,props:n,get value(){return b()},name:n.name,get validity(){return v()},focus:A})),r.useImperativeHandle(s,()=>y.current);const G=t=>{let l=!1;for(const M in t)t.hasOwnProperty(M)&&(l=l||!!t[M]);return l},g=!I||v().valid,H=u.classNames("k-input",{"k-invalid":!g,"k-disabled":n.disabled},N),z=()=>{e.current&&e.current.setCustomValidity&&(v().valid||!I?e.current.classList.remove("k-invalid"):e.current.classList.add("k-invalid"),e.current.setCustomValidity(v().valid?"":h||""))},K=t=>{_({value:t.target.value}),d.current=t.target.value,n.onChange&&n.onChange.call(void 0,{syntheticEvent:t,nativeEvent:t.nativeEvent,value:t.target.value,target:y.current}),d.current=void 0},J=t=>{if(t.animationName==="autoFillStart"){const l=t.target.parentNode;l&&l.classList.contains("k-empty")&&l.classList.remove("k-empty")}};r.useEffect(()=>{R()},[]),r.useEffect(()=>{z()});const L=r.createElement("input",{"aria-labelledby":D,"aria-describedby":q,"aria-disabled":n.disabled||void 0,"aria-invalid":!g||void 0,"aria-label":F||void 0,...U,style:p?void 0:P,value:b(),id:k,autoFocus:w,className:H,onChange:K,onAnimationStart:J,ref:e});return p?r.createElement(W.FloatingLabel,{label:p,labelClassName:x,editorId:k,editorValue:String(b()),editorValid:g,editorDisabled:n.disabled,editorPlaceholder:n.placeholder,children:L,style:P,dir:n.dir,unstyled:f}):L}),O=u.createPropsContext(),Y={defaultValue:"",required:!1,validityStyles:!0,autoFocus:!1};m.displayName="KendoReactInput";m.propTypes={label:a.node,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,value:a.oneOfType([a.string,a.number,a.array])};exports.Input=m;exports.InputPropsContext=O;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("react"),r=require("prop-types"),i=require("@progress/kendo-react-common"),Z=require("@progress/kendo-react-labels");function $(l){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const u in l)if(u!=="default"){const c=Object.getOwnPropertyDescriptor(l,u);Object.defineProperty(o,u,c.get?c:{enumerable:!0,get:()=>l[u]})}}return o.default=l,Object.freeze(o)}const a=$(Y),P=a.forwardRef((l,o)=>{const c=a.useContext(R).call(void 0,l),[,S]=a.useReducer(t=>t,!0),n=i.applyDefaultProps(c,ee),{className:V,label:f,labelClassName:x,id:w,validationMessage:I,defaultValue:D,valid:k,unstyled:F,visited:te,touched:ae,modified:re,autoFocus:q,ariaLabelledBy:B,ariaDescribedBy:T,validityStyles:E,style:L,ariaLabel:U,...j}=n,K=i.useUnstyled(),y=F||K;y&&y.uInput;const _=i.useId(),[A,G]=a.useState({value:D}),M=w||_,e=a.useRef(null),d=a.useRef(void 0),g=a.useRef(null),N=n.name||n.id,H=()=>{e.current&&e.current.focus()},m=()=>d.current!==void 0?d.current:n.value!==void 0?n.value:A.value,v=()=>{const t={badInput:e.current?e.current.validity.badInput:!1,patternMismatch:e.current?e.current.validity.patternMismatch:!1,rangeOverflow:e.current?e.current.validity.rangeOverflow:!1,rangeUnderflow:e.current?e.current.validity.rangeUnderflow:!1,stepMismatch:e.current?e.current.validity.stepMismatch:!1,tooLong:e.current?e.current.validity.tooLong:!1,typeMismatch:e.current?e.current.validity.typeMismatch:!1,valueMissing:e.current?e.current.validity.valueMissing:!1};return{...t,customError:I!==void 0,valid:k!==void 0?k:e.current?!z(t):!0}};a.useImperativeHandle(g,()=>({element:e.current,props:n,get value(){return m()},name:n.name,get validity(){return v()},focus:H})),a.useImperativeHandle(o,()=>g.current);const z=t=>{let s=!1;for(const p in t)t.hasOwnProperty(p)&&(s=s||!!t[p]);return s},b=!E||v().valid,J=i.classNames("k-input",{"k-invalid":!b,"k-disabled":n.disabled},V),Q=()=>{e.current&&e.current.setCustomValidity&&(v().valid||!E?e.current.classList.remove("k-invalid"):e.current.classList.add("k-invalid"),e.current.setCustomValidity(v().valid?"":I||""))},{onChange:h}=n,C=a.useCallback(t=>{G({value:t.target.value}),d.current=t.target.value,h&&h({syntheticEvent:t,nativeEvent:t.nativeEvent,value:t.target.value,target:g.current}),d.current=void 0},[h]),W=a.useCallback(t=>{const s=t!=null?String(t):"",p={target:e.current,currentTarget:e.current,nativeEvent:new Event("change")};e.current&&(e.current.value=s),C(p)},[C]);i.useKendoPaste(e,{fieldName:N||"",onValueChange:W,enabled:!!N});const X=t=>{if(t.animationName==="autoFillStart"){const s=t.target.parentNode;s&&s.classList.contains("k-empty")&&s.classList.remove("k-empty")}};a.useEffect(()=>{S()},[]),a.useEffect(()=>{Q()});const O=a.createElement("input",{"aria-labelledby":B,"aria-describedby":T,"aria-disabled":n.disabled||void 0,"aria-invalid":!b||void 0,"aria-label":U||void 0,...j,style:f?void 0:L,value:m(),id:M,autoFocus:q,className:J,onChange:C,onAnimationStart:X,ref:e});return f?a.createElement(Z.FloatingLabel,{label:f,labelClassName:x,editorId:M,editorValue:String(m()),editorValid:b,editorDisabled:n.disabled,editorPlaceholder:n.placeholder,children:O,style:L,dir:n.dir,unstyled:y}):O}),R=i.createPropsContext(),ee={defaultValue:"",required:!1,validityStyles:!0,autoFocus:!1};P.displayName="KendoReactInput";P.propTypes={label:r.node,labelClassName:r.string,validationMessage:r.string,required:r.bool,validate:r.bool,id:r.string,ariaLabelledBy:r.string,ariaDescribedBy:r.string,ariaLabel:r.string,autoFocus:r.bool,value:r.oneOfType([r.string,r.number,r.array])};exports.Input=P;exports.InputPropsContext=R;
package/input/Input.mjs CHANGED
@@ -5,38 +5,38 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as r from "react";
9
- import a from "prop-types";
10
- import { createPropsContext as j, applyDefaultProps as z, useUnstyled as J, useId as Q, classNames as W } from "@progress/kendo-react-common";
11
- import { FloatingLabel as X } from "@progress/kendo-react-labels";
12
- const C = r.forwardRef((I, L) => {
13
- const M = r.useContext(Y).call(void 0, I), [, P] = r.useReducer((t) => t, !0), n = z(M, Z), {
14
- className: k,
15
- label: o,
8
+ import * as a from "react";
9
+ import r from "prop-types";
10
+ import { createPropsContext as Q, applyDefaultProps as W, useUnstyled as X, useId as Y, classNames as Z, useKendoPaste as $ } from "@progress/kendo-react-common";
11
+ import { FloatingLabel as ee } from "@progress/kendo-react-labels";
12
+ const E = a.forwardRef((k, L) => {
13
+ const N = a.useContext(te).call(void 0, k), [, M] = a.useReducer((t) => t, !0), n = W(N, ae), {
14
+ className: V,
15
+ label: u,
16
16
  labelClassName: x,
17
- id: E,
18
- validationMessage: p,
19
- defaultValue: N,
20
- valid: f,
21
- unstyled: R,
17
+ id: R,
18
+ validationMessage: y,
19
+ defaultValue: F,
20
+ valid: g,
21
+ unstyled: w,
22
22
  // Removed to support direct use in Form Field component
23
- visited: ee,
24
- touched: te,
25
- modified: ae,
26
- autoFocus: V,
27
- ariaLabelledBy: w,
28
- ariaDescribedBy: F,
29
- validityStyles: y,
30
- style: m,
31
- ariaLabel: U,
32
- ...B
33
- } = n, D = J(), u = R || D;
34
- u && u.uInput;
35
- const O = Q(), [S, T] = r.useState({
36
- value: N
37
- }), g = E || O, e = r.useRef(null), l = r.useRef(void 0), d = r.useRef(null), q = () => {
23
+ visited: ne,
24
+ touched: le,
25
+ modified: se,
26
+ autoFocus: B,
27
+ ariaLabelledBy: S,
28
+ ariaDescribedBy: U,
29
+ validityStyles: b,
30
+ style: h,
31
+ ariaLabel: D,
32
+ ...O
33
+ } = n, T = X(), c = w || T;
34
+ c && c.uInput;
35
+ const K = Y(), [q, A] = a.useState({
36
+ value: F
37
+ }), C = R || K, e = a.useRef(null), s = a.useRef(void 0), d = a.useRef(null), I = n.name || n.id, G = () => {
38
38
  e.current && e.current.focus();
39
- }, c = () => l.current !== void 0 ? l.current : n.value !== void 0 ? n.value : S.value, s = () => {
39
+ }, v = () => s.current !== void 0 ? s.current : n.value !== void 0 ? n.value : q.value, i = () => {
40
40
  const t = {
41
41
  badInput: e.current ? e.current.validity.badInput : !1,
42
42
  patternMismatch: e.current ? e.current.validity.patternMismatch : !1,
@@ -49,112 +49,131 @@ const C = r.forwardRef((I, L) => {
49
49
  };
50
50
  return {
51
51
  ...t,
52
- customError: p !== void 0,
53
- valid: f !== void 0 ? f : e.current ? !A(t) : !0
52
+ customError: y !== void 0,
53
+ valid: g !== void 0 ? g : e.current ? !H(t) : !0
54
54
  };
55
55
  };
56
- r.useImperativeHandle(d, () => ({
56
+ a.useImperativeHandle(d, () => ({
57
57
  element: e.current,
58
58
  props: n,
59
59
  get value() {
60
- return c();
60
+ return v();
61
61
  },
62
62
  name: n.name,
63
63
  get validity() {
64
- return s();
64
+ return i();
65
65
  },
66
- focus: q
67
- })), r.useImperativeHandle(L, () => d.current);
68
- const A = (t) => {
69
- let i = !1;
70
- for (const h in t)
71
- t.hasOwnProperty(h) && (i = i || !!t[h]);
72
- return i;
73
- }, v = !y || s().valid, G = W(
66
+ focus: G
67
+ })), a.useImperativeHandle(L, () => d.current);
68
+ const H = (t) => {
69
+ let l = !1;
70
+ for (const o in t)
71
+ t.hasOwnProperty(o) && (l = l || !!t[o]);
72
+ return l;
73
+ }, p = !b || i().valid, _ = Z(
74
74
  "k-input",
75
75
  {
76
- "k-invalid": !v,
76
+ "k-invalid": !p,
77
77
  "k-disabled": n.disabled
78
78
  },
79
- k
80
- ), H = () => {
81
- e.current && e.current.setCustomValidity && (s().valid || !y ? e.current.classList.remove("k-invalid") : e.current.classList.add("k-invalid"), e.current.setCustomValidity(s().valid ? "" : p || ""));
82
- }, _ = (t) => {
83
- T({
84
- value: t.target.value
85
- }), l.current = t.target.value, n.onChange && n.onChange.call(void 0, {
86
- syntheticEvent: t,
87
- nativeEvent: t.nativeEvent,
88
- value: t.target.value,
89
- target: d.current
90
- }), l.current = void 0;
91
- }, K = (t) => {
79
+ V
80
+ ), j = () => {
81
+ e.current && e.current.setCustomValidity && (i().valid || !b ? e.current.classList.remove("k-invalid") : e.current.classList.add("k-invalid"), e.current.setCustomValidity(i().valid ? "" : y || ""));
82
+ }, { onChange: f } = n, m = a.useCallback(
83
+ (t) => {
84
+ A({
85
+ value: t.target.value
86
+ }), s.current = t.target.value, f && f({
87
+ syntheticEvent: t,
88
+ nativeEvent: t.nativeEvent,
89
+ value: t.target.value,
90
+ target: d.current
91
+ }), s.current = void 0;
92
+ },
93
+ [f]
94
+ ), z = a.useCallback(
95
+ (t) => {
96
+ const l = t != null ? String(t) : "", o = {
97
+ target: e.current,
98
+ currentTarget: e.current,
99
+ nativeEvent: new Event("change")
100
+ };
101
+ e.current && (e.current.value = l), m(o);
102
+ },
103
+ [m]
104
+ );
105
+ $(e, {
106
+ fieldName: I || "",
107
+ onValueChange: z,
108
+ enabled: !!I
109
+ });
110
+ const J = (t) => {
92
111
  if (t.animationName === "autoFillStart") {
93
- const i = t.target.parentNode;
94
- i && i.classList.contains("k-empty") && i.classList.remove("k-empty");
112
+ const l = t.target.parentNode;
113
+ l && l.classList.contains("k-empty") && l.classList.remove("k-empty");
95
114
  }
96
115
  };
97
- r.useEffect(() => {
98
- P();
99
- }, []), r.useEffect(() => {
100
- H();
116
+ a.useEffect(() => {
117
+ M();
118
+ }, []), a.useEffect(() => {
119
+ j();
101
120
  });
102
- const b = /* @__PURE__ */ r.createElement(
121
+ const P = /* @__PURE__ */ a.createElement(
103
122
  "input",
104
123
  {
105
- "aria-labelledby": w,
106
- "aria-describedby": F,
124
+ "aria-labelledby": S,
125
+ "aria-describedby": U,
107
126
  "aria-disabled": n.disabled || void 0,
108
- "aria-invalid": !v || void 0,
109
- "aria-label": U || void 0,
110
- ...B,
111
- style: o ? void 0 : m,
112
- value: c(),
113
- id: g,
114
- autoFocus: V,
115
- className: G,
116
- onChange: _,
117
- onAnimationStart: K,
127
+ "aria-invalid": !p || void 0,
128
+ "aria-label": D || void 0,
129
+ ...O,
130
+ style: u ? void 0 : h,
131
+ value: v(),
132
+ id: C,
133
+ autoFocus: B,
134
+ className: _,
135
+ onChange: m,
136
+ onAnimationStart: J,
118
137
  ref: e
119
138
  }
120
139
  );
121
- return o ? /* @__PURE__ */ r.createElement(
122
- X,
140
+ return u ? /* @__PURE__ */ a.createElement(
141
+ ee,
123
142
  {
124
- label: o,
143
+ label: u,
125
144
  labelClassName: x,
126
- editorId: g,
127
- editorValue: String(c()),
128
- editorValid: v,
145
+ editorId: C,
146
+ editorValue: String(v()),
147
+ editorValid: p,
129
148
  editorDisabled: n.disabled,
130
149
  editorPlaceholder: n.placeholder,
131
- children: b,
132
- style: m,
150
+ children: P,
151
+ style: h,
133
152
  dir: n.dir,
134
- unstyled: u
153
+ unstyled: c
135
154
  }
136
- ) : b;
137
- }), Y = j(), Z = {
155
+ ) : P;
156
+ }), te = Q(), ae = {
138
157
  defaultValue: "",
139
158
  required: !1,
140
159
  validityStyles: !0,
141
160
  autoFocus: !1
142
161
  };
143
- C.displayName = "KendoReactInput";
144
- C.propTypes = {
145
- label: a.node,
146
- labelClassName: a.string,
147
- validationMessage: a.string,
148
- required: a.bool,
149
- validate: a.bool,
150
- id: a.string,
151
- ariaLabelledBy: a.string,
152
- ariaDescribedBy: a.string,
153
- ariaLabel: a.string,
154
- autoFocus: a.bool,
155
- value: a.oneOfType([a.string, a.number, a.array])
162
+ E.displayName = "KendoReactInput";
163
+ E.propTypes = {
164
+ label: r.node,
165
+ labelClassName: r.string,
166
+ validationMessage: r.string,
167
+ required: r.bool,
168
+ validate: r.bool,
169
+ id: r.string,
170
+ ariaLabelledBy: r.string,
171
+ ariaDescribedBy: r.string,
172
+ ariaLabel: r.string,
173
+ autoFocus: r.bool,
174
+ value: r.oneOfType([r.string, r.number, r.array])
156
175
  };
157
176
  export {
158
- C as Input,
159
- Y as InputPropsContext
177
+ E as Input,
178
+ te as InputPropsContext
160
179
  };
@@ -58,7 +58,7 @@ export declare class MaskedTextBoxWithoutContext extends React.Component<MaskedT
58
58
  validityStyles: PropTypes.Requireable<boolean>;
59
59
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
60
60
  size: PropTypes.Requireable<"small" | "medium" | "large" | undefined>;
61
- rounded: PropTypes.Requireable<"small" | "medium" | "large" | "full" | undefined>;
61
+ rounded: PropTypes.Requireable<"small" | "none" | "medium" | "large" | "full" | undefined>;
62
62
  fillMode: PropTypes.Requireable<"flat" | "solid" | "outline" | undefined>;
63
63
  autoFocus: PropTypes.Requireable<boolean>;
64
64
  inputAttributes: PropTypes.Requireable<object>;
@@ -92,6 +92,7 @@ export declare class MaskedTextBoxWithoutContext extends React.Component<MaskedT
92
92
  private _selection;
93
93
  private _input;
94
94
  private _valueDuringOnChange?;
95
+ private KendoPasteSubscription?;
95
96
  /**
96
97
  * @hidden
97
98
  */
@@ -151,6 +152,11 @@ export declare class MaskedTextBoxWithoutContext extends React.Component<MaskedT
151
152
  * @hidden
152
153
  */
153
154
  componentDidMount(): void;
155
+ /**
156
+ * @hidden
157
+ */
158
+ componentWillUnmount(): void;
159
+ private readonly handleKendoPasteValue;
154
160
  /**
155
161
  * @hidden
156
162
  */
@@ -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 O=require("react"),e=require("prop-types"),M=require("./masking.service.js"),h=require("./utils.js"),n=require("@progress/kendo-react-common"),E=require("@progress/kendo-react-labels");function V(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>u[s]})}}return t.default=u,Object.freeze(t)}const p=V(O),l=class l extends p.Component{constructor(){super(...arguments),this.state={},this._inputId=`k_${this.props.id}`,this._service=new M.MaskingService,this._isPasted=!1,this._selection=[null,null],this._input=null,this.focus=()=>{this._input&&this._input.focus()},this.pasteHandler=t=>{const{selectionStart:s,selectionEnd:i}=t.target;i!==s&&(this._isPasted=!0,this._selection=[s||0,i||0])},this.onChangeHandler=t=>{const s=t.currentTarget,i=s.value,a=this._selection[0]||0,o=this._selection[1]||0;if(!this.props.mask){this._isPasted=!1,this._selection=[null,null],this.triggerOnChange(i,t);return}const r=this.value;let d;if(this._isPasted){this._isPasted=!1;const c=r.length-o,v=i.length-c;d=this._service.maskInRange(i.slice(a,v),r,a,o)}else d=this._service.maskInput(i,r,s.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||"")}}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 t=this.value,s=this._service.validationValue(t),i=this.props.validationMessage!==void 0,a=this.props.valid!==void 0?this.props.valid:(!this.required||!!s)&&(!this.props.maskValidation||!this.props.prompt||t.indexOf(this.props.prompt)===-1);return{customError:i,valid:a,valueMissing:!s}}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:!1}get name(){return this.props.name}componentDidUpdate(t,s){if(this.element&&this.state.focused&&s.focused){let[i,a]=this._selection;const o=t.selection,r=this.props.selection;(!o&&r||o&&r&&(o.start!==r.start||o.end!==r.end))&&(i=r.start,a=r.end),i!==null&&a!==null&&this.element.setSelectionRange(i,a)}h.maskingChanged(t,this.props)&&this.updateService(),this.setValidity()}componentDidMount(){this.updateService(),this.setValidity()}render(){const{size:t=l.defaultProps.size,fillMode:s=l.defaultProps.fillMode,rounded:i=l.defaultProps.rounded,autoFocus:a=l.defaultProps.autoFocus,prefix:o=l.defaultProps.prefix,suffix:r=l.defaultProps.suffix,inputAttributes:d,unstyled:c,className:v}=this.props,g=this.props.id||this._inputId,m=!this.validityStyles||this.validity.valid,b=this.props.style||{},C=c&&c.uMaskedTextBox,[_]=n.useCustomComponent(o),[P]=n.useCustomComponent(r),y=p.createElement("span",{dir:this.props.dir,className:n.classNames("k-input","k-maskedtextbox",{[`k-input-${n.kendoThemeMaps.sizeMap[t]||t}`]:t,[`k-input-${s}`]:s,[`k-rounded-${n.kendoThemeMaps.roundedMap[i]||i}`]:i,"k-invalid":!m,"k-disabled":this.props.disabled},v),style:this.props.label?b:{width:this.props.width,...b}},p.createElement(_,null),p.createElement("input",{type:"text",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",autoFocus:a,spellCheck:!1,className:n.classNames(n.uMaskedTextBox.inputInner({c:C})),value:this.value,id:g,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,"aria-placeholder":this.props.mask,"aria-required":this.props.required,name:this.props.name,tabIndex:n.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:S=>{this._input=S},onChange:this.onChangeHandler,onPaste:this.pasteHandler,onFocus:this.focusHandler,onBlur:this.blurHandler,onDragStart:h.returnFalse,onDrop:h.returnFalse,...d}),p.createElement(P,null));return this.props.label?p.createElement(E.FloatingLabel,{label:this.props.label,editorId:g,editorValue:this.value,editorValid:m,editorDisabled:this.props.disabled,editorPlaceholder:this.props.placeholder,children:y,style:{width:this.props.width},dir:this.props.dir}):y}triggerOnChange(t,s){if(this.setState({value:t}),this.props.onChange){this._valueDuringOnChange=t;const i={syntheticEvent:s,nativeEvent:s.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(t){const s=Object.assign({includeLiterals:this.props.includeLiterals,mask:this.props.mask,prompt:this.props.prompt,promptPlaceholder:this.props.promptPlaceholder,rules:this.rules},t);this._service.update(s)}get rules(){return Object.assign({},h.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(t,s,i){const a=t.rules;return a!==void 0&&!Object.entries(a).some(r=>typeof r!="string"||!(a[r]instanceof RegExp))?new Error("Invalid prop `"+s+"` supplied to `"+i+"`. Validation failed."):null},selection:e.shape({start:e.number.isRequired,end:e.number.isRequired}),name:e.string,label:e.node,validationMessage:e.string,required:e.bool,valid:e.bool,validityStyles:e.bool,onChange:e.func,size:e.oneOf(["small","medium","large"]),rounded:e.oneOf(["small","medium","large","full"]),fillMode:e.oneOf(["solid","flat","outline"]),autoFocus:e.bool,inputAttributes:e.object},l.defaultProps={prompt:"_",promptPlaceholder:" ",includeLiterals:!1,maskValidation:!0,rules:h.defaultRules,validityStyles:!0,prefix:t=>null,suffix:t=>null,size:void 0,rounded:void 0,fillMode:void 0,autoFocus:!1};let f=l;const k=n.createPropsContext(),x=n.withIdHOC(n.withPropsContext(k,n.withUnstyledHOC(f)));x.displayName="KendoReactMaskedTextBox";exports.MaskedTextBox=x;exports.MaskedTextBoxPropsContext=k;exports.MaskedTextBoxWithoutContext=f;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react"),t=require("prop-types"),E=require("./masking.service.js"),h=require("./utils.js"),a=require("@progress/kendo-react-common"),M=require("@progress/kendo-react-labels");function V(p){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const s in p)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(p,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>p[s]})}}return e.default=p,Object.freeze(e)}const u=V(O),o=class o extends u.Component{constructor(){super(...arguments),this.state={},this._inputId=`k_${this.props.id}`,this._service=new E.MaskingService,this._isPasted=!1,this._selection=[null,null],this._input=null,this.focus=()=>{this._input&&this._input.focus()},this.handleKendoPasteValue=e=>{const s=e!=null?String(e):"",i={target:this._input,currentTarget:this._input,nativeEvent:new Event("change",{bubbles:!0})};this.triggerOnChange(s,i)},this.pasteHandler=e=>{const{selectionStart:s,selectionEnd:i}=e.target;i!==s&&(this._isPasted=!0,this._selection=[s||0,i||0])},this.onChangeHandler=e=>{const s=e.currentTarget,i=s.value,r=this._selection[0]||0,l=this._selection[1]||0;if(!this.props.mask){this._isPasted=!1,this._selection=[null,null],this.triggerOnChange(i,e);return}const n=this.value;let d;if(this._isPasted){this._isPasted=!1;const c=n.length-l,v=i.length-c;d=this._service.maskInRange(i.slice(r,v),n,r,l)}else d=this._service.maskInput(i,n,s.selectionStart||0);this._selection=[d.selection,d.selection],this.triggerOnChange(d.value,e)},this.focusHandler=e=>{this.state.focused||(this.setState({focused:!0}),this.props.onFocus&&this.props.onFocus.call(void 0,{target:this,syntheticEvent:e,nativeEvent:e.nativeEvent}))},this.blurHandler=e=>{this.state.focused&&(this.setState({focused:!1}),this.props.onBlur&&this.props.onBlur.call(void 0,{target:this,syntheticEvent:e,nativeEvent:e.nativeEvent}))},this.setValidity=()=>{this.element&&this.element.setCustomValidity(this.validity.valid?"":this.props.validationMessage||"")}}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 e=this.value,s=this._service.validationValue(e),i=this.props.validationMessage!==void 0,r=this.props.valid!==void 0?this.props.valid:(!this.required||!!s)&&(!this.props.maskValidation||!this.props.prompt||e.indexOf(this.props.prompt)===-1);return{customError:i,valid:r,valueMissing:!s}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:o.defaultProps.validityStyles}get required(){return this.props.required!==void 0?this.props.required:!1}get name(){return this.props.name}componentDidUpdate(e,s){if(this.element&&this.state.focused&&s.focused){let[i,r]=this._selection;const l=e.selection,n=this.props.selection;(!l&&n||l&&n&&(l.start!==n.start||l.end!==n.end))&&(i=n.start,r=n.end),i!==null&&r!==null&&this.element.setSelectionRange(i,r)}h.maskingChanged(e,this.props)&&this.updateService(),this.setValidity()}componentDidMount(){this.updateService(),this.setValidity();const e=this.props.name||this.props.id;this.KendoPasteSubscription=a.subscribeToKendoPaste(this._input,{fieldName:e,onValueChange:s=>{this.handleKendoPasteValue(s)}})}componentWillUnmount(){var e;(e=this.KendoPasteSubscription)==null||e.unsubscribe()}render(){const{size:e=o.defaultProps.size,fillMode:s=o.defaultProps.fillMode,rounded:i=o.defaultProps.rounded,autoFocus:r=o.defaultProps.autoFocus,prefix:l=o.defaultProps.prefix,suffix:n=o.defaultProps.suffix,inputAttributes:d,unstyled:c,className:v}=this.props,g=this.props.id||this._inputId,m=!this.validityStyles||this.validity.valid,b=this.props.style||{},x=c&&c.uMaskedTextBox,[_]=a.useCustomComponent(l),[C]=a.useCustomComponent(n),y=u.createElement("span",{dir:this.props.dir,className:a.classNames("k-input","k-maskedtextbox",{[`k-input-${a.kendoThemeMaps.sizeMap[e]||e}`]:e,[`k-input-${s}`]:s,[`k-rounded-${a.kendoThemeMaps.roundedMap[i]||i}`]:i,"k-invalid":!m,"k-disabled":this.props.disabled},v),style:this.props.label?b:{width:this.props.width,...b}},u.createElement(_,null),u.createElement("input",{type:"text",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",autoFocus:r,spellCheck:!1,className:a.classNames(a.uMaskedTextBox.inputInner({c:x})),value:this.value,id:g,"aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,"aria-placeholder":this.props.mask,"aria-required":this.props.required,name:this.props.name,tabIndex:a.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:S=>{this._input=S},onChange:this.onChangeHandler,onPaste:this.pasteHandler,onFocus:this.focusHandler,onBlur:this.blurHandler,onDragStart:h.returnFalse,onDrop:h.returnFalse,...d}),u.createElement(C,null));return this.props.label?u.createElement(M.FloatingLabel,{label:this.props.label,editorId:g,editorValue:this.value,editorValid:m,editorDisabled:this.props.disabled,editorPlaceholder:this.props.placeholder,children:y,style:{width:this.props.width},dir:this.props.dir}):y}triggerOnChange(e,s){if(this.setState({value:e}),this.props.onChange){this._valueDuringOnChange=e;const i={syntheticEvent:s,nativeEvent:s.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(e){const s=Object.assign({includeLiterals:this.props.includeLiterals,mask:this.props.mask,prompt:this.props.prompt,promptPlaceholder:this.props.promptPlaceholder,rules:this.rules},e);this._service.update(s)}get rules(){return Object.assign({},h.defaultRules,this.props.rules)}};o.displayName="MaskedTextBox",o.propTypes={value:t.string,defaultValue:t.string,placeholder:t.string,title:t.string,dir:t.string,id:t.string,style:t.object,className:t.string,prefix:t.any,suffix:t.any,ariaLabelledBy:t.string,ariaDescribedBy:t.string,width:t.oneOfType([t.string,t.number]),tabIndex:t.number,accessKey:t.string,disabled:t.bool,readonly:t.bool,prompt:t.string,promptPlaceholder:t.string,includeLiterals:t.bool,maskValidation:t.bool,mask:t.string,rules:function(e,s,i){const r=e.rules;return r!==void 0&&!Object.entries(r).some(n=>typeof n!="string"||!(r[n]instanceof RegExp))?new Error("Invalid prop `"+s+"` supplied to `"+i+"`. Validation failed."):null},selection:t.shape({start:t.number.isRequired,end:t.number.isRequired}),name:t.string,label:t.node,validationMessage:t.string,required:t.bool,valid:t.bool,validityStyles:t.bool,onChange:t.func,size:t.oneOf(["small","medium","large"]),rounded:t.oneOf(["small","medium","large","full","none"]),fillMode:t.oneOf(["solid","flat","outline"]),autoFocus:t.bool,inputAttributes:t.object},o.defaultProps={prompt:"_",promptPlaceholder:" ",includeLiterals:!1,maskValidation:!0,rules:h.defaultRules,validityStyles:!0,prefix:e=>null,suffix:e=>null,size:void 0,rounded:void 0,fillMode:void 0,autoFocus:!1};let f=o;const k=a.createPropsContext(),P=a.withIdHOC(a.withPropsContext(k,a.withUnstyledHOC(f)));P.displayName="KendoReactMaskedTextBox";exports.MaskedTextBox=P;exports.MaskedTextBoxPropsContext=k;exports.MaskedTextBoxWithoutContext=f;