UNPKG

@progress/kendo-react-inputs

Version:

React Inputs offer a customizable interface for users to enter and pick different information. KendoReact Input package

79 lines (78 loc) 2.52 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { Result as i, ResultType as u } from "./result.mjs"; import { Stream as p } from "./stream.mjs"; const h = (t) => (t || "").split(""), a = "\\"; class o { constructor(e) { this.parse = e; } run(e, n = "") { return e instanceof p ? this.parse(e) : this.parse(new p(h(e), h(n))); } // map :: Functor f => f a ~> (a -> b) -> f b map(e) { return new o((n) => this.parse(n).map(e)); } // chain :: Chain m => m a ~> (a -> m b) -> m b chain(e) { return new o((n) => this.parse(n).chain((r, c) => e(r).run(c))); } isLiteral(e) { return this.run(e).type === u.Literal; } } const k = (t) => (e) => new o((n) => { const { prompt: r, promptPlaceholder: c } = t; for (; !n.eof(); ) { const { char: w, control: l } = n.peek(); if (w === l && l === r) return n.eat(), new i(r, n, u.Mask); if (e.test(w)) return n.eat(), new i(w, n, u.Mask); if (w === c) return n.eat(), new i(r, n, u.Mask); n.eat_input(); } return n.eat(), new i(r, n, u.Mask); }), x = (t) => new o((e) => e.peek().char === t ? (e.eat(), new i(t, e, u.Literal)) : new i(t, e, u.Literal)), L = (t) => (e) => new o((n) => { for (; !n.eof(); ) { const { char: r, control: c } = n.peek(); if (r === t && c === t) return n.eat(), new i(r, n); if (e.test(r)) return n.eat(), new i(r, n); n.eat_input(); } return n.eat(), new i("", n); }), M = (t) => new o((e) => { if (e.eof()) return new i("", e); const { char: n } = e.peek(); return n === t && e.eat(), new i(t, e); }), A = (t, e) => new o((n) => { let { char: r } = n.next(); const c = t[r]; return r === a ? (r = n.next().char, new i(e.literal(r), n)) : c ? new i(e.mask(c), n) : new i(e.literal(r), n); }), R = (t) => new o((e) => { const { prompt: n, promptPlaceholder: r } = t, { char: c } = e.next(); return c === n ? new i(r, e) : new i(c, e); }), y = (t) => new o((e) => { const { char: n } = e.next(); return t ? new i(n, e) : new i("", e); }); export { o as Parser, x as literal, k as mask, y as rawLiteral, R as rawMask, A as token, M as unliteral, L as unmask };