@nivaro/react 0.3.142 → 0.3.144
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/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/shared/components/CollectionBrowserView.js +1304 -1295
- package/dist/shared/components/layout-editor/DesignNode.js +181 -169
- package/dist/shared/components/layout-editor/LayoutEditor.js +334 -326
- package/dist/shared/components/layout-editor/explain/CanvasRules.js +72 -61
- package/package.json +1 -1
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import { jsxs as u, jsx as
|
|
2
|
-
import { GitBranch as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { amberStrip as
|
|
6
|
-
import { loopSentence as
|
|
7
|
-
const
|
|
1
|
+
import { jsxs as u, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { GitBranch as k, AlertTriangle as y } from "lucide-react";
|
|
3
|
+
import { useState as g, useCallback as v } from "react";
|
|
4
|
+
import { cn as w } from "../../../lib/utils.js";
|
|
5
|
+
import { amberStrip as N } from "../panel-style.js";
|
|
6
|
+
import { loopSentence as b } from "./field-sources.js";
|
|
7
|
+
const S = {
|
|
8
8
|
required: "amber",
|
|
9
9
|
readonly: "slate",
|
|
10
10
|
hidden: "slate",
|
|
11
11
|
filled: "violet"
|
|
12
|
-
},
|
|
13
|
-
function
|
|
14
|
-
|
|
12
|
+
}, C = /* @__PURE__ */ new Set(["hidden", "filled"]);
|
|
13
|
+
function R(e) {
|
|
14
|
+
return [...new Set(e.map((t) => t.tip || t.text))].join(`
|
|
15
|
+
`);
|
|
16
|
+
}
|
|
17
|
+
const m = "nvr:layout-editor:rules-view";
|
|
18
|
+
function M() {
|
|
19
|
+
const [e, t] = g(() => {
|
|
15
20
|
try {
|
|
16
|
-
return window.localStorage.getItem(
|
|
21
|
+
return window.localStorage.getItem(m) !== "off";
|
|
17
22
|
} catch {
|
|
18
23
|
return !0;
|
|
19
24
|
}
|
|
20
|
-
}), r =
|
|
21
|
-
|
|
25
|
+
}), r = v((d) => {
|
|
26
|
+
t(d);
|
|
22
27
|
try {
|
|
23
|
-
window.localStorage.setItem(
|
|
28
|
+
window.localStorage.setItem(m, d ? "on" : "off");
|
|
24
29
|
} catch {
|
|
25
30
|
}
|
|
26
31
|
}, []);
|
|
27
32
|
return [e, r];
|
|
28
33
|
}
|
|
29
|
-
function
|
|
34
|
+
function _({ on: e, onChange: t }) {
|
|
30
35
|
return /* @__PURE__ */ u(
|
|
31
36
|
"button",
|
|
32
37
|
{
|
|
@@ -35,97 +40,103 @@ function j({ on: e, onChange: n }) {
|
|
|
35
40
|
"aria-label": "Rules",
|
|
36
41
|
"data-rules-view": e ? "on" : "off",
|
|
37
42
|
"data-tip": e ? "Hide the rule tags and default values on the canvas" : "Show why fields are required, read-only or hidden, section rules and default values",
|
|
38
|
-
onClick: () =>
|
|
39
|
-
className:
|
|
43
|
+
onClick: () => t(!e),
|
|
44
|
+
className: w(
|
|
40
45
|
"inline-flex h-8 items-center gap-1 rounded-md px-2 text-[12px] font-medium transition-colors",
|
|
41
46
|
e ? "bg-accent text-slate-900 dark:text-foreground" : "text-slate-500 hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
|
|
42
47
|
),
|
|
43
48
|
children: [
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */
|
|
49
|
+
/* @__PURE__ */ a(k, { className: "h-3.5 w-3.5" }),
|
|
50
|
+
/* @__PURE__ */ a("span", { "data-tb-wide": "", children: "Rules" })
|
|
46
51
|
]
|
|
47
52
|
}
|
|
48
53
|
);
|
|
49
54
|
}
|
|
50
|
-
function
|
|
55
|
+
function q(e, t) {
|
|
51
56
|
var i;
|
|
52
57
|
const r = /* @__PURE__ */ new Map();
|
|
53
58
|
for (const o of e.loops) {
|
|
54
|
-
const
|
|
55
|
-
for (const
|
|
59
|
+
const n = b(o, e.describe, e.groupLabel);
|
|
60
|
+
for (const c of o.fields) r.set(c, [...r.get(c) ?? [], n]);
|
|
56
61
|
}
|
|
57
|
-
if (r.size > 0 || (((i =
|
|
62
|
+
if (r.size > 0 || (((i = t.ghostTags) == null ? void 0 : i.size) ?? 0) > 0 || t.chips && (e.fieldChips.size > 0 || e.groupChips.size > 0))
|
|
58
63
|
return (o) => {
|
|
59
|
-
var
|
|
60
|
-
const
|
|
64
|
+
var p;
|
|
65
|
+
const n = [];
|
|
61
66
|
if (o.kind === "group") {
|
|
62
|
-
if (
|
|
67
|
+
if (t.chips)
|
|
63
68
|
for (const s of e.groupChips.get(o.key) ?? [])
|
|
64
|
-
|
|
65
|
-
return
|
|
69
|
+
n.push({ text: s.text, tone: "slate", tip: s.tip, onClick: () => t.open(s.open, o) });
|
|
70
|
+
return n;
|
|
66
71
|
}
|
|
67
|
-
if (o.kind !== "field" && o.kind !== "header") return
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
72
|
+
if (o.kind !== "field" && o.kind !== "header") return n;
|
|
73
|
+
const c = r.get(o.field);
|
|
74
|
+
if (c && n.push({
|
|
70
75
|
text: "Rule loop",
|
|
71
76
|
tone: "amber",
|
|
72
|
-
tip:
|
|
77
|
+
tip: c.join(" · "),
|
|
73
78
|
highlight: !0,
|
|
74
79
|
kind: "loop"
|
|
75
|
-
}),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
}), t.chips) {
|
|
81
|
+
const s = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const l of e.fieldChips.get(o.field) ?? [])
|
|
83
|
+
t.readOnlyView && !C.has(l.state) || s.set(l.state, [...s.get(l.state) ?? [], l]);
|
|
84
|
+
for (const [l, f] of s)
|
|
85
|
+
n.push({
|
|
86
|
+
text: f.map((x) => x.text).join(" · "),
|
|
87
|
+
tone: S[l],
|
|
88
|
+
icon: l,
|
|
89
|
+
iconOnly: !0,
|
|
90
|
+
tip: R(f),
|
|
91
|
+
onClick: () => t.open(f[0].open, o)
|
|
82
92
|
});
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
}
|
|
94
|
+
const h = (p = t.ghostTags) == null ? void 0 : p.get(o.field);
|
|
95
|
+
return h && n.push({ text: h, tone: "slate", tip: "What a new record starts with" }), n;
|
|
85
96
|
};
|
|
86
97
|
}
|
|
87
|
-
function
|
|
98
|
+
function A({
|
|
88
99
|
explain: e,
|
|
89
|
-
onShow:
|
|
100
|
+
onShow: t
|
|
90
101
|
}) {
|
|
91
|
-
const [r,
|
|
102
|
+
const [r, d] = g(!1);
|
|
92
103
|
if (e.loops.length === 0) return null;
|
|
93
|
-
const i = e.loops.map((
|
|
94
|
-
field:
|
|
95
|
-
text:
|
|
104
|
+
const i = e.loops.map((n) => ({
|
|
105
|
+
field: n.fields[0],
|
|
106
|
+
text: b(n, e.describe, e.groupLabel)
|
|
96
107
|
})), o = r ? i : i.slice(0, 1);
|
|
97
108
|
return /* @__PURE__ */ u(
|
|
98
109
|
"div",
|
|
99
110
|
{
|
|
100
111
|
role: "note",
|
|
101
112
|
"data-rule-loops": "",
|
|
102
|
-
className:
|
|
113
|
+
className: w(
|
|
103
114
|
"flex shrink-0 items-start gap-2 border-b px-4 py-1.5 text-[12.5px]",
|
|
104
|
-
|
|
115
|
+
N
|
|
105
116
|
),
|
|
106
117
|
children: [
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ a(y, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
119
|
+
/* @__PURE__ */ a("ul", { className: "m-0 min-w-0 flex-1 list-none space-y-0.5 p-0", children: o.map((n) => /* @__PURE__ */ u("li", { className: "flex min-w-0 items-baseline gap-2", children: [
|
|
109
120
|
/* @__PURE__ */ u("span", { className: "min-w-0", children: [
|
|
110
121
|
"Rule loop: ",
|
|
111
|
-
|
|
122
|
+
n.text,
|
|
112
123
|
"."
|
|
113
124
|
] }),
|
|
114
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ a(
|
|
115
126
|
"button",
|
|
116
127
|
{
|
|
117
128
|
type: "button",
|
|
118
|
-
onClick: () => n
|
|
129
|
+
onClick: () => t(n.field),
|
|
119
130
|
className: "shrink-0 font-medium underline underline-offset-2 hover:no-underline",
|
|
120
131
|
children: "Show"
|
|
121
132
|
}
|
|
122
133
|
)
|
|
123
|
-
] },
|
|
124
|
-
i.length > 1 && /* @__PURE__ */
|
|
134
|
+
] }, n.text)) }),
|
|
135
|
+
i.length > 1 && /* @__PURE__ */ a(
|
|
125
136
|
"button",
|
|
126
137
|
{
|
|
127
138
|
type: "button",
|
|
128
|
-
onClick: () =>
|
|
139
|
+
onClick: () => d(!r),
|
|
129
140
|
className: "shrink-0 font-medium underline underline-offset-2 hover:no-underline",
|
|
130
141
|
children: r ? "Fewer" : `${i.length - 1} more`
|
|
131
142
|
}
|
|
@@ -135,8 +146,8 @@ function L({
|
|
|
135
146
|
);
|
|
136
147
|
}
|
|
137
148
|
export {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
149
|
+
A as RuleLoopsBanner,
|
|
150
|
+
_ as RulesToggle,
|
|
151
|
+
q as explainMarks,
|
|
152
|
+
M as useRulesView
|
|
142
153
|
};
|