@progress/kendo-react-inputs
Version:
React Inputs offer a customizable interface for users to enter and pick different information. KendoReact Input package
9 lines (8 loc) • 2.18 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./result.js"),o=require("./stream.js"),w=r=>(r||"").split(""),a="\\";class s{constructor(t){this.parse=t}run(t,e=""){return t instanceof o.Stream?this.parse(t):this.parse(new o.Stream(w(t),w(e)))}map(t){return new s(e=>this.parse(e).map(t))}chain(t){return new s(e=>this.parse(e).chain((u,l)=>t(u).run(l)))}isLiteral(t){return this.run(t).type===n.ResultType.Literal}}const p=r=>t=>new s(e=>{const{prompt:u,promptPlaceholder:l}=r;for(;!e.eof();){const{char:i,control:c}=e.peek();if(i===c&&c===u)return e.eat(),new n.Result(u,e,n.ResultType.Mask);if(t.test(i))return e.eat(),new n.Result(i,e,n.ResultType.Mask);if(i===l)return e.eat(),new n.Result(u,e,n.ResultType.Mask);e.eat_input()}return e.eat(),new n.Result(u,e,n.ResultType.Mask)}),R=r=>new s(t=>t.peek().char===r?(t.eat(),new n.Result(r,t,n.ResultType.Literal)):new n.Result(r,t,n.ResultType.Literal)),h=r=>t=>new s(e=>{for(;!e.eof();){const{char:u,control:l}=e.peek();if(u===r&&l===r)return e.eat(),new n.Result(u,e);if(t.test(u))return e.eat(),new n.Result(u,e);e.eat_input()}return e.eat(),new n.Result("",e)}),f=r=>new s(t=>{if(t.eof())return new n.Result("",t);const{char:e}=t.peek();return e===r&&t.eat(),new n.Result(r,t)}),k=(r,t)=>new s(e=>{let{char:u}=e.next();const l=r[u];return u===a?(u=e.next().char,new n.Result(t.literal(u),e)):l?new n.Result(t.mask(l),e):new n.Result(t.literal(u),e)}),y=r=>new s(t=>{const{prompt:e,promptPlaceholder:u}=r,{char:l}=t.next();return l===e?new n.Result(u,t):new n.Result(l,t)}),T=r=>new s(t=>{const{char:e}=t.next();return r?new n.Result(e,t):new n.Result("",t)});exports.Parser=s;exports.literal=R;exports.mask=p;exports.rawLiteral=T;exports.rawMask=y;exports.token=k;exports.unliteral=f;exports.unmask=h;