@progress/kendo-react-inputs 13.4.0-develop.4 → 14.0.0-develop.1

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.
@@ -5,34 +5,41 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as d from "react";
8
+ import * as p from "react";
9
9
  import e from "prop-types";
10
10
  import { MaskingService as E } from "./masking.service.mjs";
11
- import { defaultRules as g, maskingChanged as O, returnFalse as y } from "./utils.mjs";
12
- import { withIdHOC as V, withPropsContext as M, createPropsContext as I, withUnstyledHOC as w, useCustomComponent as b, classNames as _, kendoThemeMaps as k, getTabIndex as D, uMaskedTextBox as H } from "@progress/kendo-react-common";
11
+ import { defaultRules as m, maskingChanged as V, returnFalse as b } from "./utils.mjs";
12
+ import { withIdHOC as O, withPropsContext as M, createPropsContext as I, withUnstyledHOC as w, subscribeToKendoPaste as D, useCustomComponent as y, classNames as _, kendoThemeMaps as P, getTabIndex as H, uMaskedTextBox as T } from "@progress/kendo-react-common";
13
13
  import { FloatingLabel as q } from "@progress/kendo-react-labels";
14
- const l = class l extends d.Component {
14
+ const n = class n extends p.Component {
15
15
  constructor() {
16
16
  super(...arguments), this.state = {}, this._inputId = `k_${this.props.id}`, this._service = new E(), this._isPasted = !1, this._selection = [null, null], this._input = null, this.focus = () => {
17
17
  this._input && this._input.focus();
18
+ }, this.handleKendoPasteValue = (t) => {
19
+ const s = t != null ? String(t) : "", i = {
20
+ target: this._input,
21
+ currentTarget: this._input,
22
+ nativeEvent: new Event("change", { bubbles: !0 })
23
+ };
24
+ this.triggerOnChange(s, i);
18
25
  }, this.pasteHandler = (t) => {
19
- const { selectionStart: i, selectionEnd: s } = t.target;
20
- s !== i && (this._isPasted = !0, this._selection = [i || 0, s || 0]);
26
+ const { selectionStart: s, selectionEnd: i } = t.target;
27
+ i !== s && (this._isPasted = !0, this._selection = [s || 0, i || 0]);
21
28
  }, this.onChangeHandler = (t) => {
22
- const i = t.currentTarget, s = i.value, a = this._selection[0] || 0, o = this._selection[1] || 0;
29
+ const s = t.currentTarget, i = s.value, a = this._selection[0] || 0, l = this._selection[1] || 0;
23
30
  if (!this.props.mask) {
24
- this._isPasted = !1, this._selection = [null, null], this.triggerOnChange(s, t);
31
+ this._isPasted = !1, this._selection = [null, null], this.triggerOnChange(i, t);
25
32
  return;
26
33
  }
27
34
  const r = this.value;
28
- let n;
35
+ let o;
29
36
  if (this._isPasted) {
30
37
  this._isPasted = !1;
31
- const p = r.length - o, u = s.length - p;
32
- n = this._service.maskInRange(s.slice(a, u), r, a, o);
38
+ const d = r.length - l, u = i.length - d;
39
+ o = this._service.maskInRange(i.slice(a, u), r, a, l);
33
40
  } else
34
- n = this._service.maskInput(s, r, i.selectionStart || 0);
35
- this._selection = [n.selection, n.selection], this.triggerOnChange(n.value, t);
41
+ o = this._service.maskInput(i, r, s.selectionStart || 0);
42
+ this._selection = [o.selection, o.selection], this.triggerOnChange(o.value, t);
36
43
  }, this.focusHandler = (t) => {
37
44
  this.state.focused || (this.setState({ focused: !0 }), this.props.onFocus && this.props.onFocus.call(void 0, {
38
45
  target: this,
@@ -90,18 +97,18 @@ const l = class l extends d.Component {
90
97
  * Represents the validity state into which the MaskedTextBox is set.
91
98
  */
92
99
  get validity() {
93
- const t = this.value, i = this._service.validationValue(t), s = this.props.validationMessage !== void 0, a = this.props.valid !== void 0 ? this.props.valid : (!this.required || !!i) && (!this.props.maskValidation || !this.props.prompt || t.indexOf(this.props.prompt) === -1);
100
+ 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);
94
101
  return {
95
- customError: s,
102
+ customError: i,
96
103
  valid: a,
97
- valueMissing: !i
104
+ valueMissing: !s
98
105
  };
99
106
  }
100
107
  /**
101
108
  * @hidden
102
109
  */
103
110
  get validityStyles() {
104
- return this.props.validityStyles !== void 0 ? this.props.validityStyles : l.defaultProps.validityStyles;
111
+ return this.props.validityStyles !== void 0 ? this.props.validityStyles : n.defaultProps.validityStyles;
105
112
  }
106
113
  /**
107
114
  * @hidden
@@ -118,35 +125,49 @@ const l = class l extends d.Component {
118
125
  /**
119
126
  * @hidden
120
127
  */
121
- componentDidUpdate(t, i) {
122
- if (this.element && this.state.focused && i.focused) {
123
- let [s, a] = this._selection;
124
- const o = t.selection, r = this.props.selection;
125
- (!o && r || o && r && (o.start !== r.start || o.end !== r.end)) && (s = r.start, a = r.end), s !== null && a !== null && this.element.setSelectionRange(s, a);
128
+ componentDidUpdate(t, s) {
129
+ if (this.element && this.state.focused && s.focused) {
130
+ let [i, a] = this._selection;
131
+ const l = t.selection, r = this.props.selection;
132
+ (!l && r || l && r && (l.start !== r.start || l.end !== r.end)) && (i = r.start, a = r.end), i !== null && a !== null && this.element.setSelectionRange(i, a);
126
133
  }
127
- O(t, this.props) && this.updateService(), this.setValidity();
134
+ V(t, this.props) && this.updateService(), this.setValidity();
128
135
  }
129
136
  /**
130
137
  * @hidden
131
138
  */
132
139
  componentDidMount() {
133
140
  this.updateService(), this.setValidity();
141
+ const t = this.props.name || this.props.id;
142
+ this.KendoPasteSubscription = D(this._input, {
143
+ fieldName: t,
144
+ onValueChange: (s) => {
145
+ this.handleKendoPasteValue(s);
146
+ }
147
+ });
148
+ }
149
+ /**
150
+ * @hidden
151
+ */
152
+ componentWillUnmount() {
153
+ var t;
154
+ (t = this.KendoPasteSubscription) == null || t.unsubscribe();
134
155
  }
135
156
  /**
136
157
  * @hidden
137
158
  */
138
159
  render() {
139
160
  const {
140
- size: t = l.defaultProps.size,
141
- fillMode: i = l.defaultProps.fillMode,
142
- rounded: s = l.defaultProps.rounded,
143
- autoFocus: a = l.defaultProps.autoFocus,
144
- prefix: o = l.defaultProps.prefix,
145
- suffix: r = l.defaultProps.suffix,
146
- inputAttributes: n,
147
- unstyled: p,
161
+ size: t = n.defaultProps.size,
162
+ fillMode: s = n.defaultProps.fillMode,
163
+ rounded: i = n.defaultProps.rounded,
164
+ autoFocus: a = n.defaultProps.autoFocus,
165
+ prefix: l = n.defaultProps.prefix,
166
+ suffix: r = n.defaultProps.suffix,
167
+ inputAttributes: o,
168
+ unstyled: d,
148
169
  className: u
149
- } = this.props, c = this.props.id || this._inputId, f = !this.validityStyles || this.validity.valid, v = this.props.style || {}, x = p && p.uMaskedTextBox, [C] = b(o), [P] = b(r), m = /* @__PURE__ */ d.createElement(
170
+ } = this.props, c = this.props.id || this._inputId, f = !this.validityStyles || this.validity.valid, v = this.props.style || {}, k = d && d.uMaskedTextBox, [C] = y(l), [x] = y(r), g = /* @__PURE__ */ p.createElement(
150
171
  "span",
151
172
  {
152
173
  dir: this.props.dir,
@@ -154,9 +175,9 @@ const l = class l extends d.Component {
154
175
  "k-input",
155
176
  "k-maskedtextbox",
156
177
  {
157
- [`k-input-${k.sizeMap[t] || t}`]: t,
158
- [`k-input-${i}`]: i,
159
- [`k-rounded-${k.roundedMap[s] || s}`]: s,
178
+ [`k-input-${P.sizeMap[t] || t}`]: t,
179
+ [`k-input-${s}`]: s,
180
+ [`k-rounded-${P.roundedMap[i] || i}`]: i,
160
181
  "k-invalid": !f,
161
182
  "k-disabled": this.props.disabled
162
183
  },
@@ -164,8 +185,8 @@ const l = class l extends d.Component {
164
185
  ),
165
186
  style: this.props.label ? v : { width: this.props.width, ...v }
166
187
  },
167
- /* @__PURE__ */ d.createElement(C, null),
168
- /* @__PURE__ */ d.createElement(
188
+ /* @__PURE__ */ p.createElement(C, null),
189
+ /* @__PURE__ */ p.createElement(
169
190
  "input",
170
191
  {
171
192
  type: "text",
@@ -174,7 +195,7 @@ const l = class l extends d.Component {
174
195
  autoCapitalize: "off",
175
196
  autoFocus: a,
176
197
  spellCheck: !1,
177
- className: _(H.inputInner({ c: x })),
198
+ className: _(T.inputInner({ c: k })),
178
199
  value: this.value,
179
200
  id: c,
180
201
  "aria-labelledby": this.props.ariaLabelledBy,
@@ -182,7 +203,7 @@ const l = class l extends d.Component {
182
203
  "aria-placeholder": this.props.mask,
183
204
  "aria-required": this.props.required,
184
205
  name: this.props.name,
185
- tabIndex: D(this.props.tabIndex, this.props.disabled, !0),
206
+ tabIndex: H(this.props.tabIndex, this.props.disabled, !0),
186
207
  accessKey: this.props.accessKey,
187
208
  title: this.props.title,
188
209
  disabled: this.props.disabled || void 0,
@@ -195,14 +216,14 @@ const l = class l extends d.Component {
195
216
  onPaste: this.pasteHandler,
196
217
  onFocus: this.focusHandler,
197
218
  onBlur: this.blurHandler,
198
- onDragStart: y,
199
- onDrop: y,
200
- ...n
219
+ onDragStart: b,
220
+ onDrop: b,
221
+ ...o
201
222
  }
202
223
  ),
203
- /* @__PURE__ */ d.createElement(P, null)
224
+ /* @__PURE__ */ p.createElement(x, null)
204
225
  );
205
- return this.props.label ? /* @__PURE__ */ d.createElement(
226
+ return this.props.label ? /* @__PURE__ */ p.createElement(
206
227
  q,
207
228
  {
208
229
  label: this.props.label,
@@ -211,30 +232,30 @@ const l = class l extends d.Component {
211
232
  editorValid: f,
212
233
  editorDisabled: this.props.disabled,
213
234
  editorPlaceholder: this.props.placeholder,
214
- children: m,
235
+ children: g,
215
236
  style: { width: this.props.width },
216
237
  dir: this.props.dir
217
238
  }
218
- ) : m;
239
+ ) : g;
219
240
  }
220
- triggerOnChange(t, i) {
241
+ triggerOnChange(t, s) {
221
242
  if (this.setState({
222
243
  value: t
223
244
  }), this.props.onChange) {
224
245
  this._valueDuringOnChange = t;
225
- const s = {
226
- syntheticEvent: i,
227
- nativeEvent: i.nativeEvent,
246
+ const i = {
247
+ syntheticEvent: s,
248
+ nativeEvent: s.nativeEvent,
228
249
  selectionStart: this._selection[0],
229
250
  selectionEnd: this._selection[1],
230
251
  target: this,
231
252
  value: this.value
232
253
  };
233
- this.props.onChange.call(void 0, s), this._valueDuringOnChange = void 0;
254
+ this.props.onChange.call(void 0, i), this._valueDuringOnChange = void 0;
234
255
  }
235
256
  }
236
257
  updateService(t) {
237
- const i = Object.assign(
258
+ const s = Object.assign(
238
259
  {
239
260
  includeLiterals: this.props.includeLiterals,
240
261
  mask: this.props.mask,
@@ -244,13 +265,13 @@ const l = class l extends d.Component {
244
265
  },
245
266
  t
246
267
  );
247
- this._service.update(i);
268
+ this._service.update(s);
248
269
  }
249
270
  get rules() {
250
- return Object.assign({}, g, this.props.rules);
271
+ return Object.assign({}, m, this.props.rules);
251
272
  }
252
273
  };
253
- l.displayName = "MaskedTextBox", l.propTypes = {
274
+ n.displayName = "MaskedTextBox", n.propTypes = {
254
275
  value: e.string,
255
276
  defaultValue: e.string,
256
277
  placeholder: e.string,
@@ -273,10 +294,10 @@ l.displayName = "MaskedTextBox", l.propTypes = {
273
294
  includeLiterals: e.bool,
274
295
  maskValidation: e.bool,
275
296
  mask: e.string,
276
- rules: function(t, i, s) {
297
+ rules: function(t, s, i) {
277
298
  const a = t.rules;
278
299
  return a !== void 0 && !Object.entries(a).some((r) => typeof r != "string" || !(a[r] instanceof RegExp)) ? new Error(
279
- "Invalid prop `" + i + "` supplied to `" + s + "`. Validation failed."
300
+ "Invalid prop `" + s + "` supplied to `" + i + "`. Validation failed."
280
301
  ) : null;
281
302
  },
282
303
  selection: e.shape({
@@ -295,12 +316,12 @@ l.displayName = "MaskedTextBox", l.propTypes = {
295
316
  fillMode: e.oneOf(["solid", "flat", "outline"]),
296
317
  autoFocus: e.bool,
297
318
  inputAttributes: e.object
298
- }, l.defaultProps = {
319
+ }, n.defaultProps = {
299
320
  prompt: "_",
300
321
  promptPlaceholder: " ",
301
322
  includeLiterals: !1,
302
323
  maskValidation: !0,
303
- rules: g,
324
+ rules: m,
304
325
  validityStyles: !0,
305
326
  prefix: (t) => null,
306
327
  suffix: (t) => null,
@@ -309,8 +330,8 @@ l.displayName = "MaskedTextBox", l.propTypes = {
309
330
  fillMode: void 0,
310
331
  autoFocus: !1
311
332
  };
312
- let h = l;
313
- const B = I(), F = V(
333
+ let h = n;
334
+ const B = I(), F = O(
314
335
  M(
315
336
  B,
316
337
  w(h)
@@ -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 we=require("react"),t=require("prop-types"),fe=require("@progress/kendo-react-intl"),i=require("@progress/kendo-react-common"),be=require("@progress/kendo-svg-icons"),Ke=require("@progress/kendo-react-labels"),g=require("../messages/index.js"),u=require("./utils/index.js"),pe=require("@progress/kendo-react-buttons");function $e(m){const L=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const v in m)if(v!=="default"){const R=Object.getOwnPropertyDescriptor(m,v);Object.defineProperty(L,v,R.get?R:{enumerable:!0,get:()=>m[v]})}}return L.default=m,Object.freeze(L)}const n=$e(we),Ue="Please enter a valid value!",ge=i.createPropsContext(),Q=n.forwardRef((m,L)=>{const v=i.usePropsContext(ge,m),{className:R,value:C,defaultValue:ve,format:s,width:X,tabIndex:ye,accessKey:Ve,title:ke,placeholder:Z,min:f,max:b,dir:ee,name:G,label:B,id:Ce,ariaDescribedBy:Se,ariaLabelledBy:Ee,ariaLabel:xe,inputType:Oe,readOnly:y,validationMessage:H,children:he,touched:We,visited:Ye,modified:Je,style:te,inputStyle:Ie,valid:w,step:S=c.step,spinners:Le=c.spinners,disabled:l=c.disabled,required:q=c.required,validityStyles:ne=c.validityStyles,prefix:Pe=c.prefix,suffix:De=c.suffix,onChange:h=c.onChange,onFocus:re=c.onFocus,onBlur:ae=c.onBlur,rangeOnEnter:se=c.rangeOnEnter,size:P=c.size,rounded:K=c.rounded,fillMode:M=c.fillMode,autoFocus:Ne=c.autoFocus,inputAttributes:Re,...ue}=v,Be=i.useId(),oe=Ce||Be,o=fe.useInternationalization(),T=fe.useLocalization(),a=n.useRef(null),F=n.useRef(void 0),[qe,I]=n.useState(!1),d=n.useRef(u.getInitialState()),j=n.useRef(!1),$=n.useRef(void 0),D=n.useRef(ve),N=u.formatValue(d.current.focused&&!l?d.current.currentLooseValue:u.getStateOrPropsValue(C,D.current),s,o);$.current=N;const[Me]=i.useCustomComponent(Pe),[Te]=i.useCustomComponent(De);n.useEffect(()=>{a.current&&a.current.setCustomValidity&&a.current.setCustomValidity(_().valid?"":H||Ue)});const le=n.useCallback(()=>{a.current&&a.current.focus()},[]),z=n.useCallback(()=>F.current!==void 0?F.current:u.getStateOrPropsValue(C,D.current),[C]),ce=n.useCallback(()=>G,[G]),A=n.useCallback(()=>q,[q]),_=n.useCallback(()=>{const r=H!==void 0,e=z(),x=w!==void 0?w:!d.current.valueIsOutOfRange&&(!A()||e!=null);return{customError:r,valid:x,valueMissing:e==null}},[H,w,z,A]),U=n.useCallback(()=>ne,[ne]),ie=n.useCallback(()=>v,[v]),E=n.useCallback(()=>{const r={element:a.current,focus:le};return Object.defineProperty(r,"name",{get:ce}),Object.defineProperty(r,"value",{get:z}),Object.defineProperty(r,"validity",{get:_}),Object.defineProperty(r,"validityStyles",{get:U}),Object.defineProperty(r,"required",{get:A}),Object.defineProperty(r,"props",{get:ie}),r},[ce,z,_,U,A,le,ie]);n.useImperativeHandle(L,E);const V=n.useCallback(()=>({eventValue:u.getStateOrPropsValue(C,D.current),prevLooseValue:$.current,currentLooseValue:a.current.value,selectionStart:a.current.selectionStart,selectionEnd:a.current.selectionEnd,decimalSelect:!1,valueIsCorrected:!1,valueIsOutOfRange:!1,isPaste:j.current,focused:d.current.focused}),[C]),k=n.useCallback((r,e)=>{if(l)return;F.current=e.eventValue,D.current=e.eventValue;const x=u.formatValue(u.rangeValue(e.eventValue,f,b),s,o),p=u.rangeValue(o.parseNumber(x,s),f,b);p!==e.eventValue&&(e.valueIsOutOfRange=!0,e.eventValue=p,D.current=p),C!==e.eventValue&&i.dispatchEvent(h,r,E(),{value:e.eventValue}),F.current=void 0,d.current=e,I(J=>!J)},[C,h,l,I,E]),Fe=n.useCallback(r=>{const e=V();j.current=!1,k(r,u.sanitizeNumber(e,s,o))},[s,h,o,k,V]),je=n.useCallback(r=>{if(y||l)return;let e=V();const x=o.parseNumber(String(e.currentLooseValue),s);if(e.selectionEnd>e.selectionStart&&e.selectionEnd-e.selectionStart===String(e.currentLooseValue).length){const p=o.numberSymbols(),O=p&&r.key===p.minusSign,J=p&&r.key===p.decimal;j.current=!O&&!J;return}switch(r.keyCode){case 38:u.increaseValue(x,e,S,f,b,s,o);break;case 40:u.decreaseValue(x,e,S,f,b,s,o);break;case 13:{if(se===!1)return;const p=u.formatValue(u.rangeValue(x,f,b),s,o),O=u.rangeValue(o.parseNumber(p,s),f,b);e.eventValue=O,e.currentLooseValue=u.formatValue(O,s,o),e.selectionStart=e.selectionEnd=e.currentLooseValue.length;break}case 110:{const p=a.current,O=o.numberSymbols();p&&(e.currentLooseValue=e.currentLooseValue.slice(0,e.selectionStart)+O.decimal+e.currentLooseValue.slice(e.selectionEnd),e.selectionStart=e.selectionEnd=e.selectionStart+1,e=u.sanitizeNumber(e,s,o));break}default:return}r.preventDefault(),k(r,e)},[s,f,b,S,h,se,k,V]),ze=n.useCallback(()=>{j.current=!0},[]),W=n.useCallback(r=>{if(y||l)return;const e=V();u.increaseValue(o.parseNumber(String(e.currentLooseValue),s),e,S,f,b,s,o),k(r,e)},[s,f,b,S,h,y,l,k,V]),Y=n.useCallback(r=>{if(y||l)return;const e=V();u.decreaseValue(o.parseNumber(String(e.currentLooseValue),s),e,S,f,b,s,o),k(r,e)},[s,f,b,S,h,y,l,k,V]),Ae=n.useCallback(r=>{const e=i.getActiveElement(document);!document||e!==a.current||!a.current||y||l||(r.nativeEvent.deltaY<0&&W(r),r.nativeEvent.deltaY>0&&Y(r))},[W,Y,l,y]),_e=n.useCallback(r=>{d.current.currentLooseValue=$.current,d.current.focused=!0,i.dispatchEvent(re,r,E(),{}),I(e=>!e)},[re,I,E]),Ge=n.useCallback(r=>{d.current=u.getInitialState(),i.dispatchEvent(ae,r,E(),{}),I(e=>!e)},[ae,I,E]),He=n.useCallback(r=>{if(document&&a.current){const e=i.getActiveElement(document);r.preventDefault(),e!==a.current&&a.current.focus()}},[]);i.useIsomorphicLayoutEffect(()=>{a.current&&a.current.type!=="number"&&d.current.selectionStart!==void 0&&d.current.selectionEnd!==void 0&&(a.current.selectionStart=d.current.selectionStart,a.current.selectionEnd=d.current.selectionEnd,d.current.selectionStart=void 0,d.current.selectionEnd=void 0)},[qe]);const de=!U()||_().valid,me=n.createElement("span",{dir:ee,style:B?te:{width:X,...te},className:i.classNames("k-input","k-numerictextbox",{[`k-input-${i.kendoThemeMaps.sizeMap[P]||P}`]:P,[`k-input-${M}`]:M,[`k-rounded-${i.kendoThemeMaps.roundedMap[K]||K}`]:K,"k-invalid":!de,"k-required":q,"k-disabled":l},R),"aria-disabled":l?"true":void 0,...B?{}:ue},n.createElement(Me,null),n.createElement("input",{role:"spinbutton",value:N===null?"":N,tabIndex:i.getTabIndex(ye,l),accessKey:Ve,disabled:l,title:ke,"aria-disabled":l?"true":void 0,"aria-valuemin":f,"aria-valuemax":b,"aria-label":xe,"aria-labelledby":Ee,"aria-describedby":Se,"aria-required":q,placeholder:Z,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:Ne,type:Oe||"tel",className:"k-input-inner",id:oe,name:G,readOnly:y,style:Ie,onChange:Fe,onFocus:_e,onBlur:Ge,onKeyDown:je,onPaste:ze,onWheel:Ae,ref:a,...Re}),n.createElement(Te,null),he,Le&&n.createElement("span",{className:"k-input-spinner k-spin-button",onMouseDown:He},n.createElement(pe.Button,{tabIndex:-1,type:"button",icon:"caret-alt-up",svgIcon:be.caretAltUpIcon,fillMode:M,size:P,className:"k-spinner-increase","aria-label":T.toLanguageString(g.numericIncreaseValue,g.messages[g.numericIncreaseValue]),title:T.toLanguageString(g.numericIncreaseValue,g.messages[g.numericIncreaseValue]),onClick:W}),n.createElement(pe.Button,{tabIndex:-1,type:"button",icon:"caret-alt-down",svgIcon:be.caretAltDownIcon,fillMode:M,size:P,className:"k-spinner-decrease","aria-label":T.toLanguageString(g.numericDecreaseValue,g.messages[g.numericDecreaseValue]),title:T.toLanguageString(g.numericDecreaseValue,g.messages[g.numericDecreaseValue]),onClick:Y})));return B?n.createElement(Ke.FloatingLabel,{label:B,editorId:oe,editorValue:N===null?"":N,editorValid:de,editorDisabled:l,editorPlaceholder:Z,children:me,style:{width:X},dir:ee,...ue}):me});Q.propTypes={value:t.number,defaultValue:t.number,step:t.number,format:t.oneOfType([t.string,t.shape({style:t.oneOf(["decimal","currency","percent","scientific","accounting"]),currency:t.string,currencyDisplay:t.oneOf(["symbol","code","name"]),useGrouping:t.bool,minimumIntegerDigits:t.number,minimumFractionDigits:t.number,maximumFractionDigits:t.number})]),width:t.oneOfType([t.string,t.number]),tabIndex:t.number,accessKey:t.string,title:t.string,placeholder:t.string,min:t.number,max:t.number,spinners:t.bool,disabled:t.bool,readOnly:t.bool,dir:t.string,name:t.string,label:t.string,validationMessage:t.string,required:t.bool,id:t.string,rangeOnEnter:t.bool,ariaLabelledBy:t.string,ariaDescribedBy:t.string,ariaLabel:t.string,onChange:t.func,onFocus:t.func,onBlur:t.func,size:t.oneOf(["small","medium","large"]),rounded:t.oneOf(["small","medium","large","full","none"]),fillMode:t.oneOf(["solid","flat","outline"]),inputAttributes:t.object};const c={prefix:m=>null,suffix:m=>null,step:1,spinners:!0,disabled:!1,required:!1,validityStyles:!0,rangeOnEnter:!0,autoFocus:!1,onChange:m=>{},onFocus:m=>{},onBlur:m=>{},size:void 0,rounded:void 0,fillMode:void 0};Q.displayName="KendoNumericTextBox";exports.NumericTextBox=Q;exports.NumericTextBoxPropsContext=ge;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=require("react"),t=require("prop-types"),ge=require("@progress/kendo-react-intl"),i=require("@progress/kendo-react-common"),pe=require("@progress/kendo-svg-icons"),Ue=require("@progress/kendo-react-labels"),p=require("../messages/index.js"),u=require("./utils/index.js"),ve=require("@progress/kendo-react-buttons");function We(g){const L=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(g){for(const k in g)if(k!=="default"){const B=Object.getOwnPropertyDescriptor(g,k);Object.defineProperty(L,k,B.get?B:{enumerable:!0,get:()=>g[k]})}}return L.default=g,Object.freeze(L)}const n=We($e),Ye="Please enter a valid value!",Ve=i.createPropsContext(),Q=n.forwardRef((g,L)=>{const k=i.usePropsContext(Ve,g),{className:B,value:E,defaultValue:ye,format:s,width:X,tabIndex:ke,accessKey:Ce,title:Se,placeholder:Z,min:f,max:b,dir:ee,name:q,label:T,id:te,ariaDescribedBy:Ee,ariaLabelledBy:he,ariaLabel:xe,inputType:Oe,readOnly:C,validationMessage:w,children:Ie,touched:Je,visited:Qe,modified:Xe,style:ne,inputStyle:Le,valid:H,step:h=m.step,spinners:Pe=m.spinners,disabled:l=m.disabled,required:F=m.required,validityStyles:re=m.validityStyles,prefix:Ne=m.prefix,suffix:De=m.suffix,onChange:O=m.onChange,onFocus:ae=m.onFocus,onBlur:se=m.onBlur,rangeOnEnter:ue=m.rangeOnEnter,size:P=m.size,rounded:$=m.rounded,fillMode:M=m.fillMode,autoFocus:Re=m.autoFocus,inputAttributes:Be,...oe}=k,qe=i.useId(),le=te||qe,o=ge.useInternationalization(),j=ge.useLocalization(),a=n.useRef(null),z=n.useRef(void 0),[Te,I]=n.useState(!1),d=n.useRef(u.getInitialState()),A=n.useRef(!1),U=n.useRef(void 0),N=n.useRef(ye),ce=q||te,D=u.formatValue(d.current.focused&&!l?d.current.currentLooseValue:u.getStateOrPropsValue(E,N.current),s,o);U.current=D;const[Fe]=i.useCustomComponent(Ne),[Me]=i.useCustomComponent(De);n.useEffect(()=>{a.current&&a.current.setCustomValidity&&a.current.setCustomValidity(K().valid?"":w||Ye)});const ie=n.useCallback(()=>{a.current&&a.current.focus()},[]),_=n.useCallback(()=>z.current!==void 0?z.current:u.getStateOrPropsValue(E,N.current),[E]),de=n.useCallback(()=>q,[q]),G=n.useCallback(()=>F,[F]),K=n.useCallback(()=>{const r=w!==void 0,e=_(),V=H!==void 0?H:!d.current.valueIsOutOfRange&&(!G()||e!=null);return{customError:r,valid:V,valueMissing:e==null}},[w,H,_,G]),W=n.useCallback(()=>re,[re]),me=n.useCallback(()=>k,[k]),x=n.useCallback(()=>{const r={element:a.current,focus:ie};return Object.defineProperty(r,"name",{get:de}),Object.defineProperty(r,"value",{get:_}),Object.defineProperty(r,"validity",{get:K}),Object.defineProperty(r,"validityStyles",{get:W}),Object.defineProperty(r,"required",{get:G}),Object.defineProperty(r,"props",{get:me}),r},[de,_,K,W,G,ie,me]);n.useImperativeHandle(L,x);const S=n.useCallback(()=>({eventValue:u.getStateOrPropsValue(E,N.current),prevLooseValue:U.current,currentLooseValue:a.current.value,selectionStart:a.current.selectionStart,selectionEnd:a.current.selectionEnd,decimalSelect:!1,valueIsCorrected:!1,valueIsOutOfRange:!1,isPaste:A.current,focused:d.current.focused}),[E]),v=n.useCallback((r,e)=>{if(l)return;z.current=e.eventValue,N.current=e.eventValue;const V=u.formatValue(u.rangeValue(e.eventValue,f,b),s,o),c=u.rangeValue(o.parseNumber(V,s),f,b);c!==e.eventValue&&(e.valueIsOutOfRange=!0,e.eventValue=c,N.current=c),E!==e.eventValue&&i.dispatchEvent(O,r,x(),{value:e.eventValue}),z.current=void 0,d.current=e,I(R=>!R)},[E,O,l,I,x]),je=n.useCallback(r=>{const e=Number(r);if(isNaN(e))return;const V=u.rangeValue(e,f,b),c=u.formatValue(V,s,o),y={...d.current,eventValue:V,currentLooseValue:c,selectionStart:c.length,selectionEnd:c.length},R={target:a.current,currentTarget:a.current};v(R,y)},[f,b,s,o,v]);i.useKendoPaste(a,{fieldName:ce,onValueChange:je,enabled:!!ce});const ze=n.useCallback(r=>{const e=S();A.current=!1,v(r,u.sanitizeNumber(e,s,o))},[s,O,o,v,S]),Ae=n.useCallback(r=>{if(C||l)return;let e=S();const V=o.parseNumber(String(e.currentLooseValue),s);if(e.selectionEnd>e.selectionStart&&e.selectionEnd-e.selectionStart===String(e.currentLooseValue).length){const c=o.numberSymbols(),y=c&&r.key===c.minusSign,R=c&&r.key===c.decimal;A.current=!y&&!R;return}switch(r.keyCode){case 38:u.increaseValue(V,e,h,f,b,s,o);break;case 40:u.decreaseValue(V,e,h,f,b,s,o);break;case 13:{if(ue===!1)return;const c=u.formatValue(u.rangeValue(V,f,b),s,o),y=u.rangeValue(o.parseNumber(c,s),f,b);e.eventValue=y,e.currentLooseValue=u.formatValue(y,s,o),e.selectionStart=e.selectionEnd=e.currentLooseValue.length;break}case 110:{const c=a.current,y=o.numberSymbols();c&&(e.currentLooseValue=e.currentLooseValue.slice(0,e.selectionStart)+y.decimal+e.currentLooseValue.slice(e.selectionEnd),e.selectionStart=e.selectionEnd=e.selectionStart+1,e=u.sanitizeNumber(e,s,o));break}default:return}r.preventDefault(),v(r,e)},[s,f,b,h,O,ue,v,S]),_e=n.useCallback(()=>{A.current=!0},[]),Y=n.useCallback(r=>{if(C||l)return;const e=S();u.increaseValue(o.parseNumber(String(e.currentLooseValue),s),e,h,f,b,s,o),v(r,e)},[s,f,b,h,O,C,l,v,S]),J=n.useCallback(r=>{if(C||l)return;const e=S();u.decreaseValue(o.parseNumber(String(e.currentLooseValue),s),e,h,f,b,s,o),v(r,e)},[s,f,b,h,O,C,l,v,S]),Ge=n.useCallback(r=>{const e=i.getActiveElement(document);!document||e!==a.current||!a.current||C||l||(r.nativeEvent.deltaY<0&&Y(r),r.nativeEvent.deltaY>0&&J(r))},[Y,J,l,C]),Ke=n.useCallback(r=>{d.current.currentLooseValue=U.current,d.current.focused=!0,i.dispatchEvent(ae,r,x(),{}),I(e=>!e)},[ae,I,x]),we=n.useCallback(r=>{d.current=u.getInitialState(),i.dispatchEvent(se,r,x(),{}),I(e=>!e)},[se,I,x]),He=n.useCallback(r=>{if(document&&a.current){const e=i.getActiveElement(document);r.preventDefault(),e!==a.current&&a.current.focus()}},[]);i.useIsomorphicLayoutEffect(()=>{a.current&&a.current.type!=="number"&&d.current.selectionStart!==void 0&&d.current.selectionEnd!==void 0&&(a.current.selectionStart=d.current.selectionStart,a.current.selectionEnd=d.current.selectionEnd,d.current.selectionStart=void 0,d.current.selectionEnd=void 0)},[Te]);const fe=!W()||K().valid,be=n.createElement("span",{dir:ee,style:T?ne:{width:X,...ne},className:i.classNames("k-input","k-numerictextbox",{[`k-input-${i.kendoThemeMaps.sizeMap[P]||P}`]:P,[`k-input-${M}`]:M,[`k-rounded-${i.kendoThemeMaps.roundedMap[$]||$}`]:$,"k-invalid":!fe,"k-required":F,"k-disabled":l},B),"aria-disabled":l?"true":void 0,...T?{}:oe},n.createElement(Fe,null),n.createElement("input",{role:"spinbutton",value:D===null?"":D,tabIndex:i.getTabIndex(ke,l),accessKey:Ce,disabled:l,title:Se,"aria-disabled":l?"true":void 0,"aria-valuemin":f,"aria-valuemax":b,"aria-label":xe,"aria-labelledby":he,"aria-describedby":Ee,"aria-required":F,placeholder:Z,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:Re,type:Oe||"tel",className:"k-input-inner",id:le,name:q,readOnly:C,style:Le,onChange:ze,onFocus:Ke,onBlur:we,onKeyDown:Ae,onPaste:_e,onWheel:Ge,ref:a,...Be}),n.createElement(Me,null),Ie,Pe&&n.createElement("span",{className:"k-input-spinner k-spin-button",onMouseDown:He},n.createElement(ve.Button,{tabIndex:-1,type:"button",icon:"caret-alt-up",svgIcon:pe.caretAltUpIcon,fillMode:M,size:P,className:"k-spinner-increase","aria-label":j.toLanguageString(p.numericIncreaseValue,p.messages[p.numericIncreaseValue]),title:j.toLanguageString(p.numericIncreaseValue,p.messages[p.numericIncreaseValue]),onClick:Y}),n.createElement(ve.Button,{tabIndex:-1,type:"button",icon:"caret-alt-down",svgIcon:pe.caretAltDownIcon,fillMode:M,size:P,className:"k-spinner-decrease","aria-label":j.toLanguageString(p.numericDecreaseValue,p.messages[p.numericDecreaseValue]),title:j.toLanguageString(p.numericDecreaseValue,p.messages[p.numericDecreaseValue]),onClick:J})));return T?n.createElement(Ue.FloatingLabel,{label:T,editorId:le,editorValue:D===null?"":D,editorValid:fe,editorDisabled:l,editorPlaceholder:Z,children:be,style:{width:X},dir:ee,...oe}):be});Q.propTypes={value:t.number,defaultValue:t.number,step:t.number,format:t.oneOfType([t.string,t.shape({style:t.oneOf(["decimal","currency","percent","scientific","accounting"]),currency:t.string,currencyDisplay:t.oneOf(["symbol","code","name"]),useGrouping:t.bool,minimumIntegerDigits:t.number,minimumFractionDigits:t.number,maximumFractionDigits:t.number})]),width:t.oneOfType([t.string,t.number]),tabIndex:t.number,accessKey:t.string,title:t.string,placeholder:t.string,min:t.number,max:t.number,spinners:t.bool,disabled:t.bool,readOnly:t.bool,dir:t.string,name:t.string,label:t.string,validationMessage:t.string,required:t.bool,id:t.string,rangeOnEnter:t.bool,ariaLabelledBy:t.string,ariaDescribedBy:t.string,ariaLabel:t.string,onChange:t.func,onFocus:t.func,onBlur:t.func,size:t.oneOf(["small","medium","large"]),rounded:t.oneOf(["small","medium","large","full","none"]),fillMode:t.oneOf(["solid","flat","outline"]),inputAttributes:t.object};const m={prefix:g=>null,suffix:g=>null,step:1,spinners:!0,disabled:!1,required:!1,validityStyles:!0,rangeOnEnter:!0,autoFocus:!1,onChange:g=>{},onFocus:g=>{},onBlur:g=>{},size:void 0,rounded:void 0,fillMode:void 0};Q.displayName="KendoNumericTextBox";exports.NumericTextBox=Q;exports.NumericTextBoxPropsContext=Ve;