@nivaro/react 0.3.58 → 0.3.59

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 (43) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +32 -1
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2083 -2052
  8. package/dist/shared/components/DataTable.js +497 -465
  9. package/dist/shared/components/ItemEditForm.js +4430 -4282
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/QueryTable.js +74 -74
  12. package/dist/shared/components/WidgetSlot.js +543 -520
  13. package/dist/shared/components/alerts/AlertManagerView.js +269 -275
  14. package/dist/shared/components/alerts/types.js +37 -14
  15. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  16. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  17. package/dist/shared/components/item-edit/InlineTableField.js +2461 -2421
  18. package/dist/shared/components/item-edit/M2MCombobox.js +141 -137
  19. package/dist/shared/components/item-edit/PlanGrid.js +876 -820
  20. package/dist/shared/components/item-edit/QuickCreateButton.js +323 -130
  21. package/dist/shared/components/item-edit/RelationCombobox.js +408 -375
  22. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +255 -156
  23. package/dist/shared/components/item-edit/SummaryPanel.js +356 -343
  24. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  25. package/dist/shared/components/item-edit/line-midair.js +82 -75
  26. package/dist/shared/components/item-edit/save-outcome.js +6 -4
  27. package/dist/shared/components/panels/ItemLockBanner.js +212 -209
  28. package/dist/shared/components/panels/PipelinePanel.js +775 -737
  29. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  30. package/dist/shared/components/panels/RevisionsPanel.js +313 -299
  31. package/dist/shared/components/pipeline/PipelineEditorView.js +26 -16
  32. package/dist/shared/components/queue/QueueQuickFilters.js +13 -13
  33. package/dist/shared/components/queue/QueueWorklist.js +978 -953
  34. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  35. package/dist/shared/components/widgets/ReviewListWidget.js +152 -149
  36. package/dist/shared/lib/display-prefs.js +60 -52
  37. package/dist/shared/lib/draft-store.js +71 -48
  38. package/dist/shared/lib/expression.js +53 -53
  39. package/dist/shared/lib/list-page-memory.js +42 -20
  40. package/dist/shared/lib/money-input.js +45 -0
  41. package/dist/shared/lib/sanitize-html.js +10 -6
  42. package/dist/shared/lib/staged-row-labels.js +18 -0
  43. package/package.json +1 -1
@@ -1,151 +1,181 @@
1
- import { jsx as r, jsxs as d } from "react/jsx-runtime";
2
- import { useState as L } from "react";
3
- import { useRelationOptions as F } from "../../hooks/useRelationOptions.js";
4
- import { useOptionalNivaroClient as R } from "../../shared/context.js";
5
- function _({
1
+ import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
+ import { useState as k, useEffect as F } from "react";
3
+ import { useRelationOptions as M, renderLabel as U } from "../../hooks/useRelationOptions.js";
4
+ import { get as P } from "../../lib/commands.js";
5
+ import { useOptionalNivaroClient as _ } from "../../shared/context.js";
6
+ import { relatedMissing as R } from "../../shared/components/item-edit/related-missing.js";
7
+ function z(e, t, o, a, s) {
8
+ const [l, v] = k(null), c = `${t}|${o}`;
9
+ return F(() => {
10
+ if (!e || !t || !o || a) return;
11
+ let p = !0;
12
+ return e.request(
13
+ P(`/items/${t}/${encodeURIComponent(o)}`)
14
+ ).then((u) => {
15
+ if (!p) return;
16
+ const g = u == null ? void 0 : u.data;
17
+ v({
18
+ key: c,
19
+ text: g ? U(g, s, "") || "Unnamed record" : R(null).text
20
+ });
21
+ }).catch((u) => {
22
+ p && v({ key: c, text: R(u).text });
23
+ }), () => {
24
+ p = !1;
25
+ };
26
+ }, [e, t, o, a, s, c]), !o || a ? null : (l == null ? void 0 : l.key) === c ? l.text : "Loading…";
27
+ }
28
+ function Q({
6
29
  field: e,
7
- value: n,
8
- onChange: u,
9
- error: l,
10
- disabled: o,
11
- readOnly: c,
12
- inputId: T,
13
- errorId: p
30
+ value: t,
31
+ onChange: o,
32
+ error: a,
33
+ disabled: s,
34
+ readOnly: l,
35
+ inputId: v,
36
+ errorId: c
14
37
  }) {
15
- var C, f, x;
16
- const b = R(), [h, m] = L(""), v = ((C = e.relation) == null ? void 0 : C.relatedCollection) ?? "", {
17
- options: S,
18
- loading: y,
19
- error: s
20
- } = F(b, v, {
21
- search: h || void 0,
22
- displayTemplate: ((f = e.relation) == null ? void 0 : f.displayTemplate) ?? null,
23
- enabled: !!v
24
- }), g = T ?? e.field, q = (e.fieldType === "relation-o2m" || e.fieldType === "relation-m2m") && ((x = e.options) == null ? void 0 : x.max_values) === 1, j = (e.fieldType === "relation-o2m" || e.fieldType === "relation-m2m") && !q;
25
- if (!b)
38
+ var j, A, N, $;
39
+ const p = _(), [u, g] = k(""), S = ((j = e.relation) == null ? void 0 : j.relatedCollection) ?? "", {
40
+ options: y,
41
+ loading: b,
42
+ error: h
43
+ } = M(p, S, {
44
+ search: u || void 0,
45
+ displayTemplate: ((A = e.relation) == null ? void 0 : A.displayTemplate) ?? null,
46
+ enabled: !!S
47
+ }), f = v ?? e.field, q = (e.fieldType === "relation-o2m" || e.fieldType === "relation-m2m") && ((N = e.options) == null ? void 0 : N.max_values) === 1, C = (e.fieldType === "relation-o2m" || e.fieldType === "relation-m2m") && !q, x = C || q ? "" : t != null && typeof t == "object" ? String(t.id ?? "") : t == null ? "" : String(t), w = !x || b || y.some((n) => String(n.id) === x), L = z(
48
+ p,
49
+ S,
50
+ x,
51
+ w,
52
+ ($ = e.relation) == null ? void 0 : $.displayTemplate
53
+ );
54
+ if (!p)
26
55
  return /* @__PURE__ */ r("span", { role: "alert", "data-nivaro-field-error": !0, children: "No NivaroClient available — wrap in <NivaroProvider> or pass a client prop." });
27
- if (!v)
56
+ if (!S)
28
57
  return /* @__PURE__ */ r(
29
58
  "input",
30
59
  {
31
60
  type: "text",
32
- id: g,
61
+ id: f,
33
62
  name: e.field,
34
- value: n == null ? "" : String(n),
35
- disabled: o,
36
- readOnly: c,
63
+ value: t == null ? "" : String(t),
64
+ disabled: s,
65
+ readOnly: l,
37
66
  "aria-required": e.required,
38
- "aria-invalid": l != null && l.length > 0,
39
- "aria-describedby": p,
40
- onChange: (i) => u(i.target.value)
67
+ "aria-invalid": a != null && a.length > 0,
68
+ "aria-describedby": c,
69
+ onChange: (n) => o(n.target.value)
41
70
  }
42
71
  );
43
72
  if (q) {
44
- const i = Array.isArray(n) ? n : n != null ? [n] : [], a = i.length > 0 ? i[0] != null && typeof i[0] == "object" ? String(i[0].id ?? "") : String(i[0]) : "";
45
- return /* @__PURE__ */ d("div", { children: [
73
+ const n = Array.isArray(t) ? t : t != null ? [t] : [], i = n.length > 0 ? n[0] != null && typeof n[0] == "object" ? String(n[0].id ?? "") : String(n[0]) : "";
74
+ return /* @__PURE__ */ m("div", { children: [
46
75
  /* @__PURE__ */ r(
47
76
  "input",
48
77
  {
49
78
  type: "search",
50
79
  placeholder: "Search…",
51
- value: h,
52
- disabled: o || c,
53
- onChange: (t) => m(t.target.value)
80
+ value: u,
81
+ disabled: s || l,
82
+ onChange: (d) => g(d.target.value)
54
83
  }
55
84
  ),
56
- /* @__PURE__ */ d(
85
+ /* @__PURE__ */ m(
57
86
  "select",
58
87
  {
59
- id: g,
88
+ id: f,
60
89
  name: e.field,
61
90
  required: e.required,
62
- disabled: o || c,
63
- value: a,
91
+ disabled: s || l,
92
+ value: i,
64
93
  "aria-required": e.required,
65
- "aria-invalid": l != null && l.length > 0,
66
- "aria-describedby": p,
67
- onChange: (t) => u(t.target.value === "" ? [] : [t.target.value]),
94
+ "aria-invalid": a != null && a.length > 0,
95
+ "aria-describedby": c,
96
+ onChange: (d) => o(d.target.value === "" ? [] : [d.target.value]),
68
97
  children: [
69
98
  /* @__PURE__ */ r("option", { value: "", children: "—" }),
70
- S.map((t) => /* @__PURE__ */ r("option", { value: String(t.id), children: t.label }, String(t.id)))
99
+ y.map((d) => /* @__PURE__ */ r("option", { value: String(d.id), children: d.label }, String(d.id)))
71
100
  ]
72
101
  }
73
102
  ),
74
- y ? /* @__PURE__ */ r("span", { "aria-live": "polite", children: "Loading…" }) : null,
75
- s ? /* @__PURE__ */ r("span", { role: "alert", children: s.message }) : null
103
+ b ? /* @__PURE__ */ r("span", { "aria-live": "polite", children: "Loading…" }) : null,
104
+ h ? /* @__PURE__ */ r("span", { role: "alert", children: h.message }) : null
76
105
  ] });
77
106
  }
78
- if (j) {
79
- const i = Array.isArray(n) ? n.map(
80
- (a) => a != null && typeof a == "object" ? String(a.id) : String(a)
107
+ if (C) {
108
+ const n = Array.isArray(t) ? t.map(
109
+ (i) => i != null && typeof i == "object" ? String(i.id) : String(i)
81
110
  ) : [];
82
- return /* @__PURE__ */ d("div", { children: [
111
+ return /* @__PURE__ */ m("div", { children: [
83
112
  /* @__PURE__ */ r(
84
113
  "input",
85
114
  {
86
115
  type: "search",
87
116
  placeholder: "Search…",
88
- value: h,
89
- disabled: o || c,
90
- onChange: (a) => m(a.target.value)
117
+ value: u,
118
+ disabled: s || l,
119
+ onChange: (i) => g(i.target.value)
91
120
  }
92
121
  ),
93
122
  /* @__PURE__ */ r(
94
123
  "select",
95
124
  {
96
- id: g,
125
+ id: f,
97
126
  name: e.field,
98
127
  multiple: !0,
99
- disabled: o || c,
100
- value: i,
128
+ disabled: s || l,
129
+ value: n,
101
130
  "aria-required": e.required,
102
- "aria-invalid": l != null && l.length > 0,
103
- "aria-describedby": p,
104
- onChange: (a) => {
105
- const t = Array.from(a.target.selectedOptions).map((N) => N.value);
106
- u(t);
131
+ "aria-invalid": a != null && a.length > 0,
132
+ "aria-describedby": c,
133
+ onChange: (i) => {
134
+ const d = Array.from(i.target.selectedOptions).map((E) => E.value);
135
+ o(d);
107
136
  },
108
- children: S.map((a) => /* @__PURE__ */ r("option", { value: String(a.id), children: a.label }, String(a.id)))
137
+ children: y.map((i) => /* @__PURE__ */ r("option", { value: String(i.id), children: i.label }, String(i.id)))
109
138
  }
110
139
  ),
111
- y ? /* @__PURE__ */ r("span", { "aria-live": "polite", children: "Loading…" }) : null,
112
- s ? /* @__PURE__ */ r("span", { role: "alert", children: s.message }) : null
140
+ b ? /* @__PURE__ */ r("span", { "aria-live": "polite", children: "Loading…" }) : null,
141
+ h ? /* @__PURE__ */ r("span", { role: "alert", children: h.message }) : null
113
142
  ] });
114
143
  }
115
- const A = n != null && typeof n == "object" ? String(n.id ?? "") : n == null ? "" : String(n);
116
- return /* @__PURE__ */ d("div", { children: [
144
+ const T = t != null && typeof t == "object" ? String(t.id ?? "") : t == null ? "" : String(t);
145
+ return /* @__PURE__ */ m("div", { children: [
117
146
  /* @__PURE__ */ r(
118
147
  "input",
119
148
  {
120
149
  type: "search",
121
150
  placeholder: "Search…",
122
- value: h,
123
- disabled: o || c,
124
- onChange: (i) => m(i.target.value)
151
+ value: u,
152
+ disabled: s || l,
153
+ onChange: (n) => g(n.target.value)
125
154
  }
126
155
  ),
127
- /* @__PURE__ */ d(
156
+ /* @__PURE__ */ m(
128
157
  "select",
129
158
  {
130
- id: g,
159
+ id: f,
131
160
  name: e.field,
132
161
  required: e.required,
133
- disabled: o || c,
134
- value: A,
162
+ disabled: s || l,
163
+ value: T,
135
164
  "aria-required": e.required,
136
- "aria-invalid": l != null && l.length > 0,
137
- "aria-describedby": p,
138
- onChange: (i) => u(i.target.value === "" ? null : i.target.value),
165
+ "aria-invalid": a != null && a.length > 0,
166
+ "aria-describedby": c,
167
+ onChange: (n) => o(n.target.value === "" ? null : n.target.value),
139
168
  children: [
140
169
  /* @__PURE__ */ r("option", { value: "", children: "—" }),
141
- S.map((i) => /* @__PURE__ */ r("option", { value: String(i.id), children: i.label }, String(i.id)))
170
+ L != null && /* @__PURE__ */ r("option", { value: T, "data-nivaro-current-unlisted": !0, children: L }),
171
+ y.map((n) => /* @__PURE__ */ r("option", { value: String(n.id), children: n.label }, String(n.id)))
142
172
  ]
143
173
  }
144
174
  ),
145
- y ? /* @__PURE__ */ r("span", { "aria-live": "polite", children: "Loading…" }) : null,
146
- s ? /* @__PURE__ */ r("span", { role: "alert", children: s.message }) : null
175
+ b ? /* @__PURE__ */ r("span", { "aria-live": "polite", children: "Loading…" }) : null,
176
+ h ? /* @__PURE__ */ r("span", { role: "alert", children: h.message }) : null
147
177
  ] });
148
178
  }
149
179
  export {
150
- _ as RelationField
180
+ Q as RelationField
151
181
  };