@nivaro/react 0.3.35 → 0.3.37
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/components/slots/CommentsSlot.js +44 -36
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/shared/components/AgentBadge.js +26 -0
- package/dist/shared/components/AgentQuestionsCard.js +198 -0
- package/dist/shared/components/ItemEditForm.js +3329 -3263
- package/dist/shared/components/McpConnectionScope.js +480 -0
- package/dist/shared/components/MyWorkView.js +223 -208
- package/dist/shared/components/RecordReadView.js +620 -572
- package/dist/shared/components/chat/ChatPanel.js +683 -671
- package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
- package/dist/shared/components/imports/ImportConsole.js +106 -104
- package/dist/shared/components/imports/RunDetailSheet.js +11 -10
- package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
- package/dist/shared/components/item-edit/FormTour.js +279 -0
- package/dist/shared/components/item-edit/GroupSection.js +377 -360
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +80 -63
- package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
- package/dist/shared/components/item-edit/form-density.js +36 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
- package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
- package/dist/shared/components/layout-editor/AddPanel.js +349 -192
- package/dist/shared/components/layout-editor/DesignNode.js +146 -131
- package/dist/shared/components/layout-editor/EditorCanvas.js +25 -17
- package/dist/shared/components/layout-editor/EditorTopBar.js +268 -206
- package/dist/shared/components/layout-editor/LayoutEditor.js +810 -731
- package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
- package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
- package/dist/shared/components/layout-editor/add-target.js +54 -43
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +379 -185
- package/dist/shared/components/layout-editor/dnd/TrashZone.js +96 -0
- package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
- package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
- package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
- package/dist/shared/components/layout-editor/dnd/node.js +115 -105
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +4 -4
- package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
- package/dist/shared/components/layout-editor/dnd/trash-drop.js +58 -0
- package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
- package/dist/shared/components/layout-editor/even-row.js +86 -0
- package/dist/shared/components/layout-editor/field-list.js +99 -0
- package/dist/shared/components/layout-editor/format-painter.js +102 -0
- package/dist/shared/components/layout-editor/grid-guides.js +15 -13
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
- package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
- package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
- package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
- package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
- package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
- package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
- package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
- package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
- package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
- package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
- package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
- package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
- package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
- package/dist/shared/components/layout-editor/panel-frame.js +1 -1
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/personal-default-marks.js +40 -0
- package/dist/shared/components/layout-editor/pin.js +37 -19
- package/dist/shared/components/layout-editor/place-clip.js +257 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +149 -118
- package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
- package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
- package/dist/shared/components/layout-editor/removed-log.js +151 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
- package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
- package/dist/shared/components/layout-editor/revert-element.js +140 -0
- package/dist/shared/components/layout-editor/section-structure.js +193 -170
- package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
- package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
- package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
- package/dist/shared/components/layout-editor/shortcuts.js +21 -16
- package/dist/shared/components/layout-editor/structure-ops.js +221 -195
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
- package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
- package/dist/shared/components/panels/CommentPanel.js +47 -45
- package/dist/shared/components/panels/RevisionsPanel.js +66 -64
- package/dist/shared/components/panels/TaskPanel.js +395 -332
- package/dist/shared/components/profile/AgentsPanel.js +196 -147
- package/dist/shared/components/profile/ConnectionRollback.js +329 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
- package/dist/shared/lib/entry-config.js +22 -22
- package/dist/shared/lib/form-usage-beacon.js +91 -55
- package/dist/shared/lib/layout-lint.js +530 -284
- package/dist/shared/lib/layout-resolve.js +58 -44
- package/package.json +1 -1
|
@@ -3,55 +3,69 @@ const k = {
|
|
|
3
3
|
desktop: null,
|
|
4
4
|
tablet: 768,
|
|
5
5
|
phone: 390
|
|
6
|
-
}
|
|
6
|
+
}, v = {
|
|
7
|
+
desktop: 1024,
|
|
8
|
+
tablet: 768,
|
|
9
|
+
phone: 390
|
|
10
|
+
}, g = ["desktop", "tablet", "phone"], C = {
|
|
11
|
+
desktop: "Desktop",
|
|
12
|
+
tablet: "Tablet",
|
|
13
|
+
phone: "Phone"
|
|
14
|
+
}, b = 16;
|
|
15
|
+
function D(e, t = 1) {
|
|
16
|
+
if (e === "all")
|
|
17
|
+
return t === 2 ? null : g.reduce((o, s) => o + v[s], 0) + b * 4 + g.length * 2;
|
|
18
|
+
const n = k[e ?? "desktop"];
|
|
19
|
+
return n == null ? null : (n + 2) * t;
|
|
20
|
+
}
|
|
7
21
|
function u(e) {
|
|
8
22
|
if (e == null || e === "") return [];
|
|
9
23
|
try {
|
|
10
|
-
const
|
|
11
|
-
return Array.isArray(
|
|
24
|
+
const t = typeof e == "string" ? JSON.parse(e) : e;
|
|
25
|
+
return Array.isArray(t) ? t.map((n) => String(n).toUpperCase()) : [];
|
|
12
26
|
} catch {
|
|
13
27
|
return [];
|
|
14
28
|
}
|
|
15
29
|
}
|
|
16
|
-
function
|
|
30
|
+
function S(e) {
|
|
17
31
|
if (e == null || e === "") return [];
|
|
18
32
|
try {
|
|
19
|
-
const
|
|
20
|
-
return Array.isArray(
|
|
33
|
+
const t = typeof e == "string" ? JSON.parse(e) : e;
|
|
34
|
+
return Array.isArray(t) ? t.flatMap(
|
|
21
35
|
(n) => (n == null ? void 0 : n.type) === "role" && Array.isArray(n.role_ids) ? n.role_ids.map((i) => String(i).toUpperCase()) : []
|
|
22
36
|
) : [];
|
|
23
37
|
} catch {
|
|
24
38
|
return [];
|
|
25
39
|
}
|
|
26
40
|
}
|
|
27
|
-
function a(e,
|
|
28
|
-
const n = String(e.role.id ?? "").toUpperCase(), i = e.role.admin_access,
|
|
41
|
+
function a(e, t) {
|
|
42
|
+
const n = String(e.role.id ?? "").toUpperCase(), i = e.role.admin_access, o = new Set(e.hidden_fields), s = new Set(e.readonly_fields), d = /* @__PURE__ */ new Map();
|
|
29
43
|
if (!i)
|
|
30
|
-
for (const l of
|
|
44
|
+
for (const l of t.groups) {
|
|
31
45
|
const f = l;
|
|
32
46
|
u(f.hidden_for_roles).includes(n) ? d.set(f.key, "hidden") : u(f.locked_for_roles).includes(n) && d.set(f.key, "locked");
|
|
33
47
|
}
|
|
34
48
|
const r = /* @__PURE__ */ new Map();
|
|
35
|
-
for (const l of
|
|
49
|
+
for (const l of t.assignments) {
|
|
36
50
|
if (l.field.startsWith("__")) continue;
|
|
37
51
|
const f = l.group_key ? d.get(l.group_key) : void 0;
|
|
38
52
|
let c;
|
|
39
|
-
!e.can_read ||
|
|
53
|
+
!e.can_read || o.has(l.field) || f === "hidden" ? c = "hidden" : !e.can_update || s.has(l.field) || f === "locked" || S(l.lock_conditions).includes(n) ? c = "readonly" : c = "editable";
|
|
40
54
|
const p = r.get(l.field);
|
|
41
|
-
(!p ||
|
|
55
|
+
(!p || _(c) > _(p)) && r.set(l.field, c);
|
|
42
56
|
}
|
|
43
57
|
return r;
|
|
44
58
|
}
|
|
45
|
-
const
|
|
59
|
+
const _ = (e) => e === "editable" ? 2 : e === "readonly" ? 1 : 0, y = {
|
|
46
60
|
hidden: "hidden",
|
|
47
61
|
readonly: "read-only",
|
|
48
62
|
editable: "can edit"
|
|
49
63
|
};
|
|
50
|
-
function
|
|
51
|
-
const i = a(
|
|
64
|
+
function E(e, t, n) {
|
|
65
|
+
const i = a(t, e), o = a(n, e), s = (r, l) => !r.role.admin_access && u(l).includes(String(r.role.id ?? "").toUpperCase()), d = /* @__PURE__ */ new Map();
|
|
52
66
|
for (const r of e.groups) {
|
|
53
|
-
const l = r.hidden_for_roles, f = s(
|
|
54
|
-
f !== c && d.set(r.key, `${f ?
|
|
67
|
+
const l = r.hidden_for_roles, f = s(t, l), c = s(n, l);
|
|
68
|
+
f !== c && d.set(r.key, `${f ? t.role.name : n.role.name} does not see this section`);
|
|
55
69
|
}
|
|
56
70
|
return (r) => {
|
|
57
71
|
if (r.kind === "group") {
|
|
@@ -59,99 +73,104 @@ function S(e, o, n) {
|
|
|
59
73
|
return c ? [{ text: "Differs", tone: "violet", tip: c, highlight: !0 }] : [];
|
|
60
74
|
}
|
|
61
75
|
if (r.kind !== "field" && r.kind !== "header") return [];
|
|
62
|
-
const l = i.get(r.field), f =
|
|
76
|
+
const l = i.get(r.field), f = o.get(r.field);
|
|
63
77
|
return !l || !f || l === f ? [] : [
|
|
64
78
|
{
|
|
65
79
|
text: "Differs",
|
|
66
80
|
tone: "violet",
|
|
67
|
-
tip: `${
|
|
81
|
+
tip: `${t.role.name}: ${y[l]} · ${n.role.name}: ${y[f]}`,
|
|
68
82
|
highlight: !0
|
|
69
83
|
}
|
|
70
84
|
];
|
|
71
85
|
};
|
|
72
86
|
}
|
|
73
|
-
function
|
|
87
|
+
function I(e, t) {
|
|
74
88
|
const n = /* @__PURE__ */ new Map();
|
|
75
89
|
for (const i of e)
|
|
76
|
-
for (const [
|
|
77
|
-
const d = n.get(
|
|
78
|
-
s === "editable" ? d.edit.push(i.role.name) : s === "readonly" ? d.read.push(i.role.name) : d.hidden.push(i.role.name), n.set(
|
|
90
|
+
for (const [o, s] of a(i, t)) {
|
|
91
|
+
const d = n.get(o) ?? { edit: [], read: [], hidden: [] };
|
|
92
|
+
s === "editable" ? d.edit.push(i.role.name) : s === "readonly" ? d.read.push(i.role.name) : d.hidden.push(i.role.name), n.set(o, d);
|
|
79
93
|
}
|
|
80
94
|
return n;
|
|
81
95
|
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
if (n ===
|
|
86
|
-
const i = n /
|
|
96
|
+
function w(e) {
|
|
97
|
+
const t = e.edit.length + e.read.length + e.hidden.length, n = e.edit.length + e.read.length;
|
|
98
|
+
if (t === 0 || n === 0) return "none";
|
|
99
|
+
if (n === t) return "all";
|
|
100
|
+
const i = n / t;
|
|
87
101
|
return i < 1 / 3 ? "few" : i < 2 / 3 ? "some" : "most";
|
|
88
102
|
}
|
|
89
|
-
function
|
|
103
|
+
function L(e, t) {
|
|
90
104
|
const n = [];
|
|
91
105
|
for (const i of e.assignments)
|
|
92
106
|
if (i.lock_conditions)
|
|
93
107
|
try {
|
|
94
|
-
const
|
|
95
|
-
Array.isArray(
|
|
108
|
+
const o = JSON.parse(i.lock_conditions);
|
|
109
|
+
Array.isArray(o) && o.some((s) => {
|
|
96
110
|
var d;
|
|
97
|
-
return (s == null ? void 0 : s.type) === "pipeline_state" && ((d = s.state_keys) == null ? void 0 : d.includes(
|
|
111
|
+
return (s == null ? void 0 : s.type) === "pipeline_state" && ((d = s.state_keys) == null ? void 0 : d.includes(t));
|
|
98
112
|
}) && n.push(i.field);
|
|
99
113
|
} catch {
|
|
100
114
|
}
|
|
101
115
|
return [...new Set(n)];
|
|
102
116
|
}
|
|
103
|
-
function
|
|
117
|
+
function M(e, t) {
|
|
104
118
|
const n = [];
|
|
105
119
|
for (const i of e)
|
|
106
|
-
if (!(i.from_state != null && i.from_state !==
|
|
107
|
-
for (const
|
|
108
|
-
const s = Array.isArray(
|
|
120
|
+
if (!(i.from_state != null && i.from_state !== t))
|
|
121
|
+
for (const o of i.requirements ?? []) {
|
|
122
|
+
const s = Array.isArray(o == null ? void 0 : o.fields) ? o.fields.map(String) : [];
|
|
109
123
|
s.length !== 0 && n.push({
|
|
110
124
|
label: i.label,
|
|
111
125
|
fields: s,
|
|
112
|
-
collection: typeof
|
|
126
|
+
collection: typeof o.collection == "string" && o.collection ? o.collection : null
|
|
113
127
|
});
|
|
114
128
|
}
|
|
115
129
|
return n;
|
|
116
130
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
131
|
+
function V(e) {
|
|
132
|
+
const t = /* @__PURE__ */ new Map();
|
|
119
133
|
for (const n of e.groups) {
|
|
120
134
|
const i = m(n.visible_when);
|
|
121
|
-
for (const
|
|
122
|
-
if (!
|
|
123
|
-
const s =
|
|
124
|
-
if (
|
|
125
|
-
for (const r of String(
|
|
135
|
+
for (const o of i) {
|
|
136
|
+
if (!o.field) continue;
|
|
137
|
+
const s = t.get(o.field) ?? { field: o.field, values: [], drives: [] };
|
|
138
|
+
if (o.op === "in")
|
|
139
|
+
for (const r of String(o.value ?? "").split(","))
|
|
126
140
|
r.trim() && !s.values.includes(r.trim()) && s.values.push(r.trim());
|
|
127
|
-
if ((
|
|
128
|
-
const r = String(
|
|
141
|
+
if ((o.op ?? "eq") === "eq" || o.op === "neq") {
|
|
142
|
+
const r = String(o.value ?? "");
|
|
129
143
|
r && !s.values.includes(r) && s.values.push(r);
|
|
130
144
|
}
|
|
131
145
|
const d = n.label || n.key;
|
|
132
|
-
s.drives.includes(d) || s.drives.push(d),
|
|
146
|
+
s.drives.includes(d) || s.drives.push(d), t.set(o.field, s);
|
|
133
147
|
}
|
|
134
148
|
}
|
|
135
|
-
return [...
|
|
149
|
+
return [...t.values()].sort((n, i) => n.field.localeCompare(i.field));
|
|
136
150
|
}
|
|
137
|
-
function
|
|
138
|
-
const i = [],
|
|
151
|
+
function W(e, t, n) {
|
|
152
|
+
const i = [], o = [];
|
|
139
153
|
for (const s of e.groups) {
|
|
140
154
|
const d = s.visible_when;
|
|
141
155
|
if (m(d).length === 0) continue;
|
|
142
|
-
const r = h(d,
|
|
143
|
-
r !== l && (l ? i :
|
|
156
|
+
const r = h(d, t), l = h(d, n);
|
|
157
|
+
r !== l && (l ? i : o).push(s.key);
|
|
144
158
|
}
|
|
145
|
-
return { shown: i, hidden:
|
|
159
|
+
return { shown: i, hidden: o };
|
|
146
160
|
}
|
|
147
161
|
export {
|
|
162
|
+
b as ALL_DEVICE_GAP,
|
|
163
|
+
v as ALL_DEVICE_WIDTH,
|
|
164
|
+
C as DEVICE_LABEL,
|
|
165
|
+
g as DEVICE_ORDER,
|
|
148
166
|
k as DEVICE_WIDTH,
|
|
149
|
-
|
|
150
|
-
|
|
167
|
+
E as compareMarks,
|
|
168
|
+
V as drivingFields,
|
|
151
169
|
a as fieldAccessForRole,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
D as
|
|
155
|
-
|
|
156
|
-
|
|
170
|
+
L as fieldsLockedInState,
|
|
171
|
+
M as leavingNeeds,
|
|
172
|
+
D as previewNaturalWidth,
|
|
173
|
+
W as visibilityChanges,
|
|
174
|
+
I as whoSeesFields,
|
|
175
|
+
w as whoTint
|
|
157
176
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { relKindOf as C, asObject as $, asArray as A } from "../inspector/model.js";
|
|
2
|
+
function T(n) {
|
|
3
|
+
let t = n >>> 0;
|
|
4
|
+
return () => {
|
|
5
|
+
t = t + 1831565813 >>> 0;
|
|
6
|
+
let e = t;
|
|
7
|
+
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const a = (n, t) => t[Math.floor(n() * t.length)], u = (n, t, e) => t + Math.floor(n() * (e - t + 1)), k = ["Jordan", "Sam", "Priya", "Alex", "Morgan", "Taylor", "Riley", "Casey", "Jamie"], v = ["Lee", "Patel", "Nguyen", "Garcia", "Smith", "Okafor", "Kim", "Rossi", "Brown"], w = ["Northwind", "Contoso", "Fabrikam", "Tailspin", "Litware", "Adatum", "Proseware"], L = ["Philadelphia", "Denver", "Atlanta", "Seattle", "Austin", "Chicago", "Boston"], E = ["Market St", "Oak Ave", "Maple Dr", "Main St", "Cedar Ln", "Park Blvd"], I = ["PA", "CO", "GA", "WA", "TX", "IL", "MA"], O = ["order", "request", "project", "site visit", "renewal", "upgrade", "review"], S = ["Quarterly", "Annual", "Urgent", "Planned", "Regional", "Standard", "Follow-up"], x = [
|
|
11
|
+
"Waiting on the vendor to confirm the delivery date.",
|
|
12
|
+
"Reviewed with the team; no changes needed this round.",
|
|
13
|
+
"Second quote came in lower, so we went with it.",
|
|
14
|
+
"Needs sign-off before the end of the month.",
|
|
15
|
+
"Scheduled for the next maintenance window.",
|
|
16
|
+
"Customer asked for an update by Friday."
|
|
17
|
+
], M = /* @__PURE__ */ new Set([
|
|
18
|
+
"id",
|
|
19
|
+
"user_created",
|
|
20
|
+
"user_updated",
|
|
21
|
+
"date_created",
|
|
22
|
+
"date_updated",
|
|
23
|
+
"created_at",
|
|
24
|
+
"updated_at",
|
|
25
|
+
"created_by",
|
|
26
|
+
"updated_by",
|
|
27
|
+
"sort"
|
|
28
|
+
]), F = /* @__PURE__ */ new Set([
|
|
29
|
+
"select-multiple-dropdown",
|
|
30
|
+
"select-multiple-checkbox",
|
|
31
|
+
"checkboxes",
|
|
32
|
+
"tags",
|
|
33
|
+
"select-multiple"
|
|
34
|
+
]), R = /* @__PURE__ */ new Set(["integer", "bigInteger", "smallint", "tinyint", "bigint"]), N = /* @__PURE__ */ new Set(["decimal", "float", "money", "smallmoney", "double", "numeric"]), P = /* @__PURE__ */ new Set(["file", "file-image", "files", "files-m2m", "image"]);
|
|
35
|
+
function D(n) {
|
|
36
|
+
const t = $(n.options);
|
|
37
|
+
return A(t.choices).map((e) => e && typeof e == "object" ? e.value : e).filter((e) => e != null && e !== "");
|
|
38
|
+
}
|
|
39
|
+
const s = (n, ...t) => t.some((e) => n.includes(e));
|
|
40
|
+
function y(n, t) {
|
|
41
|
+
const e = n.toISOString();
|
|
42
|
+
return t ? `${e.slice(0, 19)}Z` : e.slice(0, 10);
|
|
43
|
+
}
|
|
44
|
+
function b(n, t, e, o) {
|
|
45
|
+
const l = a(e, k), c = a(e, v);
|
|
46
|
+
return s(n, "email") ? `${l}.${c}@example.com`.toLowerCase() : s(n, "phone", "mobile", "fax") ? `(555) ${String(u(e, 100, 999))}-${String(u(e, 1e3, 9999))}` : s(n, "first_name", "firstname", "given") ? l : s(n, "last_name", "lastname", "surname", "family") ? c : s(n, "company", "vendor", "supplier", "customer", "organization", "org") ? `${a(e, w)} ${a(e, ["Inc.", "LLC", "Co.", "Group"])}` : s(n, "name", "owner", "contact", "person", "manager", "assignee") ? `${l} ${c}` : s(n, "city", "town") ? a(e, L) : s(n, "state", "province", "region") ? a(e, I) : s(n, "zip", "postal") ? String(u(e, 1e4, 99999)) : s(n, "country") ? "United States" : s(n, "street", "address") ? `${u(e, 10, 9999)} ${a(e, E)}` : s(n, "url", "website", "link", "site") ? `https://www.${a(e, w).toLowerCase()}.example` : s(n, "code", "number", "ref", "sku", "po", "invoice", "ticket") ? `${t.replace(/[^A-Za-z]/g, "").slice(0, 3).toUpperCase() || "REF"}-${u(e, 1e3, 9999)}` : s(n, "title", "subject", "summary", "headline") ? `${a(e, S)} ${a(e, O)}` : o || s(n, "note", "description", "comment", "detail", "reason", "message", "body") ? a(e, x) : `${a(e, S)} ${t.toLowerCase()}`;
|
|
47
|
+
}
|
|
48
|
+
function j(n) {
|
|
49
|
+
var l;
|
|
50
|
+
const t = T(n.seed), e = n.now ?? /* @__PURE__ */ new Date(), o = {};
|
|
51
|
+
for (const c of n.fields) {
|
|
52
|
+
const i = c.field;
|
|
53
|
+
if (!i || i.startsWith("__") || i.includes(".") || M.has(i) || c.computed_type) continue;
|
|
54
|
+
const h = String(c.interface ?? ""), r = String(c.type ?? "string"), p = C(i, n.relations);
|
|
55
|
+
if (p === "O2M" || p === "M2M" || r === "alias" || P.has(h)) continue;
|
|
56
|
+
const d = i.toLowerCase(), g = String(c.label || i.replace(/_/g, " "));
|
|
57
|
+
if (p === "M2O") {
|
|
58
|
+
const m = ((l = n.relatedIds) == null ? void 0 : l[i]) ?? [];
|
|
59
|
+
m.length && (o[i] = a(t, m));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const f = D(c);
|
|
63
|
+
if (f.length) {
|
|
64
|
+
if (F.has(h) || r === "csv" || r === "json") {
|
|
65
|
+
const m = Math.min(f.length, u(t, 1, 2)), _ = [...f].sort(() => t() - 0.5);
|
|
66
|
+
o[i] = _.slice(0, m);
|
|
67
|
+
} else o[i] = a(t, f);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (r === "boolean") o[i] = t() < 0.5;
|
|
71
|
+
else if (R.has(r))
|
|
72
|
+
o[i] = s(d, "year") ? e.getUTCFullYear() : u(t, 1, s(d, "qty", "quantity", "count") ? 50 : 500);
|
|
73
|
+
else if (N.has(r)) o[i] = Math.round((10 + t() * 9990) * 100) / 100;
|
|
74
|
+
else if (r === "date")
|
|
75
|
+
o[i] = y(new Date(e.getTime() + u(t, -60, 60) * 864e5), !1);
|
|
76
|
+
else if (r === "dateTime" || r === "timestamp" || r === "datetime")
|
|
77
|
+
o[i] = y(
|
|
78
|
+
new Date(e.getTime() + u(t, -60, 60) * 864e5 + u(t, 8, 17) * 36e5),
|
|
79
|
+
!0
|
|
80
|
+
);
|
|
81
|
+
else if (r === "time")
|
|
82
|
+
o[i] = `${String(u(t, 8, 17)).padStart(2, "0")}:${a(t, ["00", "15", "30", "45"])}:00`;
|
|
83
|
+
else {
|
|
84
|
+
if (r === "uuid" || r === "json" || r === "binary" || r === "geometry")
|
|
85
|
+
continue;
|
|
86
|
+
r === "text" ? o[i] = b(d, g, t, !0) : o[i] = b(d, g, t, !1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return o;
|
|
90
|
+
}
|
|
91
|
+
function q(n, t) {
|
|
92
|
+
var o;
|
|
93
|
+
const e = [];
|
|
94
|
+
for (const l of n) {
|
|
95
|
+
if (M.has(l.field) || l.computed_type || C(l.field, t) !== "M2O") continue;
|
|
96
|
+
const c = (o = t.find((i) => i.many_field === l.field)) == null ? void 0 : o.one_collection;
|
|
97
|
+
!c || /^(nivaro|directus)_/.test(c) || e.push({ field: l.field, collection: c });
|
|
98
|
+
}
|
|
99
|
+
return e;
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
j as buildSampleRecord,
|
|
103
|
+
q as samplePickers,
|
|
104
|
+
T as seededRandom
|
|
105
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { useState as M, useRef as _, useCallback as P, useMemo as $ } from "react";
|
|
2
|
+
import { applyLayoutOps as K, UNGROUPED_KEY as U, HEADER_GROUP_KEY as h } from "../../lib/layout-ops.js";
|
|
3
|
+
import { titleCase as O } from "../../lib/utils.js";
|
|
4
|
+
import { fieldSpot as A } from "./add-target.js";
|
|
5
|
+
import { sectionLabel as v } from "./canvas-diff.js";
|
|
6
|
+
import { placementPatchOf as B } from "./inspector/model.js";
|
|
7
|
+
import { restorePieceOps as C } from "./restore-piece.js";
|
|
8
|
+
import { slotName as N } from "./slot-names.js";
|
|
9
|
+
import { refuse as R, checked as S } from "./structure-ops.js";
|
|
10
|
+
const W = 25;
|
|
11
|
+
let D = 0;
|
|
12
|
+
function Y(e, t, f, a = O) {
|
|
13
|
+
let n;
|
|
14
|
+
try {
|
|
15
|
+
n = K(e, t);
|
|
16
|
+
} catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
const l = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const r of t)
|
|
21
|
+
r.op === "group_remove" && r.key !== U && !n.groups.some((o) => o.key === r.key) && l.add(r.key);
|
|
22
|
+
const g = new Set(t.flatMap((r) => r.op === "place" ? [r.field] : [])), c = [], u = Date.now(), m = (r) => {
|
|
23
|
+
var i;
|
|
24
|
+
let o = r;
|
|
25
|
+
for (; o; ) {
|
|
26
|
+
if (l.has(o)) return !0;
|
|
27
|
+
o = ((i = e.groups.find((k) => k.key === o)) == null ? void 0 : i.parent_key) ?? null;
|
|
28
|
+
}
|
|
29
|
+
return !1;
|
|
30
|
+
};
|
|
31
|
+
for (const r of l) {
|
|
32
|
+
const o = e.groups.find((k) => k.key === r);
|
|
33
|
+
if (!o || m(o.parent_key)) continue;
|
|
34
|
+
const i = e.placements.filter((k) => k.group_key === r).length;
|
|
35
|
+
c.push({
|
|
36
|
+
id: `r${++D}`,
|
|
37
|
+
piece: { kind: "group", key: r },
|
|
38
|
+
label: o.label || O(o.key),
|
|
39
|
+
where: i ? `section · ${i} ${i === 1 ? "field" : "fields"}` : "section",
|
|
40
|
+
how: f,
|
|
41
|
+
before: e,
|
|
42
|
+
at: u
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
for (const r of t) {
|
|
46
|
+
if (r.op !== "remove") continue;
|
|
47
|
+
const o = r.at.group_key ?? null;
|
|
48
|
+
m(o) || g.has(r.at.field) || n.placements.some((i) => i.field === r.at.field && i.group_key === o) || e.placements.some((i) => i.field === r.at.field && i.group_key === o) && c.push({
|
|
49
|
+
id: `r${++D}`,
|
|
50
|
+
piece: { kind: "field", field: r.at.field, group_key: o },
|
|
51
|
+
label: r.at.field.startsWith("__") ? N(r.at.field) : a(r.at.field),
|
|
52
|
+
where: o === h ? "in the header strip" : `in ${v(e.groups, o)}`,
|
|
53
|
+
how: f,
|
|
54
|
+
before: e,
|
|
55
|
+
at: u
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return c;
|
|
59
|
+
}
|
|
60
|
+
function L(e, t) {
|
|
61
|
+
if (t.piece.kind === "group") {
|
|
62
|
+
const n = t.piece.key;
|
|
63
|
+
return !e.groups.some((l) => l.key === n);
|
|
64
|
+
}
|
|
65
|
+
const { field: f, group_key: a } = t.piece;
|
|
66
|
+
return !e.placements.some((n) => n.field === f && n.group_key === a);
|
|
67
|
+
}
|
|
68
|
+
function T(e, t, f) {
|
|
69
|
+
if (!L(e, t)) return R(`${t.label} is already on the form`);
|
|
70
|
+
try {
|
|
71
|
+
const a = C(e, t.before, t.piece);
|
|
72
|
+
return S(e, {
|
|
73
|
+
ok: !0,
|
|
74
|
+
ops: a,
|
|
75
|
+
label: `Put back ${t.label}`,
|
|
76
|
+
notes: [],
|
|
77
|
+
select: t.piece.kind === "group" ? { kind: "group", key: t.piece.key } : t.piece.group_key === h ? { kind: "header", field: t.piece.field } : {
|
|
78
|
+
kind: t.piece.field.startsWith("__") ? "slot" : "field",
|
|
79
|
+
field: t.piece.field,
|
|
80
|
+
group_key: t.piece.group_key
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} catch (a) {
|
|
84
|
+
if (t.piece.kind === "group") return R(a.message);
|
|
85
|
+
const { field: n, group_key: l } = t.piece, g = t.before.placements.find((u) => u.field === n && u.group_key === l), c = A(e, f, l === h ? "header" : "form");
|
|
86
|
+
return e.placements.some((u) => u.field === n && u.group_key === c.group_key) ? R(
|
|
87
|
+
`Its section is gone and ${t.label} is already in ${v(e.groups, c.group_key)}`
|
|
88
|
+
) : S(e, {
|
|
89
|
+
ok: !0,
|
|
90
|
+
ops: [
|
|
91
|
+
{
|
|
92
|
+
op: "place",
|
|
93
|
+
field: n,
|
|
94
|
+
group_key: c.group_key,
|
|
95
|
+
index: c.index,
|
|
96
|
+
...g ? { patch: B(g) } : {}
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
label: `Put back ${t.label}`,
|
|
100
|
+
notes: [`Its section is gone: it goes in ${v(e.groups, c.group_key)}`],
|
|
101
|
+
select: c.group_key === h ? { kind: "header", field: n } : { kind: "field", field: n, group_key: c.group_key }
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function X(e, t, f) {
|
|
106
|
+
const [a, n] = M({}), l = _(e.bundle), g = _(e.bundle);
|
|
107
|
+
g.current !== e.bundle && (g.current = e.bundle, l.current = e.bundle);
|
|
108
|
+
const c = _(e);
|
|
109
|
+
c.current = e;
|
|
110
|
+
const u = _(f);
|
|
111
|
+
u.current = f;
|
|
112
|
+
const m = _(t);
|
|
113
|
+
m.current = t;
|
|
114
|
+
const r = P((d, s) => {
|
|
115
|
+
const p = l.current;
|
|
116
|
+
if (p && d.some((y) => y.op === "remove" || y.op === "group_remove")) {
|
|
117
|
+
const y = Y(p, d, (s == null ? void 0 : s.label) ?? "Removed", u.current);
|
|
118
|
+
if (y.length) {
|
|
119
|
+
const w = m.current;
|
|
120
|
+
n((E) => ({
|
|
121
|
+
...E,
|
|
122
|
+
[w]: [...y.reverse(), ...E[w] ?? []].slice(0, W)
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (p)
|
|
127
|
+
try {
|
|
128
|
+
l.current = K(p, d);
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
c.current.apply(d, s);
|
|
132
|
+
}, []), o = P((d) => {
|
|
133
|
+
const s = m.current;
|
|
134
|
+
n((p) => ({ ...p, [s]: (p[s] ?? []).filter((y) => y.id !== d) }));
|
|
135
|
+
}, []), i = a[t], k = e.bundle, b = $(() => {
|
|
136
|
+
if (!k || !i) return [];
|
|
137
|
+
const d = /* @__PURE__ */ new Set();
|
|
138
|
+
return i.filter((s) => {
|
|
139
|
+
const p = s.piece.kind === "group" ? `g:${s.piece.key}` : `f:${s.piece.field}:${s.piece.group_key ?? ""}`;
|
|
140
|
+
return d.has(p) ? !1 : (d.add(p), L(k, s));
|
|
141
|
+
});
|
|
142
|
+
}, [i, k]), x = $(() => ({ ...e, apply: r }), [e, r]), G = $(() => ({ entries: b, forget: o }), [b, o]);
|
|
143
|
+
return { draft: x, removed: G };
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
W as REMOVED_KEEP,
|
|
147
|
+
T as putBackPlan,
|
|
148
|
+
Y as removalsIn,
|
|
149
|
+
L as stillRemoved,
|
|
150
|
+
X as useRemovalLog
|
|
151
|
+
};
|