UNPKG

igniteui-react-core

Version:
152 lines (151 loc) 5.24 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { Base, String_$type, typeCast, markType } from "./type"; import { List$1 } from "./List$1"; import { FastReflectionHelper } from "./FastReflectionHelper"; import { FormatSpecifier } from "./FormatSpecifier"; import { NumberFormatSpecifier } from "./NumberFormatSpecifier"; import { DateTimeFormatSpecifier } from "./DateTimeFormatSpecifier"; /** * @hidden */ export let BindingFormatter = /*@__PURE__*/ (() => { class BindingFormatter extends Base { constructor() { super(); this.h = null; this.a = null; this.f = null; this.g = null; this.b = null; this.c = null; } get j() { return this.h; } set j(a) { this.h = a; this.l(); } l() { let a = this.j; if (a == null) { return; } let b = 0; let c = new List$1(String_$type, 0); let d = new List$1(FastReflectionHelper.$, 0); let e = new List$1(String_$type, 0); for (let f = a.indexOf('{', b); f >= b; f = a.indexOf('{', b)) { e.add(a.substr(b, f - b)); let g = a.indexOf('}', f); if (g <= f) { return; } let h = a.substr(f + 1, g - f - 1).trim(); let i = h.indexOf(':'); if (i == -1) { c.add(h); if (h == "0" || h == ".") { d.add(null); } else { d.add(new FastReflectionHelper(false, h)); } } else { let j = h.substr(0, i).trim(); d.add(new FastReflectionHelper(false, j)); c.add(j); if (j == "0" || j == ".") { d.add(null); } else { d.add(new FastReflectionHelper(false, h)); } } b = g + 1; } e.add(a.substr(b)); this.f = e; this.g = d; } get d() { return this.a; } set d(a) { this.a = a; this.k(); } k() { if (this.a == null) { this.b = null; this.c = null; return; } this.b = new Array(this.a.length); this.c = new Array(this.a.length); for (let a = 0; a < this.a.length; a++) { let spec_ = this.a[a]; if ((spec_._implementation)) { spec_ = (spec_._implementation); } let b = this.e(spec_); this.c[a] = b; if (b != 0) { if (typeCast(FormatSpecifier.$, spec_) !== null) { this.b[a] = spec_.toIntl(); } else { this.b[a] = spec_; } } } } e(a) { if (a == null) { return 0; } let v_ = a; if ((v_ instanceof Intl.NumberFormat) || typeCast(NumberFormatSpecifier.$, v_) !== null) { return 1; } if ((v_ instanceof Intl.DateTimeFormat) || typeCast(DateTimeFormatSpecifier.$, v_) !== null) { return 2; } return 0; } i(a) { let b = ""; if (this.f == null) { return b; } for (let c = 0; c < this.f.count; c++) { b += this.f._inner[c]; if (c < this.g.count) { let obj_ = a; let d = this.g._inner[c]; if (d != null) { obj_ = d.getPropertyValue(obj_); } if (this.b != null && c < this.b.length && this.b[c] != null) { let platformSpecifier_ = this.b[c]; let e = this.c[c]; let intlSpecifier_ = platformSpecifier_; b += intlSpecifier_.format(obj_); } else { b += obj_ != null ? obj_.toString() : ""; } } } return b; } } BindingFormatter.$t = /*@__PURE__*/ markType(BindingFormatter, 'BindingFormatter'); return BindingFormatter; })();