@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,342 @@
|
|
|
1
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as O } from "@tanstack/react-query";
|
|
3
|
+
import { MessageSquare as P, Share2 as W, BellRing as B, Bell as T, Link2 as q, Copy as D, Crosshair as _, X as j } from "lucide-react";
|
|
4
|
+
import { useState as f } from "react";
|
|
5
|
+
import { toast as b } from "sonner";
|
|
6
|
+
import { useNivaroClient as F } from "../../../context.js";
|
|
7
|
+
import { get as R } from "../../../lib/commands.js";
|
|
8
|
+
import { cn as x } from "../../../lib/utils.js";
|
|
9
|
+
import { Popover as A, PopoverContent as K } from "../../ui/popover.js";
|
|
10
|
+
import { SimpleSelect as U } from "../../ui/SimpleSelect.js";
|
|
11
|
+
import { apiFailure as $ } from "../overview/overview-api.js";
|
|
12
|
+
import { ToolButton as N } from "../toolbar-kit.js";
|
|
13
|
+
import { useLayoutCollab as C, usePreviewComments as E, useCollabActions as w, usePreviewLinks as H, previewUrl as k } from "./collab-api.js";
|
|
14
|
+
const h = "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[12px] text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 disabled:opacity-40 dark:text-muted-foreground dark:hover:text-foreground", g = "text-[12px] font-semibold text-slate-700 dark:text-foreground", v = "text-[11.5px] leading-snug text-slate-500 dark:text-muted-foreground", L = (s) => s ? new Date(s).toLocaleDateString(void 0, { month: "short", day: "numeric" }) : "";
|
|
15
|
+
function y(s, o) {
|
|
16
|
+
b.error($(s, o).message);
|
|
17
|
+
}
|
|
18
|
+
function oe({ layoutId: s }) {
|
|
19
|
+
const { data: o } = C(s), m = w(s), [d, l] = f(!1), t = !!(o != null && o.watching);
|
|
20
|
+
return /* @__PURE__ */ e(
|
|
21
|
+
N,
|
|
22
|
+
{
|
|
23
|
+
label: "Watch this form",
|
|
24
|
+
ariaLabel: t ? "Stop watching this form" : "Watch this form",
|
|
25
|
+
icon: t ? /* @__PURE__ */ e(B, { className: "h-4 w-4" }) : /* @__PURE__ */ e(T, { className: "h-4 w-4" }),
|
|
26
|
+
hint: "Hear when someone saves a change",
|
|
27
|
+
iconOnly: !0,
|
|
28
|
+
checked: t,
|
|
29
|
+
disabled: d,
|
|
30
|
+
className: x(t && "text-[#0089ad] dark:text-nvr-cyan"),
|
|
31
|
+
tip: t ? "Watching: you hear when someone saves a change. Click to stop" : "Watch: hear when someone saves a change to this form",
|
|
32
|
+
data: { "data-form-watch": "" },
|
|
33
|
+
onClick: async () => {
|
|
34
|
+
l(!0);
|
|
35
|
+
try {
|
|
36
|
+
await m.setWatch(!t);
|
|
37
|
+
} catch (i) {
|
|
38
|
+
y(i, "Could not change the watch");
|
|
39
|
+
} finally {
|
|
40
|
+
l(!1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function M({ layoutId: s, owner: o }) {
|
|
47
|
+
const m = F(), d = w(s), [l, t] = f(!1), [i, p] = f(""), { data: u = [] } = O({
|
|
48
|
+
queryKey: ["layout-editor", "collab", "people", i],
|
|
49
|
+
queryFn: () => m.request(R("/users", { search: i, limit: 6, people: "1" })).then((n) => n.data ?? []),
|
|
50
|
+
enabled: l && i.trim().length > 1
|
|
51
|
+
}), c = async (n) => {
|
|
52
|
+
try {
|
|
53
|
+
await d.setOwner(n), t(!1), p("");
|
|
54
|
+
} catch (a) {
|
|
55
|
+
y(a, "Could not change the owner");
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return l ? /* @__PURE__ */ r("div", { children: [
|
|
59
|
+
/* @__PURE__ */ e(
|
|
60
|
+
"input",
|
|
61
|
+
{
|
|
62
|
+
autoFocus: !0,
|
|
63
|
+
"aria-label": "Find a person",
|
|
64
|
+
value: i,
|
|
65
|
+
onChange: (n) => p(n.target.value),
|
|
66
|
+
onKeyDown: (n) => n.key === "Escape" && t(!1),
|
|
67
|
+
placeholder: "Type a name or email",
|
|
68
|
+
className: "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12.5px] outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground"
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
i.trim().length > 1 && /* @__PURE__ */ e("div", { className: "mt-1 overflow-hidden rounded-md border border-slate-200 dark:border-border", children: u.length === 0 ? /* @__PURE__ */ e("div", { className: x(v, "px-2.5 py-1.5"), children: "No one matches" }) : u.map((n) => {
|
|
72
|
+
const a = `${n.first_name ?? ""} ${n.last_name ?? ""}`.trim() || n.email;
|
|
73
|
+
return /* @__PURE__ */ r(
|
|
74
|
+
"button",
|
|
75
|
+
{
|
|
76
|
+
type: "button",
|
|
77
|
+
onClick: () => void c(n.id),
|
|
78
|
+
className: "block w-full px-2.5 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-foreground",
|
|
79
|
+
children: [
|
|
80
|
+
a,
|
|
81
|
+
/* @__PURE__ */ e("span", { className: "ml-1.5 text-[11px] text-slate-400 dark:text-muted-foreground", children: n.email })
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
n.id
|
|
85
|
+
);
|
|
86
|
+
}) }),
|
|
87
|
+
/* @__PURE__ */ e("button", { type: "button", className: x(h, "mt-1"), onClick: () => t(!1), children: "Cancel" })
|
|
88
|
+
] }) : /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
89
|
+
/* @__PURE__ */ e(
|
|
90
|
+
"span",
|
|
91
|
+
{
|
|
92
|
+
"data-form-owner": "",
|
|
93
|
+
className: x(
|
|
94
|
+
"min-w-0 flex-1 truncate text-[12.5px]",
|
|
95
|
+
o ? "text-slate-800 dark:text-foreground" : "text-slate-400 dark:text-muted-foreground"
|
|
96
|
+
),
|
|
97
|
+
children: (o == null ? void 0 : o.name) ?? "No owner yet"
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ e("button", { type: "button", className: h, onClick: () => t(!0), children: o ? "Change" : "Name an owner" }),
|
|
101
|
+
o && /* @__PURE__ */ e("button", { type: "button", className: h, onClick: () => void c(null), children: "Clear" })
|
|
102
|
+
] });
|
|
103
|
+
}
|
|
104
|
+
function Q({ layoutId: s, open: o }) {
|
|
105
|
+
const { data: m = [] } = H(s, o), d = w(s), [l, t] = f("14"), [i, p] = f(!1), [u, c] = f(null), n = async (a) => {
|
|
106
|
+
try {
|
|
107
|
+
await navigator.clipboard.writeText(k(a)), b.success("Link copied");
|
|
108
|
+
} catch {
|
|
109
|
+
b.error("Could not copy — select the link and copy it");
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
113
|
+
/* @__PURE__ */ e("p", { className: v, children: "Anyone with the link can read this form’s layout (never record data) and comment on its fields. It shows the last saved version, as you see it." }),
|
|
114
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
115
|
+
/* @__PURE__ */ e(
|
|
116
|
+
U,
|
|
117
|
+
{
|
|
118
|
+
value: l,
|
|
119
|
+
onChange: t,
|
|
120
|
+
ariaLabel: "Link lasts",
|
|
121
|
+
className: "h-8 w-[120px] text-[12.5px]",
|
|
122
|
+
options: [
|
|
123
|
+
{ value: "7", label: "7 days" },
|
|
124
|
+
{ value: "14", label: "14 days" },
|
|
125
|
+
{ value: "30", label: "30 days" },
|
|
126
|
+
{ value: "90", label: "90 days" }
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ r(
|
|
131
|
+
"button",
|
|
132
|
+
{
|
|
133
|
+
type: "button",
|
|
134
|
+
disabled: i,
|
|
135
|
+
className: "inline-flex h-8 items-center gap-1.5 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50",
|
|
136
|
+
onClick: async () => {
|
|
137
|
+
p(!0);
|
|
138
|
+
try {
|
|
139
|
+
const a = await d.createLink(Number(l));
|
|
140
|
+
a != null && a.path && await n(a.path);
|
|
141
|
+
} catch (a) {
|
|
142
|
+
y(a, "Could not create the link");
|
|
143
|
+
} finally {
|
|
144
|
+
p(!1);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ e(q, { className: "h-3.5 w-3.5" }),
|
|
149
|
+
"Create link"
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] }),
|
|
154
|
+
m.map((a) => /* @__PURE__ */ r(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
"data-preview-link": a.id,
|
|
158
|
+
className: "rounded-md border border-slate-200 px-2.5 py-1.5 dark:border-border",
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ e("div", { className: "truncate font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: k(a.path) }),
|
|
161
|
+
/* @__PURE__ */ r("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
162
|
+
/* @__PURE__ */ r("span", { children: [
|
|
163
|
+
"until ",
|
|
164
|
+
L(a.expires_at)
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ r("span", { children: [
|
|
167
|
+
"· ",
|
|
168
|
+
a.view_count,
|
|
169
|
+
" ",
|
|
170
|
+
a.view_count === 1 ? "view" : "views"
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ r("span", { children: [
|
|
173
|
+
"· ",
|
|
174
|
+
a.comments,
|
|
175
|
+
" ",
|
|
176
|
+
a.comments === 1 ? "comment" : "comments"
|
|
177
|
+
] }),
|
|
178
|
+
/* @__PURE__ */ e("span", { className: "flex-1" }),
|
|
179
|
+
/* @__PURE__ */ r("button", { type: "button", className: h, onClick: () => void n(a.path), children: [
|
|
180
|
+
/* @__PURE__ */ e(D, { className: "h-3 w-3" }),
|
|
181
|
+
"Copy"
|
|
182
|
+
] }),
|
|
183
|
+
u === a.id ? /* @__PURE__ */ e(
|
|
184
|
+
"button",
|
|
185
|
+
{
|
|
186
|
+
type: "button",
|
|
187
|
+
className: x(h, "text-red-600 dark:text-red-400"),
|
|
188
|
+
onClick: async () => {
|
|
189
|
+
try {
|
|
190
|
+
await d.revokeLink(a.id);
|
|
191
|
+
} catch (S) {
|
|
192
|
+
y(S, "Could not turn the link off");
|
|
193
|
+
}
|
|
194
|
+
c(null);
|
|
195
|
+
},
|
|
196
|
+
children: "Turn off for everyone"
|
|
197
|
+
}
|
|
198
|
+
) : /* @__PURE__ */ e("button", { type: "button", className: h, onClick: () => c(a.id), children: "Turn off" })
|
|
199
|
+
] })
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
a.id
|
|
203
|
+
))
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
function X({
|
|
207
|
+
layoutId: s,
|
|
208
|
+
comments: o,
|
|
209
|
+
fieldLabel: m,
|
|
210
|
+
onSelectField: d
|
|
211
|
+
}) {
|
|
212
|
+
const l = w(s);
|
|
213
|
+
return o.length === 0 ? /* @__PURE__ */ e("p", { className: v, children: "No comments yet. People with a preview link leave them here." }) : /* @__PURE__ */ e("ul", { className: "space-y-1.5", children: o.map((t) => /* @__PURE__ */ r(
|
|
214
|
+
"li",
|
|
215
|
+
{
|
|
216
|
+
"data-preview-comment": t.id,
|
|
217
|
+
className: "rounded-md bg-slate-50 px-2.5 py-1.5 dark:bg-muted/40",
|
|
218
|
+
children: [
|
|
219
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
220
|
+
/* @__PURE__ */ e("span", { className: "min-w-0 truncate font-semibold text-slate-700 dark:text-foreground", children: t.field ? m(t.field) : "Whole form" }),
|
|
221
|
+
/* @__PURE__ */ r("span", { className: "shrink-0", children: [
|
|
222
|
+
"· ",
|
|
223
|
+
t.name,
|
|
224
|
+
" · ",
|
|
225
|
+
L(t.at)
|
|
226
|
+
] }),
|
|
227
|
+
/* @__PURE__ */ e("span", { className: "flex-1" }),
|
|
228
|
+
t.field && d && /* @__PURE__ */ e(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
type: "button",
|
|
232
|
+
"aria-label": "Select this field",
|
|
233
|
+
"data-tip": "Select this field on the canvas",
|
|
234
|
+
className: h,
|
|
235
|
+
onClick: () => d(t.field),
|
|
236
|
+
children: /* @__PURE__ */ e(_, { className: "h-3 w-3" })
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
/* @__PURE__ */ e(
|
|
240
|
+
"button",
|
|
241
|
+
{
|
|
242
|
+
type: "button",
|
|
243
|
+
"aria-label": "Resolve comment",
|
|
244
|
+
"data-tip": "Resolve: remove the comment",
|
|
245
|
+
className: h,
|
|
246
|
+
onClick: async () => {
|
|
247
|
+
try {
|
|
248
|
+
await l.resolveComment(t.id);
|
|
249
|
+
} catch (i) {
|
|
250
|
+
y(i, "Could not resolve the comment");
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
children: /* @__PURE__ */ e(j, { className: "h-3 w-3" })
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
] }),
|
|
257
|
+
/* @__PURE__ */ e("p", { className: "mt-0.5 whitespace-pre-wrap break-words text-[12.5px] text-slate-800 dark:text-foreground", children: t.text })
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
t.id
|
|
261
|
+
)) });
|
|
262
|
+
}
|
|
263
|
+
function ie({
|
|
264
|
+
layoutId: s,
|
|
265
|
+
fields: o,
|
|
266
|
+
onSelectField: m
|
|
267
|
+
}) {
|
|
268
|
+
const [d, l] = f(!1), { data: t } = C(s), { data: i = [] } = E(s), p = (c) => {
|
|
269
|
+
var n;
|
|
270
|
+
return ((n = o.find((a) => a.field === c)) == null ? void 0 : n.label) || c;
|
|
271
|
+
}, u = ((t == null ? void 0 : t.watchers) ?? []).filter((c) => {
|
|
272
|
+
var n;
|
|
273
|
+
return c.id !== ((n = t == null ? void 0 : t.owner) == null ? void 0 : n.id);
|
|
274
|
+
});
|
|
275
|
+
return /* @__PURE__ */ r(A, { open: d, onOpenChange: l, children: [
|
|
276
|
+
/* @__PURE__ */ e(
|
|
277
|
+
N,
|
|
278
|
+
{
|
|
279
|
+
popover: !0,
|
|
280
|
+
onOpen: () => l(!0),
|
|
281
|
+
label: "Share & watchers",
|
|
282
|
+
ariaLabel: "Share",
|
|
283
|
+
icon: /* @__PURE__ */ e(W, { className: "h-3.5 w-3.5" }),
|
|
284
|
+
tip: "Owner, watchers, preview links and comments",
|
|
285
|
+
hint: "Owner, watchers, preview links, comments",
|
|
286
|
+
badge: i.length || void 0,
|
|
287
|
+
data: { "data-form-share": "" },
|
|
288
|
+
trailing: i.length > 0 && /* @__PURE__ */ r(
|
|
289
|
+
"span",
|
|
290
|
+
{
|
|
291
|
+
"data-preview-comment-count": "",
|
|
292
|
+
className: "inline-flex h-4 min-w-4 items-center justify-center gap-0.5 rounded-full bg-nvr-cyan/15 px-1 text-[10.5px] font-semibold text-[#0089ad] dark:text-nvr-cyan",
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ e(P, { className: "h-2.5 w-2.5" }),
|
|
295
|
+
i.length
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
/* @__PURE__ */ r(
|
|
302
|
+
K,
|
|
303
|
+
{
|
|
304
|
+
align: "end",
|
|
305
|
+
className: "max-h-[min(75vh,620px)] w-[400px] space-y-4 overflow-y-auto overscroll-contain p-3",
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ r("section", { className: "space-y-1.5", children: [
|
|
308
|
+
/* @__PURE__ */ e("h3", { className: g, children: "Owner" }),
|
|
309
|
+
/* @__PURE__ */ e(M, { layoutId: s, owner: (t == null ? void 0 : t.owner) ?? null }),
|
|
310
|
+
/* @__PURE__ */ e("p", { className: v, children: "The business owner hears first about change requests and every saved change." })
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ r("section", { className: "space-y-1", children: [
|
|
313
|
+
/* @__PURE__ */ e("h3", { className: g, children: "Watching" }),
|
|
314
|
+
/* @__PURE__ */ e("p", { className: v, children: u.length === 0 ? "No one else watches this form. Use the bell to watch it yourself." : u.map((c) => c.name).join(", ") })
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ r("section", { className: "space-y-1.5", children: [
|
|
317
|
+
/* @__PURE__ */ e("h3", { className: g, children: "Preview link" }),
|
|
318
|
+
/* @__PURE__ */ e(Q, { layoutId: s, open: d })
|
|
319
|
+
] }),
|
|
320
|
+
/* @__PURE__ */ r("section", { className: "space-y-1.5", children: [
|
|
321
|
+
/* @__PURE__ */ e("h3", { className: g, children: "Comments from previews" }),
|
|
322
|
+
/* @__PURE__ */ e(
|
|
323
|
+
X,
|
|
324
|
+
{
|
|
325
|
+
layoutId: s,
|
|
326
|
+
comments: i,
|
|
327
|
+
fieldLabel: p,
|
|
328
|
+
onSelectField: m ? (c) => {
|
|
329
|
+
m(c), l(!1);
|
|
330
|
+
} : void 0
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
] })
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
)
|
|
337
|
+
] });
|
|
338
|
+
}
|
|
339
|
+
export {
|
|
340
|
+
ie as ShareButton,
|
|
341
|
+
oe as WatchButton
|
|
342
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useQuery as l, useQueryClient as m } from "@tanstack/react-query";
|
|
2
|
+
import { useCallback as b } from "react";
|
|
3
|
+
import { useNivaroClient as i } from "../../../context.js";
|
|
4
|
+
import { get as s, del as u, post as q, put as w } from "../../../lib/commands.js";
|
|
5
|
+
const c = {
|
|
6
|
+
one: (e) => ["layout-editor", "collab", e],
|
|
7
|
+
owners: () => ["layout-editor", "collab", "owners"],
|
|
8
|
+
links: (e) => ["layout-editor", "collab", e, "links"],
|
|
9
|
+
comments: (e) => ["layout-editor", "collab", e, "comments"]
|
|
10
|
+
}, r = (e, t) => (e == null ? void 0 : e.data) ?? t;
|
|
11
|
+
function d(e) {
|
|
12
|
+
const t = i();
|
|
13
|
+
return l({
|
|
14
|
+
queryKey: c.one(e),
|
|
15
|
+
queryFn: async () => r(await t.request(s(`/layout-collab/${e}`)), {
|
|
16
|
+
owner: null,
|
|
17
|
+
watching: !1,
|
|
18
|
+
watchers: []
|
|
19
|
+
}),
|
|
20
|
+
staleTime: 3e4
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function $(e, t) {
|
|
24
|
+
const a = i();
|
|
25
|
+
return l({
|
|
26
|
+
queryKey: c.links(e),
|
|
27
|
+
queryFn: async () => r(await a.request(s(`/layout-collab/${e}/preview-links`)), []),
|
|
28
|
+
enabled: t,
|
|
29
|
+
staleTime: 15e3
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function C(e) {
|
|
33
|
+
const t = i();
|
|
34
|
+
return l({
|
|
35
|
+
queryKey: c.comments(e),
|
|
36
|
+
queryFn: async () => r(await t.request(s(`/layout-collab/${e}/preview-comments`)), []),
|
|
37
|
+
staleTime: 3e4,
|
|
38
|
+
refetchOnWindowFocus: !0
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function h(e) {
|
|
42
|
+
const t = i(), a = m(), o = b(
|
|
43
|
+
() => a.invalidateQueries({ queryKey: ["layout-editor", "collab"] }),
|
|
44
|
+
[a]
|
|
45
|
+
);
|
|
46
|
+
return {
|
|
47
|
+
setWatch: async (n) => {
|
|
48
|
+
await t.request(w(`/layout-collab/${e}/watch`, { on: n })), await o();
|
|
49
|
+
},
|
|
50
|
+
setOwner: async (n) => {
|
|
51
|
+
await t.request(w(`/layout-collab/${e}/owner`, { user_id: n })), await o();
|
|
52
|
+
},
|
|
53
|
+
createLink: async (n) => {
|
|
54
|
+
const y = await t.request(
|
|
55
|
+
q(`/layout-collab/${e}/preview-links`, { days: n })
|
|
56
|
+
);
|
|
57
|
+
return await o(), r(y, null);
|
|
58
|
+
},
|
|
59
|
+
revokeLink: async (n) => {
|
|
60
|
+
await t.request(u(`/layout-collab/preview-links/${n}`)), await o();
|
|
61
|
+
},
|
|
62
|
+
resolveComment: async (n) => {
|
|
63
|
+
await t.request(u(`/layout-collab/${e}/preview-comments/${n}`)), await o();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function K(e) {
|
|
68
|
+
return typeof window > "u" ? e : new URL(e, window.location.origin).toString();
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
c as collabKeys,
|
|
72
|
+
K as previewUrl,
|
|
73
|
+
h as useCollabActions,
|
|
74
|
+
d as useLayoutCollab,
|
|
75
|
+
C as usePreviewComments,
|
|
76
|
+
$ as usePreviewLinks
|
|
77
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { jsxs as o, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Command as y, CornerDownLeft as O, Sparkles as w } from "lucide-react";
|
|
3
|
+
import { useState as x, useRef as P, useEffect as $, useMemo as D } from "react";
|
|
4
|
+
import { useNivaroClient as R } from "../../../context.js";
|
|
5
|
+
import { post as q } from "../../../lib/commands.js";
|
|
6
|
+
import { Popover as j, PopoverContent as B } from "../../ui/popover.js";
|
|
7
|
+
import { useLayoutEditorHost as F } from "../host.js";
|
|
8
|
+
import { useOverviewFields as Z, useRoleNames as H } from "../overview/overview-api.js";
|
|
9
|
+
import { ToolButton as V } from "../toolbar-kit.js";
|
|
10
|
+
import { parseSaveFailure as X } from "../useLayoutDraft.js";
|
|
11
|
+
import { intentsToOps as f, planLabel as Y } from "./intents.js";
|
|
12
|
+
import { parseCommand as z } from "./parse.js";
|
|
13
|
+
const G = [
|
|
14
|
+
"move Shipping Location to Materials",
|
|
15
|
+
"make Zone required",
|
|
16
|
+
"hide Notes; set width Region half",
|
|
17
|
+
"add step Review after Details"
|
|
18
|
+
], m = "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", N = "inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[12px] font-medium text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground", J = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform), A = J ? "⌘K" : "Ctrl+K";
|
|
19
|
+
function le({
|
|
20
|
+
collection: C,
|
|
21
|
+
layoutId: L,
|
|
22
|
+
draft: d
|
|
23
|
+
}) {
|
|
24
|
+
const T = F(), S = R(), [k, p] = x(!1), [c, I] = x(""), [r, s] = x({ kind: "idle" }), u = P(null), { data: g = [] } = Z(C), { data: v = [] } = H(k), K = T.isAdmin;
|
|
25
|
+
$(() => {
|
|
26
|
+
const e = (t) => {
|
|
27
|
+
var l;
|
|
28
|
+
if (!(t.metaKey || t.ctrlKey) || t.altKey || t.shiftKey || t.key.toLowerCase() !== "k") return;
|
|
29
|
+
const a = t.target;
|
|
30
|
+
(l = a == null ? void 0 : a.closest) != null && l.call(a, '[contenteditable]:not([contenteditable="false"])') || (t.preventDefault(), p(!0));
|
|
31
|
+
};
|
|
32
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
33
|
+
}, []);
|
|
34
|
+
const i = D(
|
|
35
|
+
() => d.bundle ? { bundle: d.bundle, fields: g, roles: v } : null,
|
|
36
|
+
[d.bundle, g, v]
|
|
37
|
+
), h = (e = "") => {
|
|
38
|
+
I(e), s({ kind: "idle" });
|
|
39
|
+
}, E = () => {
|
|
40
|
+
if (!i || !c.trim()) return;
|
|
41
|
+
const e = z(c, i);
|
|
42
|
+
if (!e.ok) {
|
|
43
|
+
s({ kind: "error", error: e.error, canAsk: K });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const t = f(e.intents, i);
|
|
47
|
+
s(
|
|
48
|
+
t.ok ? { kind: "preview", intents: e.intents, plan: t, source: "typed", explanation: null } : { kind: "error", error: t.error, canAsk: !1 }
|
|
49
|
+
);
|
|
50
|
+
}, M = async () => {
|
|
51
|
+
var e;
|
|
52
|
+
if (!(!i || !c.trim())) {
|
|
53
|
+
s({ kind: "asking" });
|
|
54
|
+
try {
|
|
55
|
+
const t = await S.request(q(`/ai-design/layouts/${L}/command`, { text: c.trim() })), a = Array.isArray((e = t == null ? void 0 : t.data) == null ? void 0 : e.intents) ? t.data.intents : [], l = f(a, i);
|
|
56
|
+
s(
|
|
57
|
+
l.ok ? {
|
|
58
|
+
kind: "preview",
|
|
59
|
+
intents: a,
|
|
60
|
+
plan: l,
|
|
61
|
+
source: "ai",
|
|
62
|
+
explanation: t.data.explanation ?? null
|
|
63
|
+
} : {
|
|
64
|
+
kind: "error",
|
|
65
|
+
error: `The AI's answer does not fit this form: ${l.error}`,
|
|
66
|
+
canAsk: !1
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
} catch (t) {
|
|
70
|
+
const a = X(t, "The AI could not read that");
|
|
71
|
+
s({
|
|
72
|
+
kind: "error",
|
|
73
|
+
error: a.status === 503 ? "AI is not set up here — typed commands such as the examples still work." : a.message,
|
|
74
|
+
canAsk: !1
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, b = () => {
|
|
79
|
+
if (r.kind !== "preview" || !i) return;
|
|
80
|
+
const e = f(r.intents, i);
|
|
81
|
+
if (!e.ok) {
|
|
82
|
+
s({ kind: "error", error: e.error, canAsk: !1 });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
d.apply(e.ops, { label: Y(e) }), h(), p(!1);
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ o(
|
|
88
|
+
j,
|
|
89
|
+
{
|
|
90
|
+
open: k,
|
|
91
|
+
onOpenChange: (e) => {
|
|
92
|
+
p(e), !e && r.kind !== "preview" && s({ kind: "idle" });
|
|
93
|
+
},
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ n(
|
|
96
|
+
V,
|
|
97
|
+
{
|
|
98
|
+
popover: !0,
|
|
99
|
+
onOpen: () => p(!0),
|
|
100
|
+
label: "Type a change…",
|
|
101
|
+
ariaLabel: "Type a change",
|
|
102
|
+
icon: /* @__PURE__ */ n(y, { className: "h-3.5 w-3.5" }),
|
|
103
|
+
kbd: A,
|
|
104
|
+
tip: `Type a change in plain words (${A})`,
|
|
105
|
+
hint: "In plain words: “make Zone required”",
|
|
106
|
+
disabled: !d.bundle,
|
|
107
|
+
data: { "data-command-palette-trigger": "" }
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ o(
|
|
111
|
+
B,
|
|
112
|
+
{
|
|
113
|
+
align: "end",
|
|
114
|
+
className: "w-[440px] overflow-hidden p-0",
|
|
115
|
+
"data-command-palette": "",
|
|
116
|
+
onOpenAutoFocus: (e) => {
|
|
117
|
+
var t;
|
|
118
|
+
e.preventDefault(), (t = u.current) == null || t.focus();
|
|
119
|
+
},
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ o(
|
|
122
|
+
"form",
|
|
123
|
+
{
|
|
124
|
+
className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border",
|
|
125
|
+
onSubmit: (e) => {
|
|
126
|
+
e.preventDefault(), r.kind === "preview" ? b() : E();
|
|
127
|
+
},
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ n(y, { className: "h-4 w-4 shrink-0 text-slate-400" }),
|
|
130
|
+
/* @__PURE__ */ n(
|
|
131
|
+
"input",
|
|
132
|
+
{
|
|
133
|
+
ref: u,
|
|
134
|
+
value: c,
|
|
135
|
+
onChange: (e) => h(e.target.value),
|
|
136
|
+
placeholder: "move Shipping Location to Materials",
|
|
137
|
+
"aria-label": "Command",
|
|
138
|
+
"data-command-input": "",
|
|
139
|
+
className: "h-8 min-w-0 flex-1 bg-transparent text-[13px] text-slate-800 outline-none placeholder:text-slate-400 dark:text-foreground dark:placeholder:text-muted-foreground"
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ o("kbd", { className: "hidden shrink-0 items-center gap-0.5 rounded border border-slate-200 px-1 text-[10.5px] text-slate-500 sm:inline-flex dark:border-border dark:text-muted-foreground", children: [
|
|
143
|
+
/* @__PURE__ */ n(O, { className: "h-3 w-3" }),
|
|
144
|
+
r.kind === "preview" ? "apply" : "preview"
|
|
145
|
+
] })
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ o("div", { className: "max-h-[min(60vh,420px)] overflow-y-auto overscroll-contain px-3 py-3", children: [
|
|
150
|
+
r.kind === "idle" && /* @__PURE__ */ o("div", { className: "space-y-2", children: [
|
|
151
|
+
/* @__PURE__ */ n("p", { className: m, children: "Say what to change. You see every change before it is made, and one Apply is one undo step." }),
|
|
152
|
+
/* @__PURE__ */ n("ul", { className: "space-y-0.5", children: G.map((e) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
|
|
153
|
+
"button",
|
|
154
|
+
{
|
|
155
|
+
type: "button",
|
|
156
|
+
className: "w-full rounded-md px-2 py-1 text-left text-[12.5px] text-slate-700 transition-colors hover:bg-muted dark:text-foreground",
|
|
157
|
+
onClick: () => {
|
|
158
|
+
var t;
|
|
159
|
+
h(e), (t = u.current) == null || t.focus();
|
|
160
|
+
},
|
|
161
|
+
children: e
|
|
162
|
+
}
|
|
163
|
+
) }, e)) }),
|
|
164
|
+
/* @__PURE__ */ n("p", { className: m, children: "Also: rename, make … optional / read-only, show, remove, collapse, expand, “for <role>”. Separate several commands with “;”." })
|
|
165
|
+
] }),
|
|
166
|
+
r.kind === "asking" && /* @__PURE__ */ n("p", { className: m, children: "Asking the AI…" }),
|
|
167
|
+
r.kind === "error" && /* @__PURE__ */ o("div", { className: "space-y-2", "data-command-error": "", children: [
|
|
168
|
+
/* @__PURE__ */ n("p", { className: "text-[12.5px] leading-snug text-red-700 dark:text-red-300", children: r.error }),
|
|
169
|
+
r.canAsk && /* @__PURE__ */ o("button", { type: "button", className: N, onClick: M, "data-command-ask-ai": "", children: [
|
|
170
|
+
/* @__PURE__ */ n(w, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
171
|
+
"Ask AI to read it"
|
|
172
|
+
] })
|
|
173
|
+
] }),
|
|
174
|
+
r.kind === "preview" && /* @__PURE__ */ o("div", { className: "space-y-2.5", "data-command-preview": "", children: [
|
|
175
|
+
/* @__PURE__ */ o("p", { className: "flex items-center gap-1.5 text-[12px] font-semibold text-slate-700 dark:text-foreground", children: [
|
|
176
|
+
r.source === "ai" && /* @__PURE__ */ n(w, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
177
|
+
r.source === "ai" ? "The AI read this as" : "This will"
|
|
178
|
+
] }),
|
|
179
|
+
/* @__PURE__ */ n("ol", { className: "list-decimal space-y-1 pl-5 text-[12.5px] leading-snug text-slate-700 dark:text-foreground", children: r.plan.steps.map((e, t) => /* @__PURE__ */ n("li", { children: e }, `${t}:${e}`)) }),
|
|
180
|
+
r.explanation && /* @__PURE__ */ n("p", { className: m, children: r.explanation }),
|
|
181
|
+
r.plan.notes.map((e) => /* @__PURE__ */ n(
|
|
182
|
+
"p",
|
|
183
|
+
{
|
|
184
|
+
className: "rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[12px] leading-snug text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
|
|
185
|
+
children: e
|
|
186
|
+
},
|
|
187
|
+
e
|
|
188
|
+
)),
|
|
189
|
+
/* @__PURE__ */ o("div", { className: "flex items-center justify-end gap-1.5 pt-1", children: [
|
|
190
|
+
/* @__PURE__ */ n(
|
|
191
|
+
"button",
|
|
192
|
+
{
|
|
193
|
+
type: "button",
|
|
194
|
+
className: N,
|
|
195
|
+
onClick: () => s({ kind: "idle" }),
|
|
196
|
+
children: "Back"
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ n(
|
|
200
|
+
"button",
|
|
201
|
+
{
|
|
202
|
+
type: "button",
|
|
203
|
+
onClick: b,
|
|
204
|
+
"data-command-apply": "",
|
|
205
|
+
className: "inline-flex h-7 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-medium text-white transition-opacity hover:opacity-90",
|
|
206
|
+
children: r.plan.steps.length > 1 ? `Apply ${r.plan.steps.length} changes` : "Apply"
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
] })
|
|
210
|
+
] })
|
|
211
|
+
] })
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
export {
|
|
220
|
+
le as CommandPalette
|
|
221
|
+
};
|