@nivaro/react 0.3.68 → 0.3.69

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.
@@ -1,4 +1,4 @@
1
- function c(t) {
1
+ function o(t) {
2
2
  if (typeof t == "string")
3
3
  try {
4
4
  const e = JSON.parse(t);
@@ -10,17 +10,17 @@ function c(t) {
10
10
  }
11
11
  const u = (t) => Array.isArray(t) ? t.filter((e) => typeof e == "string" && e !== "") : [], f = (t) => typeof t == "string" && t.trim() !== "" ? t : void 0;
12
12
  function y(t) {
13
- const e = c(t).text_rules;
13
+ const e = o(t).text_rules;
14
14
  if (!Array.isArray(e)) return [];
15
15
  const r = [];
16
16
  for (const n of e) {
17
17
  if (!n || typeof n != "object") continue;
18
- const i = n, s = i.type === "role" ? "role" : i.type === "pipeline_state" ? "pipeline_state" : null;
19
- if (!s) continue;
20
- const o = { type: s };
21
- typeof i.pipeline_id == "string" && i.pipeline_id && (o.pipeline_id = i.pipeline_id), s === "pipeline_state" ? o.state_keys = u(i.state_keys) : o.role_ids = u(i.role_ids);
18
+ const i = n, c = i.type === "role" ? "role" : i.type === "pipeline_state" ? "pipeline_state" : null;
19
+ if (!c) continue;
20
+ const s = { type: c };
21
+ typeof i.pipeline_id == "string" && i.pipeline_id && (s.pipeline_id = i.pipeline_id), c === "pipeline_state" ? s.state_keys = u(i.state_keys) : s.role_ids = u(i.role_ids);
22
22
  const l = f(i.label), a = f(i.note);
23
- l !== void 0 && (o.label = l), a !== void 0 && (o.note = a), r.push(o);
23
+ l !== void 0 && (s.label = l), a !== void 0 && (s.note = a), r.push(s);
24
24
  }
25
25
  return r;
26
26
  }
@@ -39,24 +39,30 @@ function h(t, e) {
39
39
  break;
40
40
  return r;
41
41
  }
42
- function k(t) {
43
- const e = c(t);
42
+ function F(t) {
43
+ const e = o(t);
44
44
  return e.recommended === !0 && e.required !== !0;
45
45
  }
46
- function F(t) {
46
+ function U(t) {
47
47
  return t == null || t === "" ? !0 : Array.isArray(t) ? t.length === 0 : typeof t == "string" && t.trim() === "";
48
48
  }
49
49
  function m(t) {
50
- const e = c(t).confirm_change;
50
+ const e = o(t).confirm_change;
51
51
  return e === !0 ? { state_keys: [] } : !e || typeof e != "object" || Array.isArray(e) ? null : { state_keys: u(e.state_keys) };
52
52
  }
53
- function U(t, e) {
53
+ function k(t, e) {
54
54
  const r = m(t);
55
55
  return r ? r.state_keys.length === 0 ? !0 : !!e && r.state_keys.includes(e) : !1;
56
56
  }
57
+ function w(t) {
58
+ return o(t).file_used_in !== !1;
59
+ }
60
+ function D(t) {
61
+ return o(t).file_downloads !== !1;
62
+ }
57
63
  const d = 1e6;
58
- function g(t) {
59
- const e = c(t).counter;
64
+ function _(t) {
65
+ const e = o(t).counter;
60
66
  if (!e || typeof e != "object" || Array.isArray(e)) return null;
61
67
  const r = e, n = Number(r.limit);
62
68
  return {
@@ -64,13 +70,13 @@ function g(t) {
64
70
  limit: r.limit != null && r.limit !== "" && Number.isFinite(n) && n > 0 ? Math.min(d, Math.floor(n)) : null
65
71
  };
66
72
  }
67
- function _(t) {
73
+ function g(t) {
68
74
  if (t == null) return "";
69
75
  const e = typeof t == "string" ? t : typeof t == "object" ? JSON.stringify(t) : String(t);
70
76
  return /<[a-z!/][^>]*>/i.test(e) ? e.replace(/<(br|\/p|\/div|\/li|\/h[1-6])\b[^>]*>/gi, " ").replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ").replace(/&(amp|lt|gt|quot|#39);/g, "x") : e;
71
77
  }
72
78
  function b(t, e) {
73
- const r = _(t);
79
+ const r = g(t);
74
80
  if (e === "words") {
75
81
  const n = r.trim();
76
82
  return n ? n.split(/\s+/).length : 0;
@@ -81,16 +87,16 @@ function L(t, e) {
81
87
  return e == null ? "ok" : t > e ? "over" : t >= e * 0.9 ? "near" : "ok";
82
88
  }
83
89
  function x(t, e, r) {
84
- const n = g(e);
90
+ const n = _(e);
85
91
  if (!n || n.limit == null) return null;
86
92
  const i = b(t, n.unit);
87
93
  return i <= n.limit ? null : `${r} is over its limit of ${n.limit.toLocaleString("en-US")} ${n.unit} (${i.toLocaleString("en-US")})`;
88
94
  }
89
95
  const S = /^__calc_[a-z0-9_]{1,40}__$/;
90
- function D(t) {
96
+ function O(t) {
91
97
  return S.test(t);
92
98
  }
93
- function w(t) {
99
+ function j(t) {
94
100
  const e = new Set(t);
95
101
  for (let r = 1; ; r++) {
96
102
  const n = `__calc_${r}__`;
@@ -98,13 +104,13 @@ function w(t) {
98
104
  }
99
105
  }
100
106
  const A = ["", "integer", "number", "currency", "percent"];
101
- function O(t) {
102
- const e = c(t).display_formula;
107
+ function $(t) {
108
+ const e = o(t).display_formula;
103
109
  if (!e || typeof e != "object" || Array.isArray(e)) return null;
104
110
  const r = e, n = A.includes(r.format) ? r.format : "", i = typeof r.currency == "string" && /^[A-Z]{3}$/.test(r.currency) ? r.currency : null;
105
111
  return { expr: typeof r.expr == "string" ? r.expr : "", format: n, currency: i };
106
112
  }
107
- function j(t, e) {
113
+ function M(t, e) {
108
114
  if (t == null || !Number.isFinite(t)) return "—";
109
115
  switch (e.format) {
110
116
  case "integer":
@@ -125,20 +131,22 @@ function j(t, e) {
125
131
  }
126
132
  export {
127
133
  d as COUNTER_LIMIT_MAX,
128
- U as confirmChangeApplies,
134
+ k as confirmChangeApplies,
129
135
  m as confirmChangeOf,
130
136
  b as countValue,
131
137
  x as counterError,
132
- g as counterOf,
138
+ _ as counterOf,
133
139
  L as counterState,
134
- O as displayFormulaOf,
135
- j as formatDisplayValue,
136
- D as isDisplayFormulaField,
137
- F as isEmptyValue,
138
- k as isRecommended,
139
- w as nextDisplayFormulaField,
140
- c as overridesObject,
140
+ $ as displayFormulaOf,
141
+ M as formatDisplayValue,
142
+ O as isDisplayFormulaField,
143
+ U as isEmptyValue,
144
+ F as isRecommended,
145
+ j as nextDisplayFormulaField,
146
+ o as overridesObject,
141
147
  h as resolvePlacementText,
148
+ D as showsFileDownloads,
149
+ w as showsFileUsage,
142
150
  p as textRuleMatches,
143
151
  y as textRulesOf
144
152
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.68",
3
+ "version": "0.3.69",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",