@nivaro/react 0.2.52 → 0.2.54
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 +116 -2
- package/dist/layout-editor.d.ts +248 -2
- package/dist/shared/components/FormWhatsNew.js +60 -0
- package/dist/shared/components/ItemEditForm.js +3994 -3876
- package/dist/shared/components/RecordReadView.js +219 -211
- package/dist/shared/components/TipLayer.js +27 -27
- package/dist/shared/components/help-videos/api.js +51 -41
- package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
- package/dist/shared/components/item-edit/FieldAffordances.js +7 -6
- package/dist/shared/components/item-edit/FieldRow.js +353 -304
- package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
- package/dist/shared/components/item-edit/GroupSection.js +419 -396
- package/dist/shared/components/item-edit/HeaderTools.js +59 -56
- package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
- package/dist/shared/components/item-edit/lock-why.js +87 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -0
- package/dist/shared/components/layout-editor/AddPanel.js +204 -146
- package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
- package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
- package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
- package/dist/shared/components/layout-editor/ChangeNote.js +146 -0
- package/dist/shared/components/layout-editor/CollabParts.js +170 -0
- package/dist/shared/components/layout-editor/DesignNode.js +304 -115
- package/dist/shared/components/layout-editor/EditorCanvas.js +21 -20
- package/dist/shared/components/layout-editor/EditorTopBar.js +452 -175
- package/dist/shared/components/layout-editor/FindReplace.js +188 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +234 -109
- package/dist/shared/components/layout-editor/LayoutEditor.js +1101 -307
- package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
- package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
- package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
- package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
- package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +413 -0
- package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
- package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
- package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
- package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
- package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
- package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
- package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
- package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
- package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
- package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
- package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
- package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
- package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
- package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
- package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
- package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
- package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
- package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
- package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
- package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
- package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
- package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
- package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
- package/dist/shared/components/layout-editor/assist/jump.js +142 -0
- package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
- package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
- package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
- package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
- package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
- package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
- package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
- package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
- package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
- package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +342 -0
- package/dist/shared/components/layout-editor/collab/collab-api.js +77 -0
- package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
- package/dist/shared/components/layout-editor/commands/intents.js +214 -0
- package/dist/shared/components/layout-editor/commands/parse.js +242 -0
- package/dist/shared/components/layout-editor/design-context.js +26 -6
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +179 -163
- package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
- package/dist/shared/components/layout-editor/draft-recovery.js +61 -0
- package/dist/shared/components/layout-editor/editor-notes.js +78 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
- package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
- package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
- package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
- package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
- package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
- package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
- package/dist/shared/components/layout-editor/field-zones.js +116 -0
- package/dist/shared/components/layout-editor/form-map.js +138 -0
- package/dist/shared/components/layout-editor/history-api.js +87 -0
- package/dist/shared/components/layout-editor/inheritance.js +55 -0
- package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
- package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
- package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
- package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +175 -0
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +146 -92
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +256 -175
- package/dist/shared/components/layout-editor/inspector/LookTab.js +46 -40
- package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +167 -141
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +175 -128
- package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +3 -3
- package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
- package/dist/shared/components/layout-editor/is-typing.js +9 -0
- package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
- package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
- package/dist/shared/components/layout-editor/load-error.js +37 -0
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
- package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
- package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
- package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
- package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
- package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
- package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
- package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
- package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
- package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
- package/dist/shared/components/layout-editor/nav/find.js +20 -0
- package/dist/shared/components/layout-editor/nav/tree.js +142 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
- package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
- package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
- package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
- package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
- package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
- package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +18 -14
- package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
- package/dist/shared/components/layout-editor/panel-style.js +8 -7
- package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
- package/dist/shared/components/layout-editor/pin.js +25 -0
- package/dist/shared/components/layout-editor/presence.js +111 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
- package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
- package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
- package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
- package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
- package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
- package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
- package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
- package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
- package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
- package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +123 -103
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +174 -100
- package/dist/shared/components/layout-editor/settings/WhoSection.js +136 -100
- package/dist/shared/components/layout-editor/settings/controls.js +8 -8
- package/dist/shared/components/layout-editor/settings/settings-registry.js +35 -11
- package/dist/shared/components/layout-editor/shortcuts.js +88 -0
- package/dist/shared/components/layout-editor/show-when.js +35 -0
- package/dist/shared/components/layout-editor/slot-names.js +4 -3
- package/dist/shared/components/layout-editor/structure-ops.js +399 -0
- package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +551 -0
- package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
- package/dist/shared/components/layout-editor/testing/testing-model.js +393 -0
- package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
- package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
- package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
- package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +158 -0
- package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -307
- package/dist/shared/components/support/SuggestFormChange.js +143 -0
- package/dist/shared/lib/ai-fill.js +37 -0
- package/dist/shared/lib/form-usage-beacon.js +84 -0
- package/dist/shared/lib/layout-i18n.js +66 -0
- package/dist/shared/lib/layout-lint.js +490 -0
- package/dist/shared/lib/layout-ops.js +110 -106
- package/dist/shared/lib/screenshot.js +54 -28
- package/dist/shared/lib/visible-when.js +34 -0
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { HEADER_GROUP_KEY as f, UNGROUPED_KEY as p } from "../../lib/layout-ops.js";
|
|
2
|
+
import { titleCase as k } from "../../lib/utils.js";
|
|
3
|
+
import { targetKey as _ } from "./design-context.js";
|
|
4
|
+
import { slotName as m } from "./slot-names.js";
|
|
5
|
+
const l = (e) => /^__.+__$/.test(e);
|
|
6
|
+
function s(e, r) {
|
|
7
|
+
return r === f ? [{ kind: "header", field: e }] : l(e) ? [{ kind: "slot", field: e, group_key: r }] : [{ kind: "field", field: e, group_key: r }];
|
|
8
|
+
}
|
|
9
|
+
const a = (e) => ({
|
|
10
|
+
kind: "group",
|
|
11
|
+
key: e ?? p
|
|
12
|
+
});
|
|
13
|
+
function h(e) {
|
|
14
|
+
switch (e.op) {
|
|
15
|
+
case "place":
|
|
16
|
+
return s(e.field, e.group_key ?? null);
|
|
17
|
+
case "move":
|
|
18
|
+
return s(e.from.field, e.to_group_key ?? null);
|
|
19
|
+
case "update_placement":
|
|
20
|
+
return s(e.at.field, e.at.group_key ?? null);
|
|
21
|
+
case "remove":
|
|
22
|
+
return e.at.group_key === f ? [] : [a(e.at.group_key ?? null)];
|
|
23
|
+
case "group_create":
|
|
24
|
+
case "group_update":
|
|
25
|
+
return [a(e.key)];
|
|
26
|
+
case "group_move":
|
|
27
|
+
return l(e.key) ? [{ kind: "slot", field: e.key, group_key: null }] : [a(e.key)];
|
|
28
|
+
default:
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function v(e) {
|
|
33
|
+
const r = /* @__PURE__ */ new Set(), t = [];
|
|
34
|
+
for (const n of e.ops)
|
|
35
|
+
for (const u of h(n)) {
|
|
36
|
+
const i = _(u);
|
|
37
|
+
r.has(i) || (r.add(i), t.push(u));
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
function U(e) {
|
|
42
|
+
const r = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const t of e) for (const n of v(t)) r.add(_(n));
|
|
44
|
+
return r;
|
|
45
|
+
}
|
|
46
|
+
function $(e) {
|
|
47
|
+
return e.ops.some((r) => r.op === "layout_update");
|
|
48
|
+
}
|
|
49
|
+
function R(e) {
|
|
50
|
+
const [r, t, ...n] = e.split(":");
|
|
51
|
+
if (!t) return null;
|
|
52
|
+
const u = n.join(":") || null;
|
|
53
|
+
return r === "group" ? { kind: "group", key: [t, ...n].join(":") } : r === "header" ? { kind: "header", field: t } : r === "field" || r === "slot" ? { kind: r, field: t, group_key: u } : null;
|
|
54
|
+
}
|
|
55
|
+
function j(e, r, t = []) {
|
|
56
|
+
var d;
|
|
57
|
+
const n = (o) => {
|
|
58
|
+
var g;
|
|
59
|
+
return o == null || o === p ? "Ungrouped" : ((g = r == null ? void 0 : r.groups.find((y) => y.key === o)) == null ? void 0 : g.label) || k(o);
|
|
60
|
+
};
|
|
61
|
+
if (e.kind === "group") return n(e.key);
|
|
62
|
+
const u = e.kind === "header" ? f : e.group_key, i = r == null ? void 0 : r.placements.find((o) => o.field === e.field && o.group_key === u), c = (i == null ? void 0 : i.label_override) || (l(e.field) ? m(e.field) : ((d = t.find((o) => o.field === e.field)) == null ? void 0 : d.label) || k(e.field));
|
|
63
|
+
return e.kind === "header" ? `${c} in the header` : `${c} in ${n(e.group_key)}`;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
j as describeTarget,
|
|
67
|
+
h as opTargets,
|
|
68
|
+
v as stepTargets,
|
|
69
|
+
R as targetFromKey,
|
|
70
|
+
$ as touchesSettings,
|
|
71
|
+
U as unsavedKeys
|
|
72
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs as n, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { cn as i } from "../../../lib/utils.js";
|
|
3
|
+
const l = 10;
|
|
4
|
+
function d({ pct: e }) {
|
|
5
|
+
const t = e > 0 && e < 1 ? "<1" : String(Math.round(e)), r = e < l;
|
|
6
|
+
return /* @__PURE__ */ n(
|
|
7
|
+
"span",
|
|
8
|
+
{
|
|
9
|
+
"data-design-fill": t,
|
|
10
|
+
"data-fill-low": r ? "" : void 0,
|
|
11
|
+
"data-tip": r ? "Rarely filled on this collection’s records" : void 0,
|
|
12
|
+
className: i(
|
|
13
|
+
"inline-flex items-center rounded bg-white px-1 text-[10.5px] tabular-nums text-slate-500 ring-1 ring-slate-200 dark:bg-card dark:text-muted-foreground dark:ring-border",
|
|
14
|
+
r && "pointer-events-auto"
|
|
15
|
+
),
|
|
16
|
+
children: [
|
|
17
|
+
t,
|
|
18
|
+
"% filled",
|
|
19
|
+
/* @__PURE__ */ o("span", { className: "sr-only", children: " on this collection's records" })
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
d as FillChip,
|
|
26
|
+
l as LOW_FILL_PCT
|
|
27
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsxs as s, jsx as a, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { Rows3 as G } from "lucide-react";
|
|
3
|
+
import { useState as q, useMemo as x } from "react";
|
|
4
|
+
import { UNGROUPED_KEY as I } from "../../../lib/layout-ops.js";
|
|
5
|
+
import { titleCase as y } from "../../../lib/utils.js";
|
|
6
|
+
import { Skeleton as L } from "../../ui/skeleton.js";
|
|
7
|
+
import { Toggle as K } from "../settings/controls.js";
|
|
8
|
+
import { suggestSections as W } from "./suggest-sections.js";
|
|
9
|
+
import { useLayoutUsageToday as Y, useLayoutFriction as z, useCoChanges as A, formatDuration as B } from "./usage-api.js";
|
|
10
|
+
const i = "px-3 pb-1.5 pt-4 text-[12px] font-semibold text-slate-700 dark:text-foreground", n = "px-3 text-[12px] leading-snug text-slate-500 dark:text-muted-foreground";
|
|
11
|
+
function d({ label: o, value: p }) {
|
|
12
|
+
return /* @__PURE__ */ s("div", { className: "flex flex-col gap-0.5 bg-white px-2.5 py-2 dark:bg-card", children: [
|
|
13
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: o }),
|
|
14
|
+
/* @__PURE__ */ a("span", { className: "text-[14px] font-semibold tabular-nums text-slate-900 dark:text-foreground", children: p })
|
|
15
|
+
] });
|
|
16
|
+
}
|
|
17
|
+
function S({ children: o }) {
|
|
18
|
+
return /* @__PURE__ */ a("div", { className: "mx-3 grid grid-cols-3 gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border", children: o });
|
|
19
|
+
}
|
|
20
|
+
function se({
|
|
21
|
+
bundle: o,
|
|
22
|
+
collection: p,
|
|
23
|
+
fields: f,
|
|
24
|
+
apply: _,
|
|
25
|
+
showFill: j,
|
|
26
|
+
onShowFill: $
|
|
27
|
+
}) {
|
|
28
|
+
const b = Number(o.layout.id), { data: r, isLoading: C } = Y(b), { data: t, isLoading: h } = z(b), { data: c, isLoading: M } = A(p), [N, U] = q(() => /* @__PURE__ */ new Set()), v = x(() => {
|
|
29
|
+
const e = new Map(f.map((l) => [l.field, l.label || y(l.field)]));
|
|
30
|
+
return (l) => e.get(l) ?? y(l);
|
|
31
|
+
}, [f]), m = (e) => {
|
|
32
|
+
var l;
|
|
33
|
+
return e == null || e === I ? "Ungrouped" : ((l = o.groups.find((g) => g.key === e)) == null ? void 0 : l.label) ?? e;
|
|
34
|
+
}, E = (e) => e === "__form__" ? "Whole form" : e === "__general__" ? "General" : m(e), F = x(() => new Set(o.placements.map((e) => e.field)), [o.placements]), w = x(
|
|
35
|
+
() => W(o, (c == null ? void 0 : c.pairs) ?? []).filter((e) => !N.has(e.id)),
|
|
36
|
+
[o, c, N]
|
|
37
|
+
), u = (t == null ? void 0 : t.steps) ?? [], O = Math.max(1, ...u.map((e) => e.avg_ms)), k = ((t == null ? void 0 : t.changed_after_save.fields) ?? []).slice(0, 8), P = r && !r.ready || t && !t.ready;
|
|
38
|
+
return /* @__PURE__ */ s("div", { "data-editor-usage": "", className: "flex flex-col pb-4", children: [
|
|
39
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-2 px-3 pt-3", children: [
|
|
40
|
+
/* @__PURE__ */ a("span", { className: "text-[12.5px] text-slate-700 dark:text-foreground", children: "Show how full each field is" }),
|
|
41
|
+
/* @__PURE__ */ a(K, { label: "Show how full each field is", checked: j, onChange: $ })
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ a("p", { className: `${n} pt-1`, children: "Each field on the form shows the share of records that have a value." }),
|
|
44
|
+
P && /* @__PURE__ */ a("p", { role: "note", className: `${n} pt-3`, children: "Usage is not being recorded on this instance yet (its database needs the latest update)." }),
|
|
45
|
+
/* @__PURE__ */ a("p", { className: i, children: "Today" }),
|
|
46
|
+
C ? /* @__PURE__ */ a(L, { className: "mx-3 h-12 rounded-lg" }) : /* @__PURE__ */ s(S, { children: [
|
|
47
|
+
/* @__PURE__ */ a(d, { label: "Opens", value: ((r == null ? void 0 : r.opens) ?? 0).toLocaleString() }),
|
|
48
|
+
/* @__PURE__ */ a(d, { label: "People", value: ((r == null ? void 0 : r.people) ?? 0).toLocaleString() }),
|
|
49
|
+
/* @__PURE__ */ a(d, { label: "Records", value: ((r == null ? void 0 : r.records) ?? 0).toLocaleString() })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ s("p", { className: i, children: [
|
|
52
|
+
"Last ",
|
|
53
|
+
(t == null ? void 0 : t.days) ?? 30,
|
|
54
|
+
" days"
|
|
55
|
+
] }),
|
|
56
|
+
h ? /* @__PURE__ */ a(L, { className: "mx-3 h-12 rounded-lg" }) : /* @__PURE__ */ s(S, { children: [
|
|
57
|
+
/* @__PURE__ */ a(d, { label: "Opens", value: ((t == null ? void 0 : t.opens) ?? 0).toLocaleString() }),
|
|
58
|
+
/* @__PURE__ */ a(d, { label: "Saves", value: ((t == null ? void 0 : t.saves) ?? 0).toLocaleString() }),
|
|
59
|
+
/* @__PURE__ */ a(d, { label: "Left unfinished", value: ((t == null ? void 0 : t.abandons) ?? 0).toLocaleString() })
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ a("p", { className: i, children: "Time per step" }),
|
|
62
|
+
u.length === 0 ? /* @__PURE__ */ a("p", { className: n, children: h ? "Loading…" : "No visits recorded yet." }) : /* @__PURE__ */ a("ul", { "data-usage-steps": "", className: "flex flex-col gap-2 px-3", children: u.map((e) => /* @__PURE__ */ s("li", { className: "flex flex-col gap-1", children: [
|
|
63
|
+
/* @__PURE__ */ s("div", { className: "flex items-baseline justify-between gap-2 text-[12px]", children: [
|
|
64
|
+
/* @__PURE__ */ a("span", { className: "truncate text-slate-800 dark:text-foreground", children: E(e.key) }),
|
|
65
|
+
/* @__PURE__ */ s("span", { className: "shrink-0 tabular-nums text-slate-500 dark:text-muted-foreground", children: [
|
|
66
|
+
B(e.avg_ms),
|
|
67
|
+
e.abandons > 0 && /* @__PURE__ */ s("span", { className: "text-amber-700 dark:text-amber-300", children: [
|
|
68
|
+
" · ",
|
|
69
|
+
e.abandons,
|
|
70
|
+
" left here"
|
|
71
|
+
] })
|
|
72
|
+
] })
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ a("div", { className: "h-1.5 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ a(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
className: "h-full rounded-full bg-slate-400 dark:bg-slate-500",
|
|
78
|
+
style: { width: `${Math.max(2, Math.round(e.avg_ms / O * 100))}%` }
|
|
79
|
+
}
|
|
80
|
+
) })
|
|
81
|
+
] }, e.key)) }),
|
|
82
|
+
/* @__PURE__ */ a("p", { className: i, children: "Changed soon after saving" }),
|
|
83
|
+
k.length === 0 ? /* @__PURE__ */ a("p", { className: n, children: h ? "Loading…" : "No field was changed within a day of a record being created." }) : /* @__PURE__ */ s(D, { children: [
|
|
84
|
+
/* @__PURE__ */ a("ul", { "data-usage-changed": "", className: "flex flex-col px-3", children: k.map((e) => /* @__PURE__ */ s(
|
|
85
|
+
"li",
|
|
86
|
+
{
|
|
87
|
+
className: "flex items-baseline justify-between gap-2 border-b border-slate-100 py-1 text-[12px] last:border-0 dark:border-border",
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 truncate text-slate-800 dark:text-foreground", children: [
|
|
90
|
+
v(e.field),
|
|
91
|
+
!F.has(e.field) && /* @__PURE__ */ s("span", { className: "text-slate-400 dark:text-muted-foreground", children: [
|
|
92
|
+
" ",
|
|
93
|
+
"· not on this form"
|
|
94
|
+
] })
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ s("span", { className: "shrink-0 tabular-nums text-slate-500 dark:text-muted-foreground", children: [
|
|
97
|
+
e.changes.toLocaleString(),
|
|
98
|
+
"×"
|
|
99
|
+
] })
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
e.field
|
|
103
|
+
)) }),
|
|
104
|
+
/* @__PURE__ */ s("p", { className: `${n} pt-1`, children: [
|
|
105
|
+
"Edits within 24 hours of a record being created, last 90 days",
|
|
106
|
+
(t == null ? void 0 : t.changed_after_save.scope) === "collection" ? ", across every form of this collection." : ", on records opened with this form."
|
|
107
|
+
] })
|
|
108
|
+
] }),
|
|
109
|
+
/* @__PURE__ */ a("p", { className: i, children: "Suggested sections" }),
|
|
110
|
+
M ? /* @__PURE__ */ a("p", { className: n, children: "Loading…" }) : w.length === 0 ? /* @__PURE__ */ a("p", { className: n, children: "No suggestions. Fields people change together already sit together on this form." }) : /* @__PURE__ */ a("ul", { "data-usage-suggestions": "", className: "flex flex-col gap-2 px-3", children: w.map((e) => {
|
|
111
|
+
const l = e.fields.map(v), g = l.length > 1 ? `${l.slice(0, -1).join(", ")} and ${l[l.length - 1]}` : l[0], R = [...new Set(Object.values(e.from).map(m))];
|
|
112
|
+
return /* @__PURE__ */ s(
|
|
113
|
+
"li",
|
|
114
|
+
{
|
|
115
|
+
"data-usage-suggestion": e.id,
|
|
116
|
+
className: "flex flex-col gap-2 rounded-lg border border-slate-200 bg-white p-2.5 dark:border-border dark:bg-card",
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ s("p", { className: "m-0 text-[12px] leading-snug text-slate-700 dark:text-foreground", children: [
|
|
119
|
+
/* @__PURE__ */ a(G, { className: "mr-1 inline h-3.5 w-3.5 align-[-2px] text-slate-400" }),
|
|
120
|
+
"People usually change ",
|
|
121
|
+
/* @__PURE__ */ a("b", { className: "font-semibold", children: g }),
|
|
122
|
+
" together, but they sit in ",
|
|
123
|
+
R.join(" and "),
|
|
124
|
+
"."
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
|
|
127
|
+
/* @__PURE__ */ s(
|
|
128
|
+
"button",
|
|
129
|
+
{
|
|
130
|
+
type: "button",
|
|
131
|
+
onClick: () => _(e.ops, { label: `Move ${g} into ${m(e.target)}` }),
|
|
132
|
+
className: "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-2.5 text-[12px] font-medium text-white transition-opacity hover:opacity-90",
|
|
133
|
+
children: [
|
|
134
|
+
"Move into ",
|
|
135
|
+
m(e.target)
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ a(
|
|
140
|
+
"button",
|
|
141
|
+
{
|
|
142
|
+
type: "button",
|
|
143
|
+
onClick: () => U((T) => new Set(T).add(e.id)),
|
|
144
|
+
className: "inline-flex h-7 items-center rounded-md px-2 text-[12px] text-slate-500 transition-colors hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
145
|
+
children: "Not now"
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
] })
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
e.id
|
|
152
|
+
);
|
|
153
|
+
}) })
|
|
154
|
+
] });
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
se as UsagePanel
|
|
158
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isCanvasSlot as p, HEADER_GROUP_KEY as k, TABLE_FORM_GROUP_KEYS as j } from "../../../lib/layout-ops.js";
|
|
2
|
+
const h = 6, w = 5;
|
|
3
|
+
function R(f, _, m = {}) {
|
|
4
|
+
const b = m.minJaccard ?? 0.5, r = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set();
|
|
5
|
+
for (const t of f.placements)
|
|
6
|
+
t.field.startsWith("__") || p(t) || t.group_key !== k && (t.group_key && j.includes(t.group_key) || (r.has(t.field) && u.add(t.field), r.set(t.field, t.group_key)));
|
|
7
|
+
for (const t of u) r.delete(t);
|
|
8
|
+
const g = _.filter((t) => t.jaccard >= b && r.has(t.a) && r.has(t.b)).sort((t, o) => o.jaccard - t.jaccard || o.together - t.together), i = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const t of g) {
|
|
10
|
+
const o = i.get(t.a), s = i.get(t.b);
|
|
11
|
+
if (o && s) {
|
|
12
|
+
if (o === s || o.length + s.length > h) continue;
|
|
13
|
+
o.push(...s);
|
|
14
|
+
for (const c of s) i.set(c, o);
|
|
15
|
+
} else if (o || s) {
|
|
16
|
+
const c = o ?? s, a = o ? t.b : t.a;
|
|
17
|
+
if (c.length >= h) continue;
|
|
18
|
+
c.push(a), i.set(a, c);
|
|
19
|
+
} else {
|
|
20
|
+
const c = [t.a, t.b];
|
|
21
|
+
i.set(t.a, c), i.set(t.b, c);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const y = [...new Set(i.values())], d = [];
|
|
25
|
+
for (const t of y) {
|
|
26
|
+
const o = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const e of t) {
|
|
28
|
+
const n = r.get(e) ?? null;
|
|
29
|
+
o.set(n, [...o.get(n) ?? [], e]);
|
|
30
|
+
}
|
|
31
|
+
if (o.size < 2) continue;
|
|
32
|
+
let s = null, c = -1;
|
|
33
|
+
for (const [e, n] of o)
|
|
34
|
+
n.length > c && (c = n.length, s = e);
|
|
35
|
+
const a = f.placements.filter((e) => e.group_key === s && !p(e)).sort((e, n) => e.sort - n.sort), S = Math.max(...a.map((e, n) => t.includes(e.field) ? n : -1)), E = t.filter((e) => (r.get(e) ?? null) !== s).map((e, n) => ({
|
|
36
|
+
op: "move",
|
|
37
|
+
from: { field: e, group_key: r.get(e) ?? null },
|
|
38
|
+
to_group_key: s,
|
|
39
|
+
// Ungrouped mixes fields with section positions: append there.
|
|
40
|
+
index: s == null ? 1e6 : S + 1 + n
|
|
41
|
+
})), l = g.filter((e) => t.includes(e.a) && t.includes(e.b)), M = l.length ? l.reduce((e, n) => e + n.jaccard, 0) / l.length : 0;
|
|
42
|
+
d.push({
|
|
43
|
+
id: [...t].sort().join("+"),
|
|
44
|
+
fields: t,
|
|
45
|
+
from: Object.fromEntries(t.map((e) => [e, r.get(e) ?? null])),
|
|
46
|
+
target: s,
|
|
47
|
+
ops: E,
|
|
48
|
+
score: Math.round(M * 100) / 100
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return d.sort((t, o) => o.score - t.score).slice(0, w);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
R as suggestSections
|
|
55
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useQuery as a } from "@tanstack/react-query";
|
|
2
|
+
import { useState as d, useCallback as f, useMemo as y } from "react";
|
|
3
|
+
import { useNivaroClient as s } from "../../../context.js";
|
|
4
|
+
import { get as u } from "../../../lib/commands.js";
|
|
5
|
+
const i = {
|
|
6
|
+
fill: (e) => ["layout-editor", "usage", "fill", e],
|
|
7
|
+
today: (e) => ["layout-editor", "usage", "today", e],
|
|
8
|
+
friction: (e) => ["layout-editor", "usage", "friction", e],
|
|
9
|
+
coChanges: (e) => ["layout-editor", "usage", "co-changes", e]
|
|
10
|
+
};
|
|
11
|
+
function $(e, n = !0) {
|
|
12
|
+
const r = s();
|
|
13
|
+
return a({
|
|
14
|
+
queryKey: i.fill(e),
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
const t = await r.request(u(`/data-model/${encodeURIComponent(e)}/field-usage`)), o = t == null ? void 0 : t.data;
|
|
17
|
+
return {
|
|
18
|
+
total: Number((o == null ? void 0 : o.total) ?? 0),
|
|
19
|
+
pct: new Map(((o == null ? void 0 : o.fields) ?? []).map((l) => [l.field, Number(l.pct)]))
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
enabled: n && !!e,
|
|
23
|
+
staleTime: 5 * 6e4,
|
|
24
|
+
retry: !1
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function q(e, n) {
|
|
28
|
+
return e == null || !Number.isFinite(e) || n <= 0 ? null : e > 0 && e < 1 ? "filled on under 1%" : `filled on ${Math.round(e)}%`;
|
|
29
|
+
}
|
|
30
|
+
function F(e, n = !0) {
|
|
31
|
+
const r = s();
|
|
32
|
+
return a({
|
|
33
|
+
queryKey: i.today(e ?? 0),
|
|
34
|
+
queryFn: () => r.request(u(`/layout-usage/${e}/today`)).then((t) => (t == null ? void 0 : t.data) ?? null),
|
|
35
|
+
enabled: n && e != null,
|
|
36
|
+
staleTime: 6e4,
|
|
37
|
+
retry: !1
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function w(e) {
|
|
41
|
+
if (!(e != null && e.ready)) return null;
|
|
42
|
+
if (e.people === 0 && e.records === 0) return "not used yet today";
|
|
43
|
+
const n = `${e.people.toLocaleString()} ${e.people === 1 ? "person" : "people"}`;
|
|
44
|
+
if (e.records === 0) return `used by ${n} today`;
|
|
45
|
+
const r = `${e.records.toLocaleString()} ${e.records === 1 ? "record" : "records"}`;
|
|
46
|
+
return `used by ${n} on ${r} today`;
|
|
47
|
+
}
|
|
48
|
+
function C(e, n = !0) {
|
|
49
|
+
const r = s();
|
|
50
|
+
return a({
|
|
51
|
+
queryKey: i.friction(e),
|
|
52
|
+
queryFn: () => r.request(u(`/layout-usage/${e}/friction`)).then((t) => (t == null ? void 0 : t.data) ?? null),
|
|
53
|
+
enabled: n,
|
|
54
|
+
staleTime: 5 * 6e4,
|
|
55
|
+
retry: !1
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function T(e, n = !0) {
|
|
59
|
+
const r = s();
|
|
60
|
+
return a({
|
|
61
|
+
queryKey: i.coChanges(e),
|
|
62
|
+
queryFn: () => r.request(
|
|
63
|
+
u(`/layout-usage/co-changes/${encodeURIComponent(e)}`)
|
|
64
|
+
).then((t) => (t == null ? void 0 : t.data) ?? null),
|
|
65
|
+
enabled: n,
|
|
66
|
+
staleTime: 10 * 6e4,
|
|
67
|
+
retry: !1
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function b(e) {
|
|
71
|
+
if (!Number.isFinite(e) || e < 1e3) return "under 1 s";
|
|
72
|
+
const n = Math.round(e / 1e3);
|
|
73
|
+
if (n < 60) return `${n} s`;
|
|
74
|
+
const r = Math.floor(n / 60), t = n % 60;
|
|
75
|
+
return r < 60 ? t ? `${r} min ${t} s` : `${r} min` : `${Math.floor(r / 60)} h ${r % 60} min`;
|
|
76
|
+
}
|
|
77
|
+
const c = "nvr:layout-editor:show-fill";
|
|
78
|
+
function K() {
|
|
79
|
+
const [e, n] = d(() => {
|
|
80
|
+
try {
|
|
81
|
+
return window.localStorage.getItem(c) === "1";
|
|
82
|
+
} catch {
|
|
83
|
+
return !1;
|
|
84
|
+
}
|
|
85
|
+
}), r = f((t) => {
|
|
86
|
+
n(t);
|
|
87
|
+
try {
|
|
88
|
+
window.localStorage.setItem(c, t ? "1" : "0");
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}, []);
|
|
92
|
+
return y(() => [e, r], [e, r]);
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
q as fillText,
|
|
96
|
+
b as formatDuration,
|
|
97
|
+
i as usageKeys,
|
|
98
|
+
w as usageTodayText,
|
|
99
|
+
T as useCoChanges,
|
|
100
|
+
$ as useFieldFillRates,
|
|
101
|
+
C as useLayoutFriction,
|
|
102
|
+
F as useLayoutUsageToday,
|
|
103
|
+
K as useShowFillRates
|
|
104
|
+
};
|