@nivaro/react 0.1.65 → 0.1.66

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.
Files changed (2) hide show
  1. package/dist/index.js +43 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35,12 +35,13 @@ function Q(...t) {
35
35
  return Zb(Xb(t));
36
36
  }
37
37
  function uo(t, n) {
38
+ const r = typeof t == "string" ? t.match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/) : null, l = r ? new Date(Number(r[1]), Number(r[2]) - 1, Number(r[3])) : new Date(t);
38
39
  return new Intl.DateTimeFormat("en-US", {
39
40
  month: "short",
40
41
  day: "numeric",
41
42
  year: "numeric",
42
43
  ...n
43
- }).format(new Date(t));
44
+ }).format(l);
44
45
  }
45
46
  function il(t) {
46
47
  return new Intl.DateTimeFormat("en-US", {
@@ -1639,35 +1640,35 @@ function li(t) {
1639
1640
  return String(t).padStart(2, "0");
1640
1641
  }
1641
1642
  function vg(t, n) {
1642
- const r = new Date(t);
1643
- return Number.isNaN(r.getTime()) ? t : n === "relative" ? ua(r) : n.replace(/YYYY|MMM|YY|MM|DD|HH|hh|mm|ss|h|A|a/g, (l) => {
1644
- switch (l) {
1643
+ const r = t.match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/), l = r ? new Date(Number(r[1]), Number(r[2]) - 1, Number(r[3])) : new Date(t);
1644
+ return Number.isNaN(l.getTime()) ? t : n === "relative" ? ua(l) : n.replace(/YYYY|MMM|YY|MM|DD|HH|hh|mm|ss|h|A|a/g, (s) => {
1645
+ switch (s) {
1645
1646
  case "YYYY":
1646
- return String(r.getFullYear());
1647
+ return String(l.getFullYear());
1647
1648
  case "YY":
1648
- return String(r.getFullYear()).slice(-2);
1649
+ return String(l.getFullYear()).slice(-2);
1649
1650
  case "MMM":
1650
- return xg[r.getMonth()];
1651
+ return xg[l.getMonth()];
1651
1652
  case "MM":
1652
- return li(r.getMonth() + 1);
1653
+ return li(l.getMonth() + 1);
1653
1654
  case "DD":
1654
- return li(r.getDate());
1655
+ return li(l.getDate());
1655
1656
  case "HH":
1656
- return li(r.getHours());
1657
+ return li(l.getHours());
1657
1658
  case "hh":
1658
- return li(r.getHours() % 12 || 12);
1659
+ return li(l.getHours() % 12 || 12);
1659
1660
  case "h":
1660
- return String(r.getHours() % 12 || 12);
1661
+ return String(l.getHours() % 12 || 12);
1661
1662
  case "mm":
1662
- return li(r.getMinutes());
1663
+ return li(l.getMinutes());
1663
1664
  case "ss":
1664
- return li(r.getSeconds());
1665
+ return li(l.getSeconds());
1665
1666
  case "A":
1666
- return r.getHours() < 12 ? "AM" : "PM";
1667
+ return l.getHours() < 12 ? "AM" : "PM";
1667
1668
  case "a":
1668
- return r.getHours() < 12 ? "am" : "pm";
1669
+ return l.getHours() < 12 ? "am" : "pm";
1669
1670
  default:
1670
- return l;
1671
+ return s;
1671
1672
  }
1672
1673
  });
1673
1674
  }
@@ -5186,15 +5187,12 @@ function ss(t, n) {
5186
5187
  let i = /^\d{4}-\d{2}-\d{2}$/.test(l) || r === "date";
5187
5188
  if (!i && (n != null && n.options))
5188
5189
  try {
5189
- const d = typeof n.options == "string" ? JSON.parse(n.options) : n.options;
5190
- d && d.date_mode === "date" && (i = !0);
5190
+ const o = typeof n.options == "string" ? JSON.parse(n.options) : n.options;
5191
+ o && o.date_mode === "date" && (i = !0);
5191
5192
  } catch {
5192
5193
  }
5193
- if (/^\d{4}-\d{2}-\d{2}$/.test(l)) {
5194
- const [d, o, u] = l.split("-").map(Number);
5195
- return new Date(d, o - 1, u).toLocaleDateString();
5196
- }
5197
- return i ? new Date(l).toLocaleDateString() : new Date(l).toLocaleString();
5194
+ const d = l.match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/);
5195
+ return d ? new Date(Number(d[1]), Number(d[2]) - 1, Number(d[3])).toLocaleDateString() : i ? new Date(l).toLocaleDateString() : new Date(l).toLocaleString();
5198
5196
  } catch {
5199
5197
  }
5200
5198
  if ((r === "select-dropdown" || r === "radio-buttons") && n) {
@@ -27533,13 +27531,28 @@ function zk({
27533
27531
  relations: s
27534
27532
  }) {
27535
27533
  const i = Kk(s, t, n);
27536
- return i != null && i.one_collection ? /* @__PURE__ */ e(sh, { relatedCollection: i.one_collection, id: l }) : l == null ? /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-300", children: "—" }) : r === "boolean" ? /* @__PURE__ */ e(
27537
- "span",
27538
- {
27539
- className: `inline-flex h-4 items-center rounded-full px-1.5 text-[10px] font-medium ${l ? "bg-emerald-100 text-emerald-700" : "bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-400"}`,
27540
- children: l ? "Yes" : "No"
27534
+ if (i != null && i.one_collection) return /* @__PURE__ */ e(sh, { relatedCollection: i.one_collection, id: l });
27535
+ if (l == null) return /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-300", children: "—" });
27536
+ if (r === "boolean")
27537
+ return /* @__PURE__ */ e(
27538
+ "span",
27539
+ {
27540
+ className: `inline-flex h-4 items-center rounded-full px-1.5 text-[10px] font-medium ${l ? "bg-emerald-100 text-emerald-700" : "bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-400"}`,
27541
+ children: l ? "Yes" : "No"
27542
+ }
27543
+ );
27544
+ if (r === "timestamp" || r === "datetime" || r === "date") {
27545
+ const d = String(l).match(/^(\d{4})-(\d{2})-(\d{2})(?:T00:00:00(?:\.000)?Z)?$/);
27546
+ if (d) {
27547
+ const o = new Date(Number(d[1]), Number(d[2]) - 1, Number(d[3])).toLocaleDateString(
27548
+ "en-US",
27549
+ { month: "short", day: "numeric", year: "numeric" }
27550
+ );
27551
+ return /* @__PURE__ */ e("span", { className: "text-[12px] tabular-nums text-slate-400", children: o });
27541
27552
  }
27542
- ) : r === "timestamp" || r === "datetime" || r === "date" ? /* @__PURE__ */ e("span", { className: "text-[12px] tabular-nums text-slate-400", children: Ik(l) }) : typeof l == "string" ? /* @__PURE__ */ e(
27553
+ return /* @__PURE__ */ e("span", { className: "text-[12px] tabular-nums text-slate-400", children: Ik(l) });
27554
+ }
27555
+ return typeof l == "string" ? /* @__PURE__ */ e(
27543
27556
  "span",
27544
27557
  {
27545
27558
  className: Q(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.1.65",
3
+ "version": "0.1.66",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",