@ws-ui/formatter 1.6.5 → 1.6.6

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.
package/dist/index.es.js CHANGED
@@ -3,11 +3,11 @@ function wr(t) {
3
3
  }
4
4
  var oa = { exports: {} }, Pr = oa.exports, at;
5
5
  function kr() {
6
- return at || (at = 1, function(t, e) {
6
+ return at || (at = 1, (function(t, e) {
7
7
  (function(r, a) {
8
8
  t.exports = a();
9
- })(typeof self < "u" ? self : Pr, function() {
10
- return function() {
9
+ })(typeof self < "u" ? self : Pr, (function() {
10
+ return (function() {
11
11
  var r = { d: function(m, u) {
12
12
  for (var l in u) r.o(u, l) && !r.o(m, l) && Object.defineProperty(m, l, { enumerable: !0, get: u[l] });
13
13
  }, o: function(m, u) {
@@ -86,7 +86,7 @@ function kr() {
86
86
  const ye = {};
87
87
  function we(m) {
88
88
  if (!(m in ye)) {
89
- const u = [], l = m.replace(/^[#,]+/, "").replace(/[1-9]\d*/g, (v) => "?".repeat(v.length));
89
+ const u = [], l = m.replace(/^[#,]+/, "").replace(/[1-9]\d*/g, ((v) => "?".repeat(v.length)));
90
90
  for (let v = 0; v < l.length; v++) {
91
91
  const g = l.charAt(v);
92
92
  u[v] = g in Y ? Y[g] : g;
@@ -179,10 +179,10 @@ function kr() {
179
179
  le(p.replace(/[,]/g, ""), l, "int"), le(l.frac_pattern.join(""), l, "frac"), le(l.man_pattern.join(""), l, "man");
180
180
  let z = l.num_pattern.join(""), V = l.den_pattern.join("");
181
181
  const C = /\?/.test(V) || /\?/.test(z);
182
- return V = V.replace(/\d/g, C ? "?" : "#"), C && (V = V.replace(/#$/g, "?")), le(z, l, "num"), le(V, l, "den"), C && (z = z.replace(/#$/g, "?")), l.int_padding = we(l.int_pattern.join("")), l.man_padding = we(l.man_pattern.join("")), l.num_padding = we(z), l.den_padding = we(V), l.den_pattern.length && (l.denominator = parseInt(l.den_pattern.join("").replace(/\D/g, ""), 10)), l.integer = !!l.int_pattern.join("").length, l.fractions && u.forEach((b, W) => {
182
+ return V = V.replace(/\d/g, C ? "?" : "#"), C && (V = V.replace(/#$/g, "?")), le(z, l, "num"), le(V, l, "den"), C && (z = z.replace(/#$/g, "?")), l.int_padding = we(l.int_pattern.join("")), l.man_padding = we(l.man_pattern.join("")), l.num_padding = we(z), l.den_padding = we(V), l.den_pattern.length && (l.denominator = parseInt(l.den_pattern.join("").replace(/\D/g, ""), 10)), l.integer = !!l.int_pattern.join("").length, l.fractions && u.forEach(((b, W) => {
183
183
  const S = u[W + 1];
184
184
  b.type === "string" && S && (S.type === "num" ? b.rule = "num+int" : S.type === "div" ? b.rule = "num" : S.type === "den" && (b.rule = "den"));
185
- }), l;
185
+ })), l;
186
186
  }
187
187
  const Le = (m) => {
188
188
  const u = m.condition;
@@ -317,7 +317,7 @@ function kr() {
317
317
  const w = Math.abs(l);
318
318
  let M = w ? Math.floor(Math.log10(w)) : 0, f = M < 0 ? w * 10 ** -M : w / 10 ** M;
319
319
  f === 10 && (f = 1, M++);
320
- const h = function(j) {
320
+ const h = (function(j) {
321
321
  let p = !(arguments.length > 1 && arguments[1] !== void 0) || arguments[1];
322
322
  const z = Math.abs(j);
323
323
  if (!z) return vr;
@@ -337,7 +337,7 @@ function kr() {
337
337
  S = L - b, S < 0 && (S = 0, W = 0);
338
338
  }
339
339
  return { total: V + Math.max(b, 1) + W + S, digits: Math.max(b, 0) + S, sign: V, period: W, int: Math.max(b, 1), frac: S };
340
- }(w), $ = () => {
340
+ })(w), $ = () => {
341
341
  const j = Math.abs(M);
342
342
  let p;
343
343
  p = f === 1 ? f : A(f, 5), m.push(Ie(p + "", v), v.exponent, M < 0 ? v.negative : v.positive, j < 10 ? "0" : "", j);
@@ -364,11 +364,11 @@ function kr() {
364
364
  function Qa(m, u, l, v) {
365
365
  let g = "", w = "", M = "", f = "", h = "", $ = 0, j = 0 | m, p = 0, z = 0, V = 1, C = 0, b = 0, W = 0, S = 0, X = 0, L = 0;
366
366
  const O = v || N;
367
- if (!u.text && isFinite(u.scale) && u.scale !== 1 && (m = function(_) {
367
+ if (!u.text && isFinite(u.scale) && u.scale !== 1 && (m = (function(_) {
368
368
  if (_ === 0) return _;
369
369
  const R = Math.ceil(Math.log10(_ < 0 ? -_ : _)), P = 10 ** (16 - Math.floor(R));
370
370
  return Math.round(_ * P) / P;
371
- }(m * u.scale)), u.exponential) {
371
+ })(m * u.scale)), u.exponential) {
372
372
  let _ = Math.abs(m);
373
373
  if (_) {
374
374
  const R = 10 ** -Ga(_, u.int_max), P = A(_ * R, u.frac_max) / R;
@@ -507,9 +507,9 @@ function kr() {
507
507
  u[l] = u[l] || {}, Me(m.slice(1), u[l]);
508
508
  } else u.$ = !0;
509
509
  }
510
- ["d-F-y", "d-F-Y", "d-M-y", "d-M-Y", "F-d-y", "F-d-Y", "F-j-y", "F-j-Y", "j-F-y", "j-F-Y", "j-M-y", "j-M-Y", "M-d-y", "M-d-Y", "M-j-y", "M-j-Y", "m-d-y", "m-d-Y", "m-j-y", "m-j-Y", "n-d-y", "n-d-Y", "n-j-y", "n-j-Y", "y-F-d", "y-F-j", "y-M-d", "y-M-j", "Y-F-d", "Y-F-j", "Y-M-d", "Y-m-d", "Y-M-j", "Y-m-j", "Y-n-d", "Y-n-j", "j-F", "j-M", "d-F", "d-M", "n-d", "n-j", "n-Y", "m-d", "m-j", "m-Y", "M-Y", "M-y", "F-y", "F-Y", "Y-M", "Y-n", "Y-m", "Y-F", "Y-M"].forEach((m) => {
510
+ ["d-F-y", "d-F-Y", "d-M-y", "d-M-Y", "F-d-y", "F-d-Y", "F-j-y", "F-j-Y", "j-F-y", "j-F-Y", "j-M-y", "j-M-Y", "M-d-y", "M-d-Y", "M-j-y", "M-j-Y", "m-d-y", "m-d-Y", "m-j-y", "m-j-Y", "n-d-y", "n-d-Y", "n-j-y", "n-j-Y", "y-F-d", "y-F-j", "y-M-d", "y-M-j", "Y-F-d", "Y-F-j", "Y-M-d", "Y-m-d", "Y-M-j", "Y-m-j", "Y-n-d", "Y-n-j", "j-F", "j-M", "d-F", "d-M", "n-d", "n-j", "n-Y", "m-d", "m-j", "m-Y", "M-Y", "M-y", "F-y", "F-Y", "Y-M", "Y-n", "Y-m", "Y-F", "Y-M"].forEach(((m) => {
511
511
  Me(m, ge), Me(m + " x", ge), Me(m + " l", ge), Me(m + " l x", ge), Me("l " + m, ge), Me("l " + m + " x", ge), Me(m + " D", ge), Me(m + " D x", ge), Me("D " + m, ge), Me("D " + m + " x", ge);
512
- });
512
+ }));
513
513
  const fr = { jan: 1, feb: 2, mar: 3, apr: 4, may: 5, jun: 6, jul: 7, aug: 8, sep: 9, oct: 10, nov: 11, dec: 12 }, gr = { january: 1, february: 2, march: 3, april: 4, june: 6, july: 7, august: 8, september: 9, october: 10, november: 11, december: 12 }, Mr = { sunday: "l", monday: "l", tuesday: "l", wednesday: "l", thursday: "l", friday: "l", saturday: "l", sun: "D", mon: "D", tue: "D", wed: "D", thu: "D", fri: "D", sat: "D" }, pr = (/* @__PURE__ */ new Date()).getUTCFullYear();
514
514
  function Ba(m) {
515
515
  const u = new RegExp("^([\\s+%" + ce.join("") + "(-]*)(((?:(?:\\d[\\d,]*)(?:\\.\\d*)?|(?:\\.\\d+)))([eE][+-]?\\d+)?)([\\s%" + ce.join("") + ")]*)$").exec(m);
@@ -620,19 +620,19 @@ function kr() {
620
620
  var v;
621
621
  if (l.sep === "." && l.path.length === 3) return null;
622
622
  const g = +((v = l.year) !== null && v !== void 0 ? v : pr);
623
- if (l.day || (l.day = 1), !function(f, h, $) {
623
+ if (l.day || (l.day = 1), !(function(f, h, $) {
624
624
  if ($ < 1 || h < 1 || h > 12) return !1;
625
625
  if (h === 2) {
626
626
  if ($ > (f % 4 == 0 && f % 100 != 0 || f % 400 == 0 || f === 1900 ? 29 : 28)) return !1;
627
627
  } else if ((h === 4 || h === 6 || h === 9 || h === 11) && $ > 30 || (h === 1 || h === 3 || h === 5 || h === 7 || h === 8 || h === 10 || h === 12) && $ > 31) return !1;
628
628
  return !0;
629
- }(g, l.month, l.day)) return null;
629
+ })(g, l.month, l.day)) return null;
630
630
  let w = -1 / 0;
631
631
  if (g < 1900) return null;
632
632
  g <= 1900 && l.month <= 2 ? w = 25568 : g < 1e4 && (w = 25569);
633
633
  const M = Date.UTC(g, l.month - 1, l.day) / 864e5 + w + (l.time || 0);
634
634
  if (M >= 0 && M <= 2958465) {
635
- const f = l._mon[0] === "0" || l.day[0] === "0" || l._mon.length === 2 && l.day.length === 2, h = l.path.replace(/[jdlDnmMFyYx-]/g, ($) => $ === "j" || $ === "d" ? f ? "dd" : "d" : $ === "D" ? "ddd" : $ === "l" ? "dddd" : $ === "n" || $ === "m" ? f ? "mm" : "m" : $ === "M" ? "mmm" : $ === "F" ? "mmmm" : $ === "y" ? "yy" : $ === "x" ? l.tf || "" : $ === "Y" ? "yyyy" : $);
635
+ const f = l._mon[0] === "0" || l.day[0] === "0" || l._mon.length === 2 && l.day.length === 2, h = l.path.replace(/[jdlDnmMFyYx-]/g, (($) => $ === "j" || $ === "d" ? f ? "dd" : "d" : $ === "D" ? "ddd" : $ === "l" ? "dddd" : $ === "n" || $ === "m" ? f ? "mm" : "m" : $ === "M" ? "mmm" : $ === "F" ? "mmmm" : $ === "y" ? "yy" : $ === "x" ? l.tf || "" : $ === "Y" ? "yyyy" : $));
636
636
  return u && u.nativeDate ? { v: Ya(M, u), z: h } : { v: M, z: h };
637
637
  }
638
638
  }
@@ -662,7 +662,7 @@ function kr() {
662
662
  return g && ($.locale = g), $;
663
663
  }, M = (h, $) => {
664
664
  const j = w($);
665
- return function(p, z, V) {
665
+ return (function(p, z, V) {
666
666
  const C = I(V.locale), b = z[3] ? z[3] : Ka;
667
667
  if (typeof p == "boolean" && (p = p ? "TRUE" : "FALSE"), p == null) return "";
668
668
  if (typeof p != "number") return Qa(p, b, V, C);
@@ -672,47 +672,47 @@ function kr() {
672
672
  }
673
673
  const W = Ja(p, z);
674
674
  return W ? Qa(p, W, V, C) : V.overflow;
675
- }(ra(h, j), v, j);
675
+ })(ra(h, j), v, j);
676
676
  };
677
- M.color = (h, $) => function(j, p) {
677
+ M.color = (h, $) => (function(j, p) {
678
678
  if (typeof j != "number" || !isFinite(j)) return (p[3] ? p[3].color : Ka.color) || Ua;
679
679
  const z = Ja(j, p);
680
680
  return z && z.color || Ua;
681
- }(ra(h, w($)), v);
682
- const f = function(h) {
681
+ })(ra(h, w($)), v);
682
+ const f = (function(h) {
683
683
  var $;
684
684
  let j = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
685
- const [p, z] = h, V = p.frac_max, C = { type: "general", isDate: mr(h), isText: lr(h), isPercent: ur(h), maxDecimals: p.general ? 9 : V, scale: ($ = p.scale) !== null && $ !== void 0 ? $ : 1, color: 0, parentheses: 0, grouped: p.grouping ? 1 : 0, _partitions: h }, b = !C.isDate && !C.isText && !p.error && p.tokens.some((O) => O.type === "string" && (j ? O.value === j : ve.test(O.value)));
685
+ const [p, z] = h, V = p.frac_max, C = { type: "general", isDate: mr(h), isText: lr(h), isPercent: ur(h), maxDecimals: p.general ? 9 : V, scale: ($ = p.scale) !== null && $ !== void 0 ? $ : 1, color: 0, parentheses: 0, grouped: p.grouping ? 1 : 0, _partitions: h }, b = !C.isDate && !C.isText && !p.error && p.tokens.some(((O) => O.type === "string" && (j ? O.value === j : ve.test(O.value))));
686
686
  let W = "G", S = V >= 0 ? Math.min(15, V) : "", X = "", L = "";
687
687
  if (z && z.color && (L = "-", C.color = 1), p.parens && (X = "()", C.parentheses = 1), b) W = "C", C.type = "currency";
688
688
  else if (p.error) C.type = "error", C.maxDecimals = 0;
689
689
  else if (C.isDate) {
690
690
  let O = 0, Z = 0, ke = "";
691
- p.tokens.forEach((D) => {
691
+ p.tokens.forEach(((D) => {
692
692
  const he = D.type;
693
693
  /^(b-)?year/.test(he) ? (ke += "Y", Z++) : he.startsWith("month") ? (ke += "M", Z++) : /^(week)?day/.test(he) ? (ke += "D", Z++) : he !== "hour" && he !== "min" && he !== "sec" && he !== "am" || (ke += he[0], O++);
694
- }), C.type = "date", Z && O ? C.type = "datetime" : !Z && O && (C.type = "time");
695
- const Ce = cr.find((D) => ke.startsWith(D[0]));
694
+ })), C.type = "date", Z && O ? C.type = "datetime" : !Z && O && (C.type = "time");
695
+ const Ce = cr.find(((D) => ke.startsWith(D[0])));
696
696
  W = Ce ? "D" : "G", S = Ce ? Ce[1] : "";
697
697
  } else C.isText ? (W = "G", C.type = "text", S = "", C.maxDecimals = 0) : p.general ? (W = "G", C.type = "general", S = "") : p.fractions ? (W = "G", C.type = "fraction", S = "") : p.exponential ? (W = "S", C.type = "scientific") : C.isPercent ? (W = "P", C.type = "percent") : p.grouping ? (W = ",", C.type = "grouped") : (p.int_max || V) && (W = "F", C.type = "number");
698
698
  return C.code = W + S + L + X, C.level = hr[C.type], Object.freeze(C);
699
- }(v, (u || {}).currency) || new SyntaxError();
700
- return M.info = f, M.dateInfo = function(h) {
699
+ })(v, (u || {}).currency) || new SyntaxError();
700
+ return M.info = f, M.dateInfo = (function(h) {
701
701
  const [$] = h;
702
702
  return { year: !!(2 & $.date), month: !!(4 & $.date), day: !!(8 & $.date), hours: !!(16 & $.date), minutes: !!(32 & $.date), seconds: !!(64 & $.date), clockType: $.clock === 12 ? 12 : 24 };
703
- }(v), M.isPercent = () => !!f.isPercent, M.isDate = () => !!f.isDate, M.isText = () => !!f.isText, M.pattern = l, m.error && (M.error = m.error), M.options = w, M.locale = g || u && u.locale || "", Object.freeze(M);
703
+ })(v), M.isPercent = () => !!f.isPercent, M.isDate = () => !!f.isDate, M.isText = () => !!f.isText, M.pattern = l, m.error && (M.error = m.error), M.options = w, M.locale = g || u && u.locale || "", Object.freeze(M);
704
704
  }
705
705
  function q(m, u) {
706
706
  m || (m = "General");
707
707
  let l = null;
708
- return Re[m] ? l = Re[m] : (l = Object.assign({}, ue(), u).throws ? aa(m) : function(v) {
708
+ return Re[m] ? l = Re[m] : (l = Object.assign({}, ue(), u).throws ? aa(m) : (function(v) {
709
709
  try {
710
710
  return aa(v);
711
711
  } catch (g) {
712
712
  const w = { tokens: [{ type: "error" }], error: g.message };
713
713
  return { pattern: v, partitions: [w, w, w, w], error: g.message, locale: null };
714
714
  }
715
- }(m), l.error || (Re[m] = l)), br(l, u);
715
+ })(m), l.error || (Re[m] = l)), br(l, u);
716
716
  }
717
717
  q.isDate = (m) => q(m, { throws: !1 }).isDate(), q.isPercent = (m) => q(m, { throws: !1 }).isPercent(), q.isText = (m) => q(m, { throws: !1 }).isText(), q.getInfo = (m, u) => q(m, { ...u, throws: !1 }).info, q.getDateInfo = (m, u) => q(m, { ...u, throws: !1 }).dateInfo, q.dateToSerial = ra, q.dateFromSerial = Ya, q.options = ue, q.dec2frac = ee, q.round = A, q.codeToLocale = n, q.parseLocale = E, q.getLocale = I, q.addLocale = (m, u) => {
718
718
  const l = E(u);
@@ -727,9 +727,9 @@ function kr() {
727
727
  };
728
728
  var yr = q;
729
729
  return a = a.default;
730
- }();
731
- });
732
- }(oa)), oa.exports;
730
+ })();
731
+ }));
732
+ })(oa)), oa.exports;
733
733
  }
734
734
  var ga, tt;
735
735
  function $r() {
@@ -2196,7 +2196,7 @@ function st(t, e, r) {
2196
2196
  return ue < 3 ? c.formatDistance("aboutXYears", Y, E) : ue < 9 ? c.formatDistance("overXYears", Y, E) : c.formatDistance("almostXYears", Y + 1, E);
2197
2197
  }
2198
2198
  }
2199
- var ut = 1e3 * 60, la = 60 * 24, mt = la * 30, lt = la * 365;
2199
+ var ut = 1e3 * 60, la = 1440, mt = la * 30, lt = la * 365;
2200
2200
  function ht(t, e, r) {
2201
2201
  var a, n, i;
2202
2202
  J(2, arguments);