@nine-lab/nine-util 0.9.138 → 0.9.141

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/nine-util.js CHANGED
@@ -691,9 +691,300 @@ let ninePromptPopup = _ninePromptPopup;
691
691
  if (!customElements.get("nine-prompt-popup")) {
692
692
  customElements.define("nine-prompt-popup", ninePromptPopup);
693
693
  }
694
+ function getDefaultExportFromCjs(x) {
695
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
696
+ }
697
+ var dayjs_min$1 = { exports: {} };
698
+ var dayjs_min = dayjs_min$1.exports;
699
+ var hasRequiredDayjs_min;
700
+ function requireDayjs_min() {
701
+ if (hasRequiredDayjs_min) return dayjs_min$1.exports;
702
+ hasRequiredDayjs_min = 1;
703
+ (function(module, exports$1) {
704
+ !(function(t, e) {
705
+ module.exports = e();
706
+ })(dayjs_min, (function() {
707
+ var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
708
+ var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
709
+ return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
710
+ } }, m = function(t2, e2, n2) {
711
+ var r2 = String(t2);
712
+ return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
713
+ }, v = { s: m, z: function(t2) {
714
+ var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
715
+ return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
716
+ }, m: function t2(e2, n2) {
717
+ if (e2.date() < n2.date()) return -t2(n2, e2);
718
+ var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
719
+ return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
720
+ }, a: function(t2) {
721
+ return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
722
+ }, p: function(t2) {
723
+ return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
724
+ }, u: function(t2) {
725
+ return void 0 === t2;
726
+ } }, g = "en", D = {};
727
+ D[g] = M;
728
+ var p = "$isDayjsObject", S = function(t2) {
729
+ return t2 instanceof _ || !(!t2 || !t2[p]);
730
+ }, w = function t2(e2, n2, r2) {
731
+ var i2;
732
+ if (!e2) return g;
733
+ if ("string" == typeof e2) {
734
+ var s2 = e2.toLowerCase();
735
+ D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
736
+ var u2 = e2.split("-");
737
+ if (!i2 && u2.length > 1) return t2(u2[0]);
738
+ } else {
739
+ var a2 = e2.name;
740
+ D[a2] = e2, i2 = a2;
741
+ }
742
+ return !r2 && i2 && (g = i2), i2 || !r2 && g;
743
+ }, O = function(t2, e2) {
744
+ if (S(t2)) return t2.clone();
745
+ var n2 = "object" == typeof e2 ? e2 : {};
746
+ return n2.date = t2, n2.args = arguments, new _(n2);
747
+ }, b = v;
748
+ b.l = w, b.i = S, b.w = function(t2, e2) {
749
+ return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
750
+ };
751
+ var _ = (function() {
752
+ function M2(t2) {
753
+ this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
754
+ }
755
+ var m2 = M2.prototype;
756
+ return m2.parse = function(t2) {
757
+ this.$d = (function(t3) {
758
+ var e2 = t3.date, n2 = t3.utc;
759
+ if (null === e2) return /* @__PURE__ */ new Date(NaN);
760
+ if (b.u(e2)) return /* @__PURE__ */ new Date();
761
+ if (e2 instanceof Date) return new Date(e2);
762
+ if ("string" == typeof e2 && !/Z$/i.test(e2)) {
763
+ var r2 = e2.match($);
764
+ if (r2) {
765
+ var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
766
+ return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
767
+ }
768
+ }
769
+ return new Date(e2);
770
+ })(t2), this.init();
771
+ }, m2.init = function() {
772
+ var t2 = this.$d;
773
+ this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
774
+ }, m2.$utils = function() {
775
+ return b;
776
+ }, m2.isValid = function() {
777
+ return !(this.$d.toString() === l);
778
+ }, m2.isSame = function(t2, e2) {
779
+ var n2 = O(t2);
780
+ return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
781
+ }, m2.isAfter = function(t2, e2) {
782
+ return O(t2) < this.startOf(e2);
783
+ }, m2.isBefore = function(t2, e2) {
784
+ return this.endOf(e2) < O(t2);
785
+ }, m2.$g = function(t2, e2, n2) {
786
+ return b.u(t2) ? this[e2] : this.set(n2, t2);
787
+ }, m2.unix = function() {
788
+ return Math.floor(this.valueOf() / 1e3);
789
+ }, m2.valueOf = function() {
790
+ return this.$d.getTime();
791
+ }, m2.startOf = function(t2, e2) {
792
+ var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
793
+ var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
794
+ return r2 ? i2 : i2.endOf(a);
795
+ }, $2 = function(t3, e3) {
796
+ return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
797
+ }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
798
+ switch (f2) {
799
+ case h:
800
+ return r2 ? l2(1, 0) : l2(31, 11);
801
+ case c:
802
+ return r2 ? l2(1, M3) : l2(0, M3 + 1);
803
+ case o:
804
+ var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
805
+ return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
806
+ case a:
807
+ case d:
808
+ return $2(v2 + "Hours", 0);
809
+ case u:
810
+ return $2(v2 + "Minutes", 1);
811
+ case s:
812
+ return $2(v2 + "Seconds", 2);
813
+ case i:
814
+ return $2(v2 + "Milliseconds", 3);
815
+ default:
816
+ return this.clone();
817
+ }
818
+ }, m2.endOf = function(t2) {
819
+ return this.startOf(t2, false);
820
+ }, m2.$set = function(t2, e2) {
821
+ var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
822
+ if (o2 === c || o2 === h) {
823
+ var y2 = this.clone().set(d, 1);
824
+ y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
825
+ } else l2 && this.$d[l2]($2);
826
+ return this.init(), this;
827
+ }, m2.set = function(t2, e2) {
828
+ return this.clone().$set(t2, e2);
829
+ }, m2.get = function(t2) {
830
+ return this[b.p(t2)]();
831
+ }, m2.add = function(r2, f2) {
832
+ var d2, l2 = this;
833
+ r2 = Number(r2);
834
+ var $2 = b.p(f2), y2 = function(t2) {
835
+ var e2 = O(l2);
836
+ return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
837
+ };
838
+ if ($2 === c) return this.set(c, this.$M + r2);
839
+ if ($2 === h) return this.set(h, this.$y + r2);
840
+ if ($2 === a) return y2(1);
841
+ if ($2 === o) return y2(7);
842
+ var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
843
+ return b.w(m3, this);
844
+ }, m2.subtract = function(t2, e2) {
845
+ return this.add(-1 * t2, e2);
846
+ }, m2.format = function(t2) {
847
+ var e2 = this, n2 = this.$locale();
848
+ if (!this.isValid()) return n2.invalidDate || l;
849
+ var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
850
+ return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
851
+ }, d2 = function(t3) {
852
+ return b.s(s2 % 12 || 12, t3, "0");
853
+ }, $2 = f2 || function(t3, e3, n3) {
854
+ var r3 = t3 < 12 ? "AM" : "PM";
855
+ return n3 ? r3.toLowerCase() : r3;
856
+ };
857
+ return r2.replace(y, (function(t3, r3) {
858
+ return r3 || (function(t4) {
859
+ switch (t4) {
860
+ case "YY":
861
+ return String(e2.$y).slice(-2);
862
+ case "YYYY":
863
+ return b.s(e2.$y, 4, "0");
864
+ case "M":
865
+ return a2 + 1;
866
+ case "MM":
867
+ return b.s(a2 + 1, 2, "0");
868
+ case "MMM":
869
+ return h2(n2.monthsShort, a2, c2, 3);
870
+ case "MMMM":
871
+ return h2(c2, a2);
872
+ case "D":
873
+ return e2.$D;
874
+ case "DD":
875
+ return b.s(e2.$D, 2, "0");
876
+ case "d":
877
+ return String(e2.$W);
878
+ case "dd":
879
+ return h2(n2.weekdaysMin, e2.$W, o2, 2);
880
+ case "ddd":
881
+ return h2(n2.weekdaysShort, e2.$W, o2, 3);
882
+ case "dddd":
883
+ return o2[e2.$W];
884
+ case "H":
885
+ return String(s2);
886
+ case "HH":
887
+ return b.s(s2, 2, "0");
888
+ case "h":
889
+ return d2(1);
890
+ case "hh":
891
+ return d2(2);
892
+ case "a":
893
+ return $2(s2, u2, true);
894
+ case "A":
895
+ return $2(s2, u2, false);
896
+ case "m":
897
+ return String(u2);
898
+ case "mm":
899
+ return b.s(u2, 2, "0");
900
+ case "s":
901
+ return String(e2.$s);
902
+ case "ss":
903
+ return b.s(e2.$s, 2, "0");
904
+ case "SSS":
905
+ return b.s(e2.$ms, 3, "0");
906
+ case "Z":
907
+ return i2;
908
+ }
909
+ return null;
910
+ })(t3) || i2.replace(":", "");
911
+ }));
912
+ }, m2.utcOffset = function() {
913
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
914
+ }, m2.diff = function(r2, d2, l2) {
915
+ var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
916
+ return b.m(y2, m3);
917
+ };
918
+ switch (M3) {
919
+ case h:
920
+ $2 = D2() / 12;
921
+ break;
922
+ case c:
923
+ $2 = D2();
924
+ break;
925
+ case f:
926
+ $2 = D2() / 3;
927
+ break;
928
+ case o:
929
+ $2 = (g2 - v2) / 6048e5;
930
+ break;
931
+ case a:
932
+ $2 = (g2 - v2) / 864e5;
933
+ break;
934
+ case u:
935
+ $2 = g2 / n;
936
+ break;
937
+ case s:
938
+ $2 = g2 / e;
939
+ break;
940
+ case i:
941
+ $2 = g2 / t;
942
+ break;
943
+ default:
944
+ $2 = g2;
945
+ }
946
+ return l2 ? $2 : b.a($2);
947
+ }, m2.daysInMonth = function() {
948
+ return this.endOf(c).$D;
949
+ }, m2.$locale = function() {
950
+ return D[this.$L];
951
+ }, m2.locale = function(t2, e2) {
952
+ if (!t2) return this.$L;
953
+ var n2 = this.clone(), r2 = w(t2, e2, true);
954
+ return r2 && (n2.$L = r2), n2;
955
+ }, m2.clone = function() {
956
+ return b.w(this.$d, this);
957
+ }, m2.toDate = function() {
958
+ return new Date(this.valueOf());
959
+ }, m2.toJSON = function() {
960
+ return this.isValid() ? this.toISOString() : null;
961
+ }, m2.toISOString = function() {
962
+ return this.$d.toISOString();
963
+ }, m2.toString = function() {
964
+ return this.$d.toUTCString();
965
+ }, M2;
966
+ })(), Y = _.prototype;
967
+ return O.prototype = Y, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach((function(t2) {
968
+ Y[t2[1]] = function(e2) {
969
+ return this.$g(e2, t2[0], t2[1]);
970
+ };
971
+ })), O.extend = function(t2, e2) {
972
+ return t2.$i || (t2(e2, _, O), t2.$i = true), O;
973
+ }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
974
+ return O(1e3 * t2);
975
+ }, O.en = D[g], O.Ls = D, O.p = {}, O;
976
+ }));
977
+ })(dayjs_min$1);
978
+ return dayjs_min$1.exports;
979
+ }
980
+ var dayjs_minExports = requireDayjs_min();
981
+ const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
694
982
  class NineUtil {
695
983
  constructor() {
696
984
  __privateAdd(this, _NineUtil_instances);
985
+ __publicField(this, "formatDate", (v, fmt) => {
986
+ return dayjs(v).format(fmt);
987
+ });
697
988
  }
698
989
  alert(message, title = "Alert") {
699
990
  return __privateMethod(this, _NineUtil_instances, prepare_fn).call(this, "alert", message, title, "classic");
@@ -1190,7 +1481,7 @@ class UxSplitter extends HTMLElement {
1190
1481
  const htmlTmpl = document.createElement("template");
1191
1482
  htmlTmpl.innerHTML = `
1192
1483
  <style>
1193
- @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-util@${"0.9.138"}/dist/css/nine-util.css";
1484
+ @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-util@${"0.9.141"}/dist/css/nine-util.css";
1194
1485
  ${this.cssPath ? `@import "${this.cssPath}";` : ""}
1195
1486
  </style>
1196
1487
  ${gripTmpl}
@@ -1241,6 +1532,7 @@ const utilInstance = new NineUtil();
1241
1532
  nine.alert = utilInstance.alert.bind(utilInstance);
1242
1533
  nine.confirm = utilInstance.confirm.bind(utilInstance);
1243
1534
  nine.prompt = utilInstance.prompt.bind(utilInstance);
1535
+ nine.formatDate = utilInstance.formatDate.bind(utilInstance);
1244
1536
  nine.safe = safe;
1245
1537
  nine.api = api;
1246
1538
  nine.trace = trace$2;