@nivaro/react 0.3.10 → 0.3.11
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/full.css +1 -1
- package/dist/hooks/useNivaroForm.js +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +34 -3
- package/dist/shared/components/CollectionBrowserView.js +1546 -1477
- package/dist/shared/components/ItemEditForm.js +4332 -4195
- package/dist/shared/components/PageRenderer.js +512 -465
- package/dist/shared/components/QueryStatStrip.js +74 -70
- package/dist/shared/components/ReportView.js +818 -827
- package/dist/shared/components/SheetHeaderBody.js +16 -14
- package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
- package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
- package/dist/shared/components/item-edit/FieldRow.js +20 -19
- package/dist/shared/components/item-edit/FilePickerField.js +52 -40
- package/dist/shared/components/item-edit/GroupSection.js +221 -221
- package/dist/shared/components/item-edit/InlineGridField.js +41 -41
- package/dist/shared/components/item-edit/InlineTableField.js +2249 -2238
- package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
- package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
- package/dist/shared/components/item-edit/QuickPicker.js +263 -216
- package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
- package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
- package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
- package/dist/shared/components/item-edit/helpers.js +133 -134
- package/dist/shared/components/item-edit/line-qty.js +57 -0
- package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
- package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
- package/dist/shared/components/panels/CommentPanel.js +350 -315
- package/dist/shared/components/panels/ItemLockBanner.js +297 -230
- package/dist/shared/components/panels/PipelinePanel.js +719 -701
- package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
- package/dist/shared/components/queue/QueueWorklist.js +1005 -935
- package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
- package/dist/shared/lib/obligation-banner.js +14 -13
- package/dist/shared/lib/obligation-reason-text.js +13 -0
- package/dist/shared/lib/query-filter-seed.js +34 -11
- package/dist/shared/lib/sanitize-html.js +24 -15
- package/dist/shared/lib/sheet-def.js +38 -22
- package/dist/shared/lib/unique-options.js +10 -0
- package/dist/shared/lib/utils.js +57 -43
- package/dist/shared/lib/validation-rules.js +58 -34
- package/package.json +1 -1
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { useRef as b, useEffect as w, useState as E } from "react";
|
|
2
2
|
import { useNivaroClient as N, useParentDraft as P } from "../../context.js";
|
|
3
3
|
import { get as j } from "../../lib/commands.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { htmlToText as I } from "../../lib/sanitize-html.js";
|
|
5
|
+
function L(t, n) {
|
|
6
|
+
if (!t) {
|
|
7
|
+
const i = [n.first_name, n.last_name].filter((l) => l != null && String(l).trim() !== "").join(" ");
|
|
8
|
+
return String(
|
|
9
|
+
n.name ?? n.title ?? n.label ?? n.type ?? n.description ?? (i || null) ?? n.email ?? n.id ?? ""
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
return t.replace(/\{\{([^}]+)\}\}/g, (i, l) => {
|
|
13
|
+
const f = l.trim().split(".");
|
|
14
|
+
let s = n;
|
|
15
|
+
for (const d of f) {
|
|
16
|
+
if (s == null || typeof s != "object") {
|
|
17
|
+
s = null;
|
|
11
18
|
break;
|
|
12
19
|
}
|
|
13
|
-
|
|
20
|
+
s = s[d];
|
|
14
21
|
}
|
|
15
|
-
return String(
|
|
16
|
-
})
|
|
17
|
-
n.name ?? n.title ?? n.label ?? n.type ?? n.description ?? n.id ?? ""
|
|
18
|
-
);
|
|
22
|
+
return String(s ?? "");
|
|
23
|
+
});
|
|
19
24
|
}
|
|
20
25
|
function T(t) {
|
|
21
26
|
if (t == null) return null;
|
|
@@ -27,162 +32,162 @@ function T(t) {
|
|
|
27
32
|
return null;
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
function
|
|
35
|
+
function q(t) {
|
|
31
36
|
const n = T(t);
|
|
32
37
|
return Array.isArray(n == null ? void 0 : n.cascade_filters) ? n.cascade_filters : [];
|
|
33
38
|
}
|
|
34
|
-
function
|
|
35
|
-
var d,
|
|
39
|
+
function M(t) {
|
|
40
|
+
var d, h;
|
|
36
41
|
let n;
|
|
37
|
-
const
|
|
38
|
-
if (n || (n = {}),
|
|
39
|
-
n[
|
|
40
|
-
else if (
|
|
41
|
-
const p =
|
|
42
|
+
const i = [], l = [], f = [], s = (o, a) => {
|
|
43
|
+
if (n || (n = {}), o.filter_is_m2m)
|
|
44
|
+
n[o.filter_column] = { _some: a };
|
|
45
|
+
else if (o.filter_column.includes(".")) {
|
|
46
|
+
const p = o.filter_column.split(".");
|
|
42
47
|
let _ = a;
|
|
43
48
|
for (let u = p.length - 1; u >= 1; u--) _ = { [p[u]]: _ };
|
|
44
|
-
n[p[0]] =
|
|
49
|
+
n[p[0]] = o.filter_via_many ? { _some: _ } : _;
|
|
45
50
|
} else
|
|
46
|
-
n[
|
|
51
|
+
n[o.filter_column] = a;
|
|
47
52
|
};
|
|
48
|
-
for (const
|
|
49
|
-
if ((d = t.skipParent) != null && d.call(t,
|
|
50
|
-
const a = t.parentValue(
|
|
53
|
+
for (const o of t.rules) {
|
|
54
|
+
if ((d = t.skipParent) != null && d.call(t, o.parent_field)) continue;
|
|
55
|
+
const a = t.parentValue(o.parent_field);
|
|
51
56
|
if (a != null && a !== "" && !(Array.isArray(a) && a.length === 0)) {
|
|
52
57
|
let _ = a;
|
|
53
|
-
if (
|
|
54
|
-
const y =
|
|
58
|
+
if (o.value_map && typeof o.value_map == "object") {
|
|
59
|
+
const y = o.value_map, m = (e) => y[String(e)] ?? o.value_map_default ?? e;
|
|
55
60
|
_ = Array.isArray(a) ? [
|
|
56
61
|
...new Set(
|
|
57
62
|
a.flatMap((e) => {
|
|
58
|
-
const r =
|
|
63
|
+
const r = m(e);
|
|
59
64
|
return Array.isArray(r) ? r : [r];
|
|
60
65
|
})
|
|
61
66
|
)
|
|
62
|
-
] :
|
|
67
|
+
] : m(a);
|
|
63
68
|
}
|
|
64
69
|
const u = Array.isArray(_) ? { _in: _ } : { _eq: _ };
|
|
65
|
-
|
|
70
|
+
s(o, o.filter_is_m2m ? { id: u } : u), i.push(String(o.parent_field));
|
|
66
71
|
} else {
|
|
67
|
-
|
|
68
|
-
const _ =
|
|
69
|
-
_ &&
|
|
72
|
+
l.push(String(o.parent_field)), o.show_all_if_no_parent === !1 && f.push(String(o.parent_field));
|
|
73
|
+
const _ = o.value_map || (h = t.parentOptionFilter) == null ? void 0 : h.call(t, o.parent_field);
|
|
74
|
+
_ && s(o, _);
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
|
-
return { filter: n, satisfiedParents:
|
|
77
|
+
return { filter: n, satisfiedParents: i, unsatisfiedParents: l, missingRequiredParents: f };
|
|
73
78
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
76
|
-
(r) => r.many_collection ===
|
|
77
|
-
),
|
|
79
|
+
function z(t, n, i) {
|
|
80
|
+
const l = (e) => n.some(
|
|
81
|
+
(r) => r.many_collection === i && r.many_field === e && !r.junction_field || r.one_collection === i && r.one_field === e
|
|
82
|
+
), f = /* @__PURE__ */ new Map();
|
|
78
83
|
for (const e of t) {
|
|
79
84
|
if (e.hidden) continue;
|
|
80
|
-
const r =
|
|
81
|
-
r.length &&
|
|
85
|
+
const r = q(e.dependency_config);
|
|
86
|
+
r.length && l(e.field) && f.set(e.field, r);
|
|
82
87
|
}
|
|
83
|
-
const
|
|
84
|
-
for (const e of
|
|
85
|
-
for (const r of e)
|
|
86
|
-
const d = (e, r) => [...r].filter((
|
|
87
|
-
[...
|
|
88
|
-
), p = new Set([...
|
|
89
|
-
[...p].filter((e) => d(e, p).length > 0 ||
|
|
88
|
+
const s = new Set(f.keys());
|
|
89
|
+
for (const e of f.values())
|
|
90
|
+
for (const r of e) l(r.parent_field) && s.add(r.parent_field);
|
|
91
|
+
const d = (e, r) => [...r].filter((c) => c !== e && (f.get(c) ?? []).some((g) => g.parent_field === e)), h = new Set(t.filter((e) => e.required).map((e) => e.field)), o = (e) => h.has(e) && (f.get(e) ?? []).some((r) => r.show_all_if_no_parent !== !0), a = new Set(
|
|
92
|
+
[...s].filter((e) => d(e, s).length === 0 && !o(e))
|
|
93
|
+
), p = new Set([...s].filter((e) => !a.has(e))), _ = new Set(
|
|
94
|
+
[...p].filter((e) => d(e, p).length > 0 || f.has(e))
|
|
90
95
|
), u = [...p].filter((e) => {
|
|
91
96
|
if (!_.has(e)) return !1;
|
|
92
|
-
const r = d(e,
|
|
93
|
-
return r.length === 0 || r.some((
|
|
97
|
+
const r = d(e, s);
|
|
98
|
+
return r.length === 0 || r.some((c) => p.has(c));
|
|
94
99
|
});
|
|
95
100
|
if (u.length > 0) {
|
|
96
|
-
|
|
97
|
-
for (const e of u)
|
|
101
|
+
s.clear();
|
|
102
|
+
for (const e of u) s.add(e);
|
|
98
103
|
}
|
|
99
|
-
const y = [],
|
|
100
|
-
for (;
|
|
104
|
+
const y = [], m = new Set(s);
|
|
105
|
+
for (; m.size; ) {
|
|
101
106
|
let e = null, r = Number.POSITIVE_INFINITY;
|
|
102
|
-
for (const
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
107
|
+
for (const c of [...m].sort()) {
|
|
108
|
+
const g = (f.get(c) ?? []).filter((S) => s.has(S.parent_field));
|
|
109
|
+
if (g.filter(
|
|
105
110
|
(S) => S.show_all_if_no_parent === !1 && !y.includes(S.parent_field)
|
|
106
111
|
).length > 0) continue;
|
|
107
112
|
const A = new Set(
|
|
108
|
-
|
|
109
|
-
).size * 100 +
|
|
110
|
-
A < r && (r = A, e =
|
|
113
|
+
g.map((S) => S.parent_field).filter((S) => !y.includes(S) && S !== c)
|
|
114
|
+
).size * 100 + g.length;
|
|
115
|
+
A < r && (r = A, e = c);
|
|
111
116
|
}
|
|
112
|
-
e == null && (e = [...
|
|
113
|
-
(
|
|
117
|
+
e == null && (e = [...m].sort(
|
|
118
|
+
(c, g) => {
|
|
114
119
|
var k, v;
|
|
115
|
-
return (((k =
|
|
120
|
+
return (((k = f.get(c)) == null ? void 0 : k.length) ?? 0) - (((v = f.get(g)) == null ? void 0 : v.length) ?? 0);
|
|
116
121
|
}
|
|
117
|
-
)[0]), y.push(e),
|
|
122
|
+
)[0]), y.push(e), m.delete(e);
|
|
118
123
|
}
|
|
119
124
|
return y;
|
|
120
125
|
}
|
|
121
|
-
function
|
|
126
|
+
function W({
|
|
122
127
|
cascadeRules: t,
|
|
123
128
|
cascadeFilter: n,
|
|
124
|
-
currentValue:
|
|
125
|
-
relatedCollection:
|
|
126
|
-
missingRequiredParents:
|
|
127
|
-
onClear:
|
|
129
|
+
currentValue: i,
|
|
130
|
+
relatedCollection: l,
|
|
131
|
+
missingRequiredParents: f,
|
|
132
|
+
onClear: s
|
|
128
133
|
}) {
|
|
129
|
-
const d = N(),
|
|
130
|
-
a.current =
|
|
131
|
-
const e =
|
|
132
|
-
|
|
133
|
-
}, [
|
|
134
|
-
const p = b(null), _ = P(), u = _ == null ? void 0 : _.dirtyFields, y = (
|
|
134
|
+
const d = N(), h = JSON.stringify(n), o = b(void 0), a = b(s);
|
|
135
|
+
a.current = s, w(() => {
|
|
136
|
+
const e = o.current;
|
|
137
|
+
o.current = h, e !== void 0 && e !== h && t.some((r) => r.clear_on_parent_change) && a.current();
|
|
138
|
+
}, [h, t]);
|
|
139
|
+
const p = b(null), _ = P(), u = _ == null ? void 0 : _.dirtyFields, y = (f ?? []).join(","), m = b(null);
|
|
135
140
|
return w(() => {
|
|
136
|
-
if (
|
|
137
|
-
const e = (
|
|
138
|
-
(
|
|
141
|
+
if (i == null || i === "") return;
|
|
142
|
+
const e = (f ?? []).filter(
|
|
143
|
+
(c) => (u == null ? void 0 : u.has(c)) && t.some((g) => g.parent_field === c && g.clear_on_unavailable)
|
|
139
144
|
);
|
|
140
145
|
if (e.length === 0) return;
|
|
141
|
-
const r = `${String(
|
|
142
|
-
|
|
143
|
-
}, [y,
|
|
144
|
-
if (!n || Object.keys(n).length === 0 || !t.some((
|
|
145
|
-
(
|
|
146
|
+
const r = `${String(i)}|${e.join(",")}`;
|
|
147
|
+
m.current !== r && (m.current = r, a.current());
|
|
148
|
+
}, [y, i, u, t]), w(() => {
|
|
149
|
+
if (!n || Object.keys(n).length === 0 || !t.some((c) => c.clear_on_unavailable) || i == null || !l || !t.some(
|
|
150
|
+
(c) => c.clear_on_unavailable && (u == null ? void 0 : u.has(c.parent_field))
|
|
146
151
|
)) return;
|
|
147
|
-
const r = `${
|
|
152
|
+
const r = `${l}|${String(i)}|${h}`;
|
|
148
153
|
p.current !== r && (p.current = r, d.request(
|
|
149
|
-
j(`/items/${
|
|
150
|
-
filter: JSON.stringify({ ...n, id: { _eq:
|
|
154
|
+
j(`/items/${l}`, {
|
|
155
|
+
filter: JSON.stringify({ ...n, id: { _eq: i } }),
|
|
151
156
|
limit: 1,
|
|
152
157
|
fields: "id"
|
|
153
158
|
})
|
|
154
|
-
).then((
|
|
155
|
-
(
|
|
159
|
+
).then((c) => {
|
|
160
|
+
(c.data ?? []).length === 0 && a.current();
|
|
156
161
|
}).catch(() => {
|
|
157
162
|
p.current === r && (p.current = null);
|
|
158
163
|
}));
|
|
159
164
|
}, [
|
|
160
165
|
n,
|
|
161
|
-
|
|
166
|
+
h,
|
|
162
167
|
t,
|
|
163
168
|
d,
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
i,
|
|
170
|
+
l,
|
|
166
171
|
u
|
|
167
172
|
]), null;
|
|
168
173
|
}
|
|
169
|
-
function
|
|
170
|
-
const [n,
|
|
174
|
+
function B(t) {
|
|
175
|
+
const [n, i] = E(9999);
|
|
171
176
|
return w(() => {
|
|
172
|
-
const
|
|
173
|
-
if (!
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
+
const l = t.current;
|
|
178
|
+
if (!l) return;
|
|
179
|
+
i(l.getBoundingClientRect().width);
|
|
180
|
+
const f = new ResizeObserver(([s]) => {
|
|
181
|
+
i(s.contentRect.width);
|
|
177
182
|
});
|
|
178
|
-
return
|
|
183
|
+
return f.observe(l), () => f.disconnect();
|
|
179
184
|
}, [t]), n;
|
|
180
185
|
}
|
|
181
|
-
function
|
|
182
|
-
const
|
|
183
|
-
return n < 480 ? 12 : n < 800 ?
|
|
186
|
+
function K(t, n) {
|
|
187
|
+
const i = T(t), l = (i == null ? void 0 : i.col_span) ?? 0, f = [3, 4, 6, 12].includes(l) ? l : 12;
|
|
188
|
+
return n < 480 ? 12 : n < 800 ? f <= 6 ? 6 : 12 : f;
|
|
184
189
|
}
|
|
185
|
-
function
|
|
190
|
+
function R(t) {
|
|
186
191
|
if (!t) return "";
|
|
187
192
|
try {
|
|
188
193
|
return new Date(String(t)).toISOString().slice(0, 16);
|
|
@@ -190,13 +195,13 @@ function B(t) {
|
|
|
190
195
|
return "";
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
|
-
const
|
|
198
|
+
const U = /* @__PURE__ */ new Set([
|
|
194
199
|
"id",
|
|
195
200
|
"date_created",
|
|
196
201
|
"date_updated",
|
|
197
202
|
"user_created",
|
|
198
203
|
"user_updated"
|
|
199
|
-
]),
|
|
204
|
+
]), D = /* @__PURE__ */ new Set([
|
|
200
205
|
"__pipeline__",
|
|
201
206
|
"__comments__",
|
|
202
207
|
"__tasks__",
|
|
@@ -206,50 +211,44 @@ const K = /* @__PURE__ */ new Set([
|
|
|
206
211
|
"__owners__",
|
|
207
212
|
"__pdf__",
|
|
208
213
|
"__subtitle__"
|
|
209
|
-
]),
|
|
210
|
-
function
|
|
214
|
+
]), Y = (t) => D.has(t) || t.startsWith("__widget_") && t.endsWith("__"), F = { created: [], updated: [], deleted: [] };
|
|
215
|
+
function Q(t) {
|
|
211
216
|
if (typeof t != "string") return null;
|
|
212
217
|
const n = t.trim();
|
|
213
218
|
if (!n) return null;
|
|
214
219
|
if (n.startsWith("{") && /"blocks"\s*:/.test(n))
|
|
215
220
|
try {
|
|
216
|
-
const
|
|
217
|
-
if (Array.isArray(
|
|
218
|
-
const
|
|
219
|
-
for (const
|
|
220
|
-
const
|
|
221
|
-
typeof
|
|
222
|
-
|
|
221
|
+
const i = JSON.parse(n);
|
|
222
|
+
if (Array.isArray(i.blocks)) {
|
|
223
|
+
const l = [];
|
|
224
|
+
for (const f of i.blocks) {
|
|
225
|
+
const s = f.data ?? {};
|
|
226
|
+
typeof s.text == "string" ? l.push(s.text) : Array.isArray(s.items) && l.push(
|
|
227
|
+
s.items.map(
|
|
223
228
|
(d) => typeof d == "string" ? d : String((d == null ? void 0 : d.content) ?? "")
|
|
224
229
|
).filter(Boolean).join(" · ")
|
|
225
230
|
);
|
|
226
231
|
}
|
|
227
|
-
return O(
|
|
232
|
+
return O(l.join(" ")).trim();
|
|
228
233
|
}
|
|
229
234
|
} catch {
|
|
230
235
|
}
|
|
231
236
|
return /<[a-z][\s\S]*>/i.test(n) ? O(n).trim() : null;
|
|
232
237
|
}
|
|
233
|
-
|
|
234
|
-
if (typeof document < "u") {
|
|
235
|
-
const n = document.createElement("div");
|
|
236
|
-
return n.innerHTML = t, (n.textContent || "").replace(/\s+/g, " ");
|
|
237
|
-
}
|
|
238
|
-
return t.replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/\s+/g, " ");
|
|
239
|
-
}
|
|
238
|
+
const O = I;
|
|
240
239
|
export {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
240
|
+
W as CascadeEffectController,
|
|
241
|
+
F as EMPTY_NESTED_OPS,
|
|
242
|
+
D as SENTINEL_FIELDS,
|
|
243
|
+
U as SYSTEM_FIELDS,
|
|
244
|
+
L as applyDisplayTemplate,
|
|
245
|
+
M as buildCascadeFilter,
|
|
246
|
+
q as getCascadeFilters,
|
|
247
|
+
Y as isSentinelKey,
|
|
249
248
|
T as parseJson,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
K as resolveColSpan,
|
|
250
|
+
Q as richTextToPlain,
|
|
251
|
+
z as seedQuickPickerSteps,
|
|
252
|
+
R as toLocalDatetime,
|
|
253
|
+
B as useContainerWidth
|
|
255
254
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { evaluateNumeric as c } from "../../lib/expression.js";
|
|
2
|
+
const o = {
|
|
3
|
+
tinyint: 255,
|
|
4
|
+
smallint: 32767,
|
|
5
|
+
integer: 2147483647,
|
|
6
|
+
int: 2147483647,
|
|
7
|
+
bigInteger: Number.MAX_SAFE_INTEGER,
|
|
8
|
+
bigint: Number.MAX_SAFE_INTEGER
|
|
9
|
+
}, f = /* @__PURE__ */ new Set([
|
|
10
|
+
...Object.keys(o),
|
|
11
|
+
"decimal",
|
|
12
|
+
"float",
|
|
13
|
+
"double",
|
|
14
|
+
"real",
|
|
15
|
+
"numeric",
|
|
16
|
+
"money",
|
|
17
|
+
"smallmoney",
|
|
18
|
+
"number"
|
|
19
|
+
]);
|
|
20
|
+
function m(e) {
|
|
21
|
+
return e != null && Object.hasOwn(o, e);
|
|
22
|
+
}
|
|
23
|
+
function b(e, n = {}) {
|
|
24
|
+
const r = n.label ?? "Value";
|
|
25
|
+
if (e == null || typeof e == "string" && e.trim() === "")
|
|
26
|
+
return { ok: !0, value: null };
|
|
27
|
+
const i = typeof e == "number" ? e : Number(e);
|
|
28
|
+
if (Number.isNaN(i)) return { ok: !1, message: `${r} must be a number` };
|
|
29
|
+
const t = m(n.type) ? o[n.type] : Number.MAX_SAFE_INTEGER;
|
|
30
|
+
return !Number.isFinite(i) || Math.abs(i) > t ? { ok: !1, message: `${r} can't be more than ${t.toLocaleString("en-US")}` } : m(n.type) && !Number.isInteger(i) ? { ok: !1, message: `${r} must be a whole number` } : n.min !== void 0 && i < n.min ? {
|
|
31
|
+
ok: !1,
|
|
32
|
+
message: n.min === 0 ? `${r} can't be negative` : `${r} can't be below ${n.min}`
|
|
33
|
+
} : { ok: !0, value: i };
|
|
34
|
+
}
|
|
35
|
+
function g(e, n, r, i = {}) {
|
|
36
|
+
const t = { ...e, ...n };
|
|
37
|
+
for (const u of r)
|
|
38
|
+
e[u] != null && e[u] !== "" && (t[u] = e[u]);
|
|
39
|
+
for (const [u, s] of Object.entries(i)) {
|
|
40
|
+
const l = c(s, t);
|
|
41
|
+
l !== null && (t[u] = l);
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
function N(e, n, r) {
|
|
46
|
+
const i = {};
|
|
47
|
+
for (const [t, u] of Object.entries(e))
|
|
48
|
+
r.has(t) && (n && t !== "_change_reason" && String(u ?? "") === String(n[t] ?? "") || (i[t] = u));
|
|
49
|
+
return i;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
f as NUMBER_FIELD_TYPES,
|
|
53
|
+
N as changedRowFields,
|
|
54
|
+
b as checkNumberEntry,
|
|
55
|
+
m as isIntegerFieldType,
|
|
56
|
+
g as mergePendingQtyRow
|
|
57
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { titleCase as y } from "../../lib/utils.js";
|
|
2
|
+
function S(n, i) {
|
|
3
|
+
const r = /* @__PURE__ */ new Map();
|
|
4
|
+
for (const o of n) {
|
|
5
|
+
const s = i(o).trim().toLowerCase(), a = r.get(s);
|
|
6
|
+
a ? a.push(String(o.id)) : r.set(s, [String(o.id)]);
|
|
7
|
+
}
|
|
8
|
+
return [...r.values()].filter((o) => o.length > 1).flat();
|
|
9
|
+
}
|
|
10
|
+
const b = /* @__PURE__ */ new Set([
|
|
11
|
+
"id",
|
|
12
|
+
"sort",
|
|
13
|
+
"date_created",
|
|
14
|
+
"date_updated",
|
|
15
|
+
"user_created",
|
|
16
|
+
"user_updated",
|
|
17
|
+
"created_at",
|
|
18
|
+
"updated_at",
|
|
19
|
+
"created_by",
|
|
20
|
+
"updated_by"
|
|
21
|
+
]), m = /(^|_)(system_id|code|number|no|key|name|type|status)$/i;
|
|
22
|
+
function p(n) {
|
|
23
|
+
if (n == null || typeof n == "object") return null;
|
|
24
|
+
const i = String(n).trim();
|
|
25
|
+
return i === "" ? null : i;
|
|
26
|
+
}
|
|
27
|
+
function w(n, i = []) {
|
|
28
|
+
const r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([...b, ...i]);
|
|
29
|
+
for (const s of n) {
|
|
30
|
+
if (s.length < 2) continue;
|
|
31
|
+
const a = [...new Set(s.flatMap((t) => Object.keys(t)))].filter(
|
|
32
|
+
(t) => !o.has(t) && !t.startsWith("_")
|
|
33
|
+
);
|
|
34
|
+
let e = null;
|
|
35
|
+
for (const t of a) {
|
|
36
|
+
const c = s.map((d) => p(d[t]));
|
|
37
|
+
if (c.some((d) => d === null)) continue;
|
|
38
|
+
const u = new Set(c).size;
|
|
39
|
+
if (u < 2) continue;
|
|
40
|
+
const f = m.test(t), l = s.some((d) => typeof d[t] == "string");
|
|
41
|
+
(!e || u > e.distinct || u === e.distinct && (f !== e.preferred ? f : l && !e.text)) && (e = { key: t, distinct: u, preferred: f, text: l });
|
|
42
|
+
}
|
|
43
|
+
for (const t of s) {
|
|
44
|
+
const c = String(t.id);
|
|
45
|
+
r.set(c, e ? `${y(e.key)}: ${p(t[e.key])}` : `#${c}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return r;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
S as collidingIds,
|
|
52
|
+
w as disambiguators
|
|
53
|
+
};
|