@progress/kendo-react-inputs 8.2.0-develop.2 → 8.2.0-develop.20

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.
@@ -6,35 +6,35 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as p from "react";
9
+ import * as d from "react";
10
10
  import e from "prop-types";
11
- import { MaskingService as k } from "./masking.service.mjs";
12
- import { defaultRules as v, maskingChanged as P, returnFalse as m } from "./utils.mjs";
13
- import { validatePackage as _, useCustomComponent as g, classNames as C, kendoThemeMaps as y, getTabIndex as S, createPropsContext as x, withIdHOC as E, withPropsContext as V } from "@progress/kendo-react-common";
14
- import { FloatingLabel as O } from "@progress/kendo-react-labels";
15
- import { packageMetadata as M } from "../package-metadata.mjs";
16
- const l = class l extends p.Component {
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 k(), this._isPasted = !1, this._selection = [null, null], this._input = null, this.focus = () => {
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: r, selectionEnd: i } = t.target;
22
- i !== r && (this._isPasted = !0, this._selection = [r || 0, i || 0]);
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 r = t.currentTarget, i = r.value, n = this._selection[0] || 0, a = this._selection[1] || 0;
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(i, t);
26
+ this._isPasted = !1, this._selection = [null, null], this.triggerOnChange(r, t);
27
27
  return;
28
28
  }
29
- const d = this.value;
30
- let o;
29
+ const p = this.value;
30
+ let n;
31
31
  if (this._isPasted) {
32
32
  this._isPasted = !1;
33
- const u = d.length - a, h = i.length - u;
34
- o = this._service.maskInRange(i.slice(n, h), d, n, a);
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
- o = this._service.maskInput(i, d, r.selectionStart || 0);
37
- this._selection = [o.selection, o.selection], this.triggerOnChange(o.value, t);
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
- }, _(M);
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), r = this.props.validationMessage !== void 0, i = this.props.valid !== void 0 ? this.props.valid : (!this.required || !!t) && (!this.props.maskValidation || !this.props.prompt || s.indexOf(this.props.prompt) === -1);
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: r,
109
- valid: i,
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 [r, i] = this._selection;
137
- const n = s.selection, a = this.props.selection;
138
- (!n && a || n && a && (n.start !== a.start || n.end !== a.end)) && (r = a.start, i = a.end), r !== null && i !== null && this.element.setSelectionRange(r, i);
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
- P(s, this.props) && this.updateService(), this.setValidity();
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: r = l.defaultProps.rounded
156
- } = this.props, i = this.props.id || this._inputId, n = !this.validityStyles || this.validity.valid, a = this.props.style || {}, {
157
- prefix: d = l.defaultProps.prefix,
158
- suffix: o = l.defaultProps.suffix
159
- } = this.props, [u] = g(d), [h] = g(o), f = /* @__PURE__ */ p.createElement(
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: C(
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[r] || r}`]: r,
169
- "k-invalid": !n,
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 ? a : { width: this.props.width, ...a }
176
+ style: this.props.label ? p : { width: this.props.width, ...p }
176
177
  },
177
- /* @__PURE__ */ p.createElement(u, null),
178
- /* @__PURE__ */ p.createElement(
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: i,
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: S(this.props.tabIndex, this.props.disabled, !0),
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: (b) => this._input = b,
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__ */ p.createElement(h, null)
210
+ /* @__PURE__ */ d.createElement(b, null)
209
211
  );
210
- return this.props.label ? /* @__PURE__ */ p.createElement(
211
- O,
212
+ return this.props.label ? /* @__PURE__ */ d.createElement(
213
+ M,
212
214
  {
213
215
  label: this.props.label,
214
- editorId: i,
216
+ editorId: o,
215
217
  editorValue: this.value,
216
- editorValid: n,
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 r = {
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, r), this._valueDuringOnChange = 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, r) {
282
- const i = s.rules;
283
- return i !== void 0 && !Object.entries(i).some((a) => typeof a != "string" || !(i[a] instanceof RegExp)) ? new Error(
284
- "Invalid prop `" + t + "` supplied to `" + r + "`. Validation failed."
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 I = x(), q = E(V(I, c));
317
- q.displayName = "KendoReactMaskedTextBox";
320
+ const q = E(), w = V(O(q, c));
321
+ w.displayName = "KendoReactMaskedTextBox";
318
322
  export {
319
- q as MaskedTextBox,
320
- I as MaskedTextBoxPropsContext,
323
+ w as MaskedTextBox,
324
+ q as MaskedTextBoxPropsContext,
321
325
  c as MaskedTextBoxWithoutContext
322
326
  };
@@ -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 Ae=require("react"),t=require("prop-types"),fe=require("@progress/kendo-react-intl"),o=require("@progress/kendo-react-common"),be=require("@progress/kendo-svg-icons"),He=require("@progress/kendo-react-labels"),we=require("../package-metadata.js"),g=require("../messages/index.js"),u=require("./utils/index.js"),pe=require("@progress/kendo-react-buttons");function Ke(m){const L=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const v in m)if(v!=="default"){const N=Object.getOwnPropertyDescriptor(m,v);Object.defineProperty(L,v,N.get?N:{enumerable:!0,get:()=>m[v]})}}return L.default=m,Object.freeze(L)}const n=Ke(Ae),$e="Please enter a valid value!",ge=o.createPropsContext(),Q=n.forwardRef((m,L)=>{o.validatePackage(we.packageMetadata);const v=o.usePropsContext(ge,m),{className:N,value:k,defaultValue:ve,format:s,width:X,tabIndex:ye,accessKey:Ve,title:ke,placeholder:Z,min:f,max:b,dir:ee,name:_,label:R,id:Ce,ariaDescribedBy:Se,ariaLabelledBy:Ee,ariaLabel:xe,inputType:Oe,readOnly:C,validationMessage:G,children:Ie,style:te,inputStyle:he,valid:A,step:S=d.step,spinners:Le=d.spinners,disabled:c=d.disabled,required:H=d.required,validityStyles:ne=d.validityStyles,prefix:Pe=d.prefix,suffix:De=d.suffix,onChange:I=d.onChange,onFocus:re=d.onFocus,onBlur:ae=d.onBlur,rangeOnEnter:se=d.rangeOnEnter,size:w=d.size,rounded:K=d.rounded,fillMode:B=d.fillMode,...ue}=v,Ne=o.useId(),le=Ce||Ne,l=fe.useInternationalization(),M=fe.useLocalization(),a=n.useRef(null),q=n.useRef(),[Re,h]=n.useState(!1),i=n.useRef(u.getInitialState()),T=n.useRef(!1),$=n.useRef(),P=n.useRef(ve),D=u.formatValue(i.current.focused&&!c?i.current.currentLooseValue:u.getStateOrPropsValue(k,P.current),s,l);$.current=D;const[Be]=o.useCustomComponent(Pe),[Me]=o.useCustomComponent(De);n.useEffect(()=>{a.current&&a.current.setCustomValidity&&a.current.setCustomValidity(z().valid?"":G||$e)});const oe=n.useCallback(()=>{a.current&&a.current.focus()},[]),F=n.useCallback(()=>q.current!==void 0?q.current:u.getStateOrPropsValue(k,P.current),[k]),ce=n.useCallback(()=>_,[_]),j=n.useCallback(()=>H,[H]),z=n.useCallback(()=>{const r=G!==void 0,e=F(),x=A!==void 0?A:!i.current.valueIsOutOfRange&&(!j()||e!=null);return{customError:r,valid:x,valueMissing:e==null}},[G,A,F,j]),U=n.useCallback(()=>ne,[ne]),ie=n.useCallback(()=>v,[v]),E=n.useCallback(()=>{const r={element:a.current,focus:oe};return Object.defineProperty(r,"name",{get:ce}),Object.defineProperty(r,"value",{get:F}),Object.defineProperty(r,"validity",{get:z}),Object.defineProperty(r,"validityStyles",{get:U}),Object.defineProperty(r,"required",{get:j}),Object.defineProperty(r,"props",{get:ie}),r},[ce,F,z,U,j,oe,ie]);n.useImperativeHandle(L,E);const y=n.useCallback(()=>({eventValue:u.getStateOrPropsValue(k,P.current),prevLooseValue:$.current,currentLooseValue:a.current.value,selectionStart:a.current.selectionStart,selectionEnd:a.current.selectionEnd,decimalSelect:!1,valueIsCorrected:!1,valueIsOutOfRange:!1,isPaste:T.current,focused:i.current.focused}),[k]),V=n.useCallback((r,e)=>{if(c)return;q.current=e.eventValue,P.current=e.eventValue;const x=u.formatValue(u.rangeValue(e.eventValue,f,b),s,l),p=u.rangeValue(l.parseNumber(x,s),f,b);p!==e.eventValue&&(e.valueIsOutOfRange=!0,e.eventValue=p,P.current=p),k!==e.eventValue&&o.dispatchEvent(I,r,E(),{value:e.eventValue}),q.current=void 0,i.current=e,h(J=>!J)},[k,I,c,h,E]),qe=n.useCallback(r=>{const e=y();T.current=!1,V(r,u.sanitizeNumber(e,s,l))},[s,I,l,V,y]),Te=n.useCallback(r=>{let e=y();const x=l.parseNumber(String(e.currentLooseValue),s);if(e.selectionEnd>e.selectionStart&&e.selectionEnd-e.selectionStart===String(e.currentLooseValue).length){const p=l.numberSymbols(),O=p&&r.key===p.minusSign,J=p&&r.key===p.decimal;T.current=!O&&!J;return}switch(r.keyCode){case 38:u.increaseValue(x,e,S,f,b,s,l);break;case 40:u.decreaseValue(x,e,S,f,b,s,l);break;case 13:{if(se===!1)return;const p=u.formatValue(u.rangeValue(x,f,b),s,l),O=u.rangeValue(l.parseNumber(p,s),f,b);e.eventValue=O,e.currentLooseValue=u.formatValue(O,s,l),e.selectionStart=e.selectionEnd=e.currentLooseValue.length;break}case 110:{const p=a.current,O=l.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,l));break}default:return}r.preventDefault(),V(r,e)},[s,f,b,S,I,se,V,y]),Fe=n.useCallback(()=>{T.current=!0},[]),W=n.useCallback(r=>{if(C||c)return;const e=y();u.increaseValue(l.parseNumber(String(e.currentLooseValue),s),e,S,f,b,s,l),V(r,e)},[s,f,b,S,I,C,c,V,y]),Y=n.useCallback(r=>{if(C||c)return;const e=y();u.decreaseValue(l.parseNumber(String(e.currentLooseValue),s),e,S,f,b,s,l),V(r,e)},[s,f,b,S,I,C,c,V,y]),je=n.useCallback(r=>{const e=o.getActiveElement(document);!document||e!==a.current||!a.current||C||c||(r.nativeEvent.deltaY<0&&W(r),r.nativeEvent.deltaY>0&&Y(r))},[W,Y,c,C]),ze=n.useCallback(r=>{i.current.currentLooseValue=$.current,i.current.focused=!0,o.dispatchEvent(re,r,E(),{}),h(e=>!e)},[re,h,E]),_e=n.useCallback(r=>{i.current=u.getInitialState(),o.dispatchEvent(ae,r,E(),{}),h(e=>!e)},[ae,h,E]),Ge=n.useCallback(r=>{if(document&&a.current){const e=o.getActiveElement(document);r.preventDefault(),e!==a.current&&a.current.focus()}},[]);o.useIsomorphicLayoutEffect(()=>{a.current&&a.current.type!=="number"&&i.current.selectionStart!==void 0&&i.current.selectionEnd!==void 0&&(a.current.selectionStart=i.current.selectionStart,a.current.selectionEnd=i.current.selectionEnd,i.current.selectionStart=void 0,i.current.selectionEnd=void 0)},[Re]);const de=!U()||z().valid,me=n.createElement("span",{dir:ee,style:R?te:{width:X,...te},className:o.classNames("k-input","k-numerictextbox",{[`k-input-${o.kendoThemeMaps.sizeMap[w]||w}`]:w,[`k-input-${B}`]:B,[`k-rounded-${o.kendoThemeMaps.roundedMap[K]||K}`]:K,"k-invalid":!de,"k-required":H,"k-disabled":c},N),"aria-disabled":c?"true":void 0,...R?{}:ue},n.createElement(Be,null),n.createElement("input",{role:"spinbutton",value:D===null?"":D,tabIndex:o.getTabIndex(ye,c),accessKey:Ve,disabled:c,title:ke,"aria-disabled":c?"true":void 0,"aria-valuemin":f,"aria-valuemax":b,"aria-label":xe,"aria-labelledby":Ee,"aria-describedby":Se,placeholder:Z,spellCheck:!1,autoComplete:"off",autoCorrect:"off",type:Oe||"tel",className:"k-input-inner",id:le,name:_,readOnly:C,style:he,onChange:qe,onFocus:ze,onBlur:_e,onKeyDown:Te,onPaste:Fe,onWheel:je,ref:a}),n.createElement(Me,null),Ie,Le&&n.createElement("span",{className:"k-input-spinner k-spin-button",onMouseDown:Ge},n.createElement(pe.Button,{tabIndex:-1,type:"button",icon:"caret-alt-up",svgIcon:be.caretAltUpIcon,rounded:null,fillMode:B,className:"k-spinner-increase","aria-label":M.toLanguageString(g.numericIncreaseValue,g.messages[g.numericIncreaseValue]),title:M.toLanguageString(g.numericIncreaseValue,g.messages[g.numericIncreaseValue]),onClick:W}),n.createElement(pe.Button,{tabIndex:-1,type:"button",icon:"caret-alt-down",svgIcon:be.caretAltDownIcon,rounded:null,fillMode:B,className:"k-spinner-decrease","aria-label":M.toLanguageString(g.numericDecreaseValue,g.messages[g.numericDecreaseValue]),title:M.toLanguageString(g.numericDecreaseValue,g.messages[g.numericDecreaseValue]),onClick:Y})));return R?n.createElement(He.FloatingLabel,{label:R,editorId:le,editorValue:D===null?"":D,editorValid:de,editorDisabled:c,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([null,"small","medium","large"]),rounded:t.oneOf([null,"small","medium","large","full"]),fillMode:t.oneOf([null,"solid","flat","outline"])};const d={prefix:m=>null,suffix:m=>null,step:1,spinners:!0,disabled:!1,required:!1,validityStyles:!0,rangeOnEnter:!0,onChange:m=>{},onFocus:m=>{},onBlur:m=>{},size:"medium",rounded:"medium",fillMode:"solid"};Q.displayName="KendoNumericTextBox";exports.NumericTextBox=Q;exports.NumericTextBoxPropsContext=ge;
8
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const He=require("react"),t=require("prop-types"),fe=require("@progress/kendo-react-intl"),o=require("@progress/kendo-react-common"),be=require("@progress/kendo-svg-icons"),we=require("@progress/kendo-react-labels"),Ke=require("../package-metadata.js"),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 N=Object.getOwnPropertyDescriptor(m,v);Object.defineProperty(L,v,N.get?N:{enumerable:!0,get:()=>m[v]})}}return L.default=m,Object.freeze(L)}const n=$e(He),Ue="Please enter a valid value!",ge=o.createPropsContext(),Q=n.forwardRef((m,L)=>{o.validatePackage(Ke.packageMetadata);const v=o.usePropsContext(ge,m),{className:N,value:k,defaultValue:ve,format:s,width:X,tabIndex:ye,accessKey:Ve,title:ke,placeholder:Z,min:f,max:b,dir:ee,name:_,label:R,id:Ce,ariaDescribedBy:Se,ariaLabelledBy:Ee,ariaLabel:xe,inputType:Oe,readOnly:C,validationMessage:G,children:Ie,style:te,inputStyle:he,valid:A,step:S=i.step,spinners:Le=i.spinners,disabled:c=i.disabled,required:H=i.required,validityStyles:ne=i.validityStyles,prefix:Pe=i.prefix,suffix:De=i.suffix,onChange:I=i.onChange,onFocus:re=i.onFocus,onBlur:ae=i.onBlur,rangeOnEnter:se=i.rangeOnEnter,size:w=i.size,rounded:K=i.rounded,fillMode:B=i.fillMode,autoFocus:Ne=i.autoFocus,...ue}=v,Re=o.useId(),le=Ce||Re,l=fe.useInternationalization(),M=fe.useLocalization(),a=n.useRef(null),q=n.useRef(),[Be,h]=n.useState(!1),d=n.useRef(u.getInitialState()),T=n.useRef(!1),$=n.useRef(),P=n.useRef(ve),D=u.formatValue(d.current.focused&&!c?d.current.currentLooseValue:u.getStateOrPropsValue(k,P.current),s,l);$.current=D;const[Me]=o.useCustomComponent(Pe),[qe]=o.useCustomComponent(De);n.useEffect(()=>{a.current&&a.current.setCustomValidity&&a.current.setCustomValidity(z().valid?"":G||Ue)});const oe=n.useCallback(()=>{a.current&&a.current.focus()},[]),F=n.useCallback(()=>q.current!==void 0?q.current:u.getStateOrPropsValue(k,P.current),[k]),ce=n.useCallback(()=>_,[_]),j=n.useCallback(()=>H,[H]),z=n.useCallback(()=>{const r=G!==void 0,e=F(),x=A!==void 0?A:!d.current.valueIsOutOfRange&&(!j()||e!=null);return{customError:r,valid:x,valueMissing:e==null}},[G,A,F,j]),U=n.useCallback(()=>ne,[ne]),ie=n.useCallback(()=>v,[v]),E=n.useCallback(()=>{const r={element:a.current,focus:oe};return Object.defineProperty(r,"name",{get:ce}),Object.defineProperty(r,"value",{get:F}),Object.defineProperty(r,"validity",{get:z}),Object.defineProperty(r,"validityStyles",{get:U}),Object.defineProperty(r,"required",{get:j}),Object.defineProperty(r,"props",{get:ie}),r},[ce,F,z,U,j,oe,ie]);n.useImperativeHandle(L,E);const y=n.useCallback(()=>({eventValue:u.getStateOrPropsValue(k,P.current),prevLooseValue:$.current,currentLooseValue:a.current.value,selectionStart:a.current.selectionStart,selectionEnd:a.current.selectionEnd,decimalSelect:!1,valueIsCorrected:!1,valueIsOutOfRange:!1,isPaste:T.current,focused:d.current.focused}),[k]),V=n.useCallback((r,e)=>{if(c)return;q.current=e.eventValue,P.current=e.eventValue;const x=u.formatValue(u.rangeValue(e.eventValue,f,b),s,l),p=u.rangeValue(l.parseNumber(x,s),f,b);p!==e.eventValue&&(e.valueIsOutOfRange=!0,e.eventValue=p,P.current=p),k!==e.eventValue&&o.dispatchEvent(I,r,E(),{value:e.eventValue}),q.current=void 0,d.current=e,h(J=>!J)},[k,I,c,h,E]),Te=n.useCallback(r=>{const e=y();T.current=!1,V(r,u.sanitizeNumber(e,s,l))},[s,I,l,V,y]),Fe=n.useCallback(r=>{let e=y();const x=l.parseNumber(String(e.currentLooseValue),s);if(e.selectionEnd>e.selectionStart&&e.selectionEnd-e.selectionStart===String(e.currentLooseValue).length){const p=l.numberSymbols(),O=p&&r.key===p.minusSign,J=p&&r.key===p.decimal;T.current=!O&&!J;return}switch(r.keyCode){case 38:u.increaseValue(x,e,S,f,b,s,l);break;case 40:u.decreaseValue(x,e,S,f,b,s,l);break;case 13:{if(se===!1)return;const p=u.formatValue(u.rangeValue(x,f,b),s,l),O=u.rangeValue(l.parseNumber(p,s),f,b);e.eventValue=O,e.currentLooseValue=u.formatValue(O,s,l),e.selectionStart=e.selectionEnd=e.currentLooseValue.length;break}case 110:{const p=a.current,O=l.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,l));break}default:return}r.preventDefault(),V(r,e)},[s,f,b,S,I,se,V,y]),je=n.useCallback(()=>{T.current=!0},[]),W=n.useCallback(r=>{if(C||c)return;const e=y();u.increaseValue(l.parseNumber(String(e.currentLooseValue),s),e,S,f,b,s,l),V(r,e)},[s,f,b,S,I,C,c,V,y]),Y=n.useCallback(r=>{if(C||c)return;const e=y();u.decreaseValue(l.parseNumber(String(e.currentLooseValue),s),e,S,f,b,s,l),V(r,e)},[s,f,b,S,I,C,c,V,y]),ze=n.useCallback(r=>{const e=o.getActiveElement(document);!document||e!==a.current||!a.current||C||c||(r.nativeEvent.deltaY<0&&W(r),r.nativeEvent.deltaY>0&&Y(r))},[W,Y,c,C]),_e=n.useCallback(r=>{d.current.currentLooseValue=$.current,d.current.focused=!0,o.dispatchEvent(re,r,E(),{}),h(e=>!e)},[re,h,E]),Ge=n.useCallback(r=>{d.current=u.getInitialState(),o.dispatchEvent(ae,r,E(),{}),h(e=>!e)},[ae,h,E]),Ae=n.useCallback(r=>{if(document&&a.current){const e=o.getActiveElement(document);r.preventDefault(),e!==a.current&&a.current.focus()}},[]);o.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)},[Be]);const de=!U()||z().valid,me=n.createElement("span",{dir:ee,style:R?te:{width:X,...te},className:o.classNames("k-input","k-numerictextbox",{[`k-input-${o.kendoThemeMaps.sizeMap[w]||w}`]:w,[`k-input-${B}`]:B,[`k-rounded-${o.kendoThemeMaps.roundedMap[K]||K}`]:K,"k-invalid":!de,"k-required":H,"k-disabled":c},N),"aria-disabled":c?"true":void 0,...R?{}:ue},n.createElement(Me,null),n.createElement("input",{role:"spinbutton",value:D===null?"":D,tabIndex:o.getTabIndex(ye,c),accessKey:Ve,disabled:c,title:ke,"aria-disabled":c?"true":void 0,"aria-valuemin":f,"aria-valuemax":b,"aria-label":xe,"aria-labelledby":Ee,"aria-describedby":Se,placeholder:Z,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoFocus:Ne,type:Oe||"tel",className:"k-input-inner",id:le,name:_,readOnly:C,style:he,onChange:Te,onFocus:_e,onBlur:Ge,onKeyDown:Fe,onPaste:je,onWheel:ze,ref:a}),n.createElement(qe,null),Ie,Le&&n.createElement("span",{className:"k-input-spinner k-spin-button",onMouseDown:Ae},n.createElement(pe.Button,{tabIndex:-1,type:"button",icon:"caret-alt-up",svgIcon:be.caretAltUpIcon,rounded:null,fillMode:B,className:"k-spinner-increase","aria-label":M.toLanguageString(g.numericIncreaseValue,g.messages[g.numericIncreaseValue]),title:M.toLanguageString(g.numericIncreaseValue,g.messages[g.numericIncreaseValue]),onClick:W}),n.createElement(pe.Button,{tabIndex:-1,type:"button",icon:"caret-alt-down",svgIcon:be.caretAltDownIcon,rounded:null,fillMode:B,className:"k-spinner-decrease","aria-label":M.toLanguageString(g.numericDecreaseValue,g.messages[g.numericDecreaseValue]),title:M.toLanguageString(g.numericDecreaseValue,g.messages[g.numericDecreaseValue]),onClick:Y})));return R?n.createElement(we.FloatingLabel,{label:R,editorId:le,editorValue:D===null?"":D,editorValid:de,editorDisabled:c,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([null,"small","medium","large"]),rounded:t.oneOf([null,"small","medium","large","full"]),fillMode:t.oneOf([null,"solid","flat","outline"])};const i={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:"medium",rounded:"medium",fillMode:"solid"};Q.displayName="KendoNumericTextBox";exports.NumericTextBox=Q;exports.NumericTextBoxPropsContext=ge;