@nivaro/react 0.2.53 → 0.2.55
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 +99 -98
- package/dist/index.d.ts +452 -4
- package/dist/index.js +644 -618
- package/dist/layout-editor.d.ts +252 -2
- package/dist/shared/components/BackgroundRunOffer.js +117 -0
- package/dist/shared/components/BroadcastView.js +214 -213
- package/dist/shared/components/CollectionBrowserView.js +2592 -2695
- package/dist/shared/components/FormWhatsNew.js +60 -0
- package/dist/shared/components/ItemEditForm.js +3968 -3618
- package/dist/shared/components/JobsTray.js +100 -55
- package/dist/shared/components/MyWorkView.js +91 -89
- package/dist/shared/components/NotificationBell.js +80 -79
- package/dist/shared/components/ProfileView.js +568 -520
- package/dist/shared/components/RecordCompare.js +254 -0
- package/dist/shared/components/RecordReadView.js +598 -543
- package/dist/shared/components/ReportView.js +578 -543
- package/dist/shared/components/RowPresence.js +91 -0
- package/dist/shared/components/TipLayer.js +27 -27
- package/dist/shared/components/WidgetSlot.js +474 -458
- package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
- package/dist/shared/components/ai/AskPanel.js +139 -119
- package/dist/shared/components/ai/FirstWeekCard.js +126 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
- package/dist/shared/components/bulk/bulk-field-options.js +45 -0
- package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
- package/dist/shared/components/chat/ChannelArchive.js +326 -0
- package/dist/shared/components/chat/ChannelExtras.js +141 -121
- package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
- package/dist/shared/components/chat/ChatPanel.js +1695 -1733
- package/dist/shared/components/chat/Composer.js +357 -303
- package/dist/shared/components/chat/MessageActions.js +92 -0
- package/dist/shared/components/chat/MessageFormat.js +290 -264
- package/dist/shared/components/chat/OutboxBubbles.js +146 -0
- package/dist/shared/components/chat/RequestIdCard.js +135 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
- package/dist/shared/components/chat/RoomParts.js +213 -274
- package/dist/shared/components/chat/ScreenClip.js +184 -0
- package/dist/shared/components/chat/chat-core.js +402 -483
- package/dist/shared/components/chat/chat-drafts.js +59 -0
- package/dist/shared/components/chat/chat-emoji.js +348 -0
- package/dist/shared/components/chat/chat-local-time.js +41 -0
- package/dist/shared/components/chat/chat-outbox.js +303 -0
- package/dist/shared/components/chat/chat-window.js +163 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
- package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
- package/dist/shared/components/help-videos/api.js +80 -67
- package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
- package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
- package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
- package/dist/shared/components/item-edit/FieldAffordances.js +9 -8
- package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
- package/dist/shared/components/item-edit/FieldRow.js +382 -320
- package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
- package/dist/shared/components/item-edit/GroupSection.js +786 -639
- package/dist/shared/components/item-edit/HeaderTools.js +59 -56
- package/dist/shared/components/item-edit/InlineTableField.js +3 -1
- package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
- package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
- package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
- package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
- package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
- package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
- package/dist/shared/components/item-edit/lazy-sections.js +36 -0
- package/dist/shared/components/item-edit/lock-why.js +94 -0
- package/dist/shared/components/item-edit/picker-miss.js +26 -0
- package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +65 -0
- package/dist/shared/components/layout-editor/AddPanel.js +226 -151
- 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 +147 -0
- package/dist/shared/components/layout-editor/CollabParts.js +175 -0
- package/dist/shared/components/layout-editor/DesignNode.js +311 -116
- package/dist/shared/components/layout-editor/EditorCanvas.js +30 -26
- package/dist/shared/components/layout-editor/EditorTopBar.js +463 -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 +250 -109
- package/dist/shared/components/layout-editor/LayoutEditor.js +1196 -305
- 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/RestorePiece.js +143 -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/StagedChip.js +22 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +464 -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 +388 -0
- package/dist/shared/components/layout-editor/collab/collab-api.js +80 -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 +181 -164
- package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
- package/dist/shared/components/layout-editor/dnd/node.js +69 -57
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
- package/dist/shared/components/layout-editor/draft-recovery.js +131 -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/entry/PlacementPresets.js +149 -0
- package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
- package/dist/shared/components/layout-editor/entry/presets.js +71 -0
- package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
- package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -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/grid-guides.js +142 -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/BehaviourSettings.js +402 -0
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +179 -0
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +291 -141
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +282 -180
- package/dist/shared/components/layout-editor/inspector/LookTab.js +166 -109
- package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
- package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +146 -118
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +162 -111
- package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +71 -70
- 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/outputs/OutputsButton.js +254 -0
- package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +24 -14
- package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
- package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
- 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/restore-piece.js +192 -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/section-structure.js +241 -0
- package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +125 -103
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +215 -105
- package/dist/shared/components/layout-editor/settings/WhoSection.js +139 -100
- package/dist/shared/components/layout-editor/settings/controls.js +8 -8
- package/dist/shared/components/layout-editor/settings/settings-registry.js +142 -21
- 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/staged-api.js +64 -0
- package/dist/shared/components/layout-editor/structure-ops.js +403 -0
- package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +556 -0
- package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
- package/dist/shared/components/layout-editor/testing/testing-model.js +406 -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/AbTestSection.js +355 -0
- package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +232 -0
- package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
- package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -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 -306
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
- package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
- package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
- package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
- package/dist/shared/components/profile/AgentsPanel.js +479 -0
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
- package/dist/shared/components/support/SuggestFormChange.js +143 -0
- package/dist/shared/components/support/SupportAnalytics.js +171 -0
- package/dist/shared/components/support/SupportView.js +75 -73
- package/dist/shared/lib/ai-fill.js +37 -0
- package/dist/shared/lib/background-runs.js +150 -0
- package/dist/shared/lib/delivery-ack.js +9 -0
- package/dist/shared/lib/entry-badge-style.js +13 -0
- package/dist/shared/lib/entry-config.js +71 -0
- package/dist/shared/lib/form-sections.js +64 -0
- package/dist/shared/lib/form-structure.js +99 -0
- package/dist/shared/lib/form-usage-beacon.js +133 -0
- package/dist/shared/lib/jobs-tray.js +25 -23
- package/dist/shared/lib/keyset-pager.js +37 -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 +116 -110
- package/dist/shared/lib/layout-resolve.js +113 -0
- package/dist/shared/lib/placement-behaviour.js +144 -0
- package/dist/shared/lib/prefetch.js +149 -0
- package/dist/shared/lib/presence-hooks.js +199 -0
- package/dist/shared/lib/record-outbox.js +82 -81
- package/dist/shared/lib/replay-socket.js +93 -0
- package/dist/shared/lib/request-gate.js +51 -50
- package/dist/shared/lib/room-gaps.js +96 -0
- package/dist/shared/lib/screenshot.js +54 -28
- package/dist/shared/lib/search-log.js +27 -0
- package/dist/shared/lib/socket-realtime.js +101 -80
- package/dist/shared/lib/visible-when.js +34 -0
- package/dist/shared/lib/worker-socket.js +200 -0
- package/package.json +1 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { jsxs as s, jsx as t, Fragment as W } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronsDownUp as Y, Rows3 as z } from "lucide-react";
|
|
3
|
+
import { useState as _, useMemo as u } from "react";
|
|
4
|
+
import { UNGROUPED_KEY as B } from "../../../lib/layout-ops.js";
|
|
5
|
+
import { titleCase as C } from "../../../lib/utils.js";
|
|
6
|
+
import { Skeleton as $ } from "../../ui/skeleton.js";
|
|
7
|
+
import { Toggle as H } from "../settings/controls.js";
|
|
8
|
+
import { AbTestSection as J } from "./AbTestSection.js";
|
|
9
|
+
import { suggestCollapse as Q, rateText as V } from "./suggest-collapse.js";
|
|
10
|
+
import { suggestSections as X } from "./suggest-sections.js";
|
|
11
|
+
import { useLayoutUsageToday as Z, useLayoutFriction as ee, useCoChanges as te, formatDuration as ae } from "./usage-api.js";
|
|
12
|
+
const i = "px-3 pb-1.5 pt-4 text-[12px] font-semibold text-slate-700 dark:text-foreground", d = "px-3 text-[12px] leading-snug text-slate-500 dark:text-muted-foreground";
|
|
13
|
+
function c({ label: n, value: m }) {
|
|
14
|
+
return /* @__PURE__ */ s("div", { className: "flex flex-col gap-0.5 bg-white px-2.5 py-2 dark:bg-card", children: [
|
|
15
|
+
/* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: n }),
|
|
16
|
+
/* @__PURE__ */ t("span", { className: "text-[14px] font-semibold tabular-nums text-slate-900 dark:text-foreground", children: m })
|
|
17
|
+
] });
|
|
18
|
+
}
|
|
19
|
+
function j({ children: n }) {
|
|
20
|
+
return /* @__PURE__ */ t("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: n });
|
|
21
|
+
}
|
|
22
|
+
function ge({
|
|
23
|
+
bundle: n,
|
|
24
|
+
collection: m,
|
|
25
|
+
fields: b,
|
|
26
|
+
apply: N,
|
|
27
|
+
showFill: M,
|
|
28
|
+
onShowFill: U,
|
|
29
|
+
onOpenLayout: D
|
|
30
|
+
}) {
|
|
31
|
+
var S;
|
|
32
|
+
const v = Number(n.layout.id), { data: o, isLoading: P } = Z(v), { data: a, isLoading: p } = ee(v), { data: h, isLoading: T } = te(m), [k, R] = _(() => /* @__PURE__ */ new Set()), [E, F] = _(!1), y = u(() => {
|
|
33
|
+
const e = new Map(b.map((l) => [l.field, l.label || C(l.field)]));
|
|
34
|
+
return (l) => e.get(l) ?? C(l);
|
|
35
|
+
}, [b]), g = (e) => {
|
|
36
|
+
var l;
|
|
37
|
+
return e == null || e === B ? "Ungrouped" : ((l = n.groups.find((x) => x.key === e)) == null ? void 0 : l.label) ?? e;
|
|
38
|
+
}, O = (e) => e === "__form__" ? "Whole form" : e === "__general__" ? "General" : g(e), A = u(() => new Set(n.placements.map((e) => e.field)), [n.placements]), w = u(
|
|
39
|
+
() => X(n, (h == null ? void 0 : h.pairs) ?? []).filter((e) => !k.has(e.id)),
|
|
40
|
+
[n, h, k]
|
|
41
|
+
), r = u(
|
|
42
|
+
() => Q(n, (a == null ? void 0 : a.sections) ?? []),
|
|
43
|
+
[n, a == null ? void 0 : a.sections]
|
|
44
|
+
), f = (a == null ? void 0 : a.steps) ?? [], G = Math.max(1, ...f.map((e) => e.avg_ms)), L = ((a == null ? void 0 : a.changed_after_save.fields) ?? []).slice(0, 8), q = o && !o.ready || a && !a.ready;
|
|
45
|
+
return /* @__PURE__ */ s("div", { "data-editor-usage": "", className: "flex flex-col pb-4", children: [
|
|
46
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-2 px-3 pt-3", children: [
|
|
47
|
+
/* @__PURE__ */ t("span", { className: "text-[12.5px] text-slate-700 dark:text-foreground", children: "Show how full each field is" }),
|
|
48
|
+
/* @__PURE__ */ t(H, { label: "Show how full each field is", checked: M, onChange: U })
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ t("p", { className: `${d} pt-1`, children: "Each field on the form shows the share of records that have a value." }),
|
|
51
|
+
q && /* @__PURE__ */ t("p", { role: "note", className: `${d} pt-3`, children: "Usage is not being recorded on this instance yet (its database needs the latest update)." }),
|
|
52
|
+
/* @__PURE__ */ t("p", { className: i, children: "Today" }),
|
|
53
|
+
P ? /* @__PURE__ */ t($, { className: "mx-3 h-12 rounded-lg" }) : /* @__PURE__ */ s(j, { children: [
|
|
54
|
+
/* @__PURE__ */ t(c, { label: "Opens", value: ((o == null ? void 0 : o.opens) ?? 0).toLocaleString() }),
|
|
55
|
+
/* @__PURE__ */ t(c, { label: "People", value: ((o == null ? void 0 : o.people) ?? 0).toLocaleString() }),
|
|
56
|
+
/* @__PURE__ */ t(c, { label: "Records", value: ((o == null ? void 0 : o.records) ?? 0).toLocaleString() })
|
|
57
|
+
] }),
|
|
58
|
+
/* @__PURE__ */ s("p", { className: i, children: [
|
|
59
|
+
"Last ",
|
|
60
|
+
(a == null ? void 0 : a.days) ?? 30,
|
|
61
|
+
" days"
|
|
62
|
+
] }),
|
|
63
|
+
p ? /* @__PURE__ */ t($, { className: "mx-3 h-12 rounded-lg" }) : /* @__PURE__ */ s(j, { children: [
|
|
64
|
+
/* @__PURE__ */ t(c, { label: "Opens", value: ((a == null ? void 0 : a.opens) ?? 0).toLocaleString() }),
|
|
65
|
+
/* @__PURE__ */ t(c, { label: "Saves", value: ((a == null ? void 0 : a.saves) ?? 0).toLocaleString() }),
|
|
66
|
+
/* @__PURE__ */ t(c, { label: "Left unfinished", value: ((a == null ? void 0 : a.abandons) ?? 0).toLocaleString() })
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ t("p", { className: i, children: "Time per step" }),
|
|
69
|
+
f.length === 0 ? /* @__PURE__ */ t("p", { className: d, children: p ? "Loading…" : "No visits recorded yet." }) : /* @__PURE__ */ t("ul", { "data-usage-steps": "", className: "flex flex-col gap-2 px-3", children: f.map((e) => /* @__PURE__ */ s("li", { className: "flex flex-col gap-1", children: [
|
|
70
|
+
/* @__PURE__ */ s("div", { className: "flex items-baseline justify-between gap-2 text-[12px]", children: [
|
|
71
|
+
/* @__PURE__ */ t("span", { className: "truncate text-slate-800 dark:text-foreground", children: O(e.key) }),
|
|
72
|
+
/* @__PURE__ */ s("span", { className: "shrink-0 tabular-nums text-slate-500 dark:text-muted-foreground", children: [
|
|
73
|
+
ae(e.avg_ms),
|
|
74
|
+
e.abandons > 0 && /* @__PURE__ */ s("span", { className: "text-amber-700 dark:text-amber-300", children: [
|
|
75
|
+
" · ",
|
|
76
|
+
e.abandons,
|
|
77
|
+
" left here"
|
|
78
|
+
] })
|
|
79
|
+
] })
|
|
80
|
+
] }),
|
|
81
|
+
/* @__PURE__ */ t("div", { className: "h-1.5 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ t(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
className: "h-full rounded-full bg-slate-400 dark:bg-slate-500",
|
|
85
|
+
style: { width: `${Math.max(2, Math.round(e.avg_ms / G * 100))}%` }
|
|
86
|
+
}
|
|
87
|
+
) })
|
|
88
|
+
] }, e.key)) }),
|
|
89
|
+
/* @__PURE__ */ t("p", { className: i, children: "Changed soon after saving" }),
|
|
90
|
+
L.length === 0 ? /* @__PURE__ */ t("p", { className: d, children: p ? "Loading…" : "No field was changed within a day of a record being created." }) : /* @__PURE__ */ s(W, { children: [
|
|
91
|
+
/* @__PURE__ */ t("ul", { "data-usage-changed": "", className: "flex flex-col px-3", children: L.map((e) => /* @__PURE__ */ s(
|
|
92
|
+
"li",
|
|
93
|
+
{
|
|
94
|
+
className: "flex items-baseline justify-between gap-2 border-b border-slate-100 py-1 text-[12px] last:border-0 dark:border-border",
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 truncate text-slate-800 dark:text-foreground", children: [
|
|
97
|
+
y(e.field),
|
|
98
|
+
!A.has(e.field) && /* @__PURE__ */ s("span", { className: "text-slate-400 dark:text-muted-foreground", children: [
|
|
99
|
+
" ",
|
|
100
|
+
"· not on this form"
|
|
101
|
+
] })
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ s("span", { className: "shrink-0 tabular-nums text-slate-500 dark:text-muted-foreground", children: [
|
|
104
|
+
e.changes.toLocaleString(),
|
|
105
|
+
"×"
|
|
106
|
+
] })
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
e.field
|
|
110
|
+
)) }),
|
|
111
|
+
/* @__PURE__ */ s("p", { className: `${d} pt-1`, children: [
|
|
112
|
+
"Edits within 24 hours of a record being created, last 90 days",
|
|
113
|
+
(a == null ? void 0 : a.changed_after_save.scope) === "collection" ? ", across every form of this collection." : ", on records opened with this form."
|
|
114
|
+
] })
|
|
115
|
+
] }),
|
|
116
|
+
/* @__PURE__ */ t("p", { className: i, children: "Rarely opened sections" }),
|
|
117
|
+
p ? /* @__PURE__ */ t("p", { className: d, children: "Loading…" }) : r.candidates.length === 0 || E ? /* @__PURE__ */ t("p", { className: d, children: (S = a == null ? void 0 : a.sections) != null && S.length ? "No suggestion. People open every section that starts open often enough." : "No section visits recorded yet." }) : /* @__PURE__ */ s(
|
|
118
|
+
"div",
|
|
119
|
+
{
|
|
120
|
+
"data-usage-collapse": "",
|
|
121
|
+
className: "mx-3 flex flex-col gap-2 rounded-lg border border-slate-200 bg-white p-2.5 dark:border-border dark:bg-card",
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ s("p", { className: "m-0 text-[12px] leading-snug text-slate-700 dark:text-foreground", children: [
|
|
124
|
+
/* @__PURE__ */ t(Y, { className: "mr-1 inline h-3.5 w-3.5 align-[-2px] text-slate-400" }),
|
|
125
|
+
"People rarely open",
|
|
126
|
+
" ",
|
|
127
|
+
r.candidates.length === 1 ? "this section" : "these sections",
|
|
128
|
+
". Starting",
|
|
129
|
+
" ",
|
|
130
|
+
r.candidates.length === 1 ? "it" : "them",
|
|
131
|
+
" collapsed keeps the form shorter."
|
|
132
|
+
] }),
|
|
133
|
+
/* @__PURE__ */ t("ul", { className: "m-0 flex list-none flex-col p-0", children: r.candidates.map((e) => /* @__PURE__ */ s(
|
|
134
|
+
"li",
|
|
135
|
+
{
|
|
136
|
+
"data-usage-collapse-section": e.key,
|
|
137
|
+
className: "flex flex-col border-b border-slate-100 py-1 text-[12px] last:border-0 dark:border-border",
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ t("span", { className: "truncate text-slate-800 dark:text-foreground", children: e.label }),
|
|
140
|
+
/* @__PURE__ */ s("span", { className: "tabular-nums text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
141
|
+
"opened in ",
|
|
142
|
+
V(e.rate),
|
|
143
|
+
" of ",
|
|
144
|
+
e.shown.toLocaleString(),
|
|
145
|
+
" visits"
|
|
146
|
+
] })
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
e.key
|
|
150
|
+
)) }),
|
|
151
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
|
|
152
|
+
/* @__PURE__ */ t(
|
|
153
|
+
"button",
|
|
154
|
+
{
|
|
155
|
+
type: "button",
|
|
156
|
+
onClick: () => N(r.ops, {
|
|
157
|
+
label: r.candidates.length === 1 ? `Collapse ${r.candidates[0].label}` : `Collapse ${r.candidates.length} rarely opened sections`
|
|
158
|
+
}),
|
|
159
|
+
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",
|
|
160
|
+
children: r.candidates.length === 1 ? "Start it collapsed" : `Start all ${r.candidates.length} collapsed`
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ t(
|
|
164
|
+
"button",
|
|
165
|
+
{
|
|
166
|
+
type: "button",
|
|
167
|
+
onClick: () => F(!0),
|
|
168
|
+
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",
|
|
169
|
+
children: "Not now"
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] })
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ s("p", { className: `${d} pt-1`, children: [
|
|
177
|
+
"A section counts as opened when someone expands it, clicks in it or types in it. Last",
|
|
178
|
+
" ",
|
|
179
|
+
(a == null ? void 0 : a.days) ?? 30,
|
|
180
|
+
" days."
|
|
181
|
+
] }),
|
|
182
|
+
/* @__PURE__ */ t("p", { className: i, children: "Suggested sections" }),
|
|
183
|
+
T ? /* @__PURE__ */ t("p", { className: d, children: "Loading…" }) : w.length === 0 ? /* @__PURE__ */ t("p", { className: d, children: "No suggestions. Fields people change together already sit together on this form." }) : /* @__PURE__ */ t("ul", { "data-usage-suggestions": "", className: "flex flex-col gap-2 px-3", children: w.map((e) => {
|
|
184
|
+
const l = e.fields.map(y), x = l.length > 1 ? `${l.slice(0, -1).join(", ")} and ${l[l.length - 1]}` : l[0], I = [...new Set(Object.values(e.from).map(g))];
|
|
185
|
+
return /* @__PURE__ */ s(
|
|
186
|
+
"li",
|
|
187
|
+
{
|
|
188
|
+
"data-usage-suggestion": e.id,
|
|
189
|
+
className: "flex flex-col gap-2 rounded-lg border border-slate-200 bg-white p-2.5 dark:border-border dark:bg-card",
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ s("p", { className: "m-0 text-[12px] leading-snug text-slate-700 dark:text-foreground", children: [
|
|
192
|
+
/* @__PURE__ */ t(z, { className: "mr-1 inline h-3.5 w-3.5 align-[-2px] text-slate-400" }),
|
|
193
|
+
"People usually change ",
|
|
194
|
+
/* @__PURE__ */ t("b", { className: "font-semibold", children: x }),
|
|
195
|
+
" together, but they sit in ",
|
|
196
|
+
I.join(" and "),
|
|
197
|
+
"."
|
|
198
|
+
] }),
|
|
199
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
|
|
200
|
+
/* @__PURE__ */ s(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
type: "button",
|
|
204
|
+
onClick: () => N(e.ops, { label: `Move ${x} into ${g(e.target)}` }),
|
|
205
|
+
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",
|
|
206
|
+
children: [
|
|
207
|
+
"Move into ",
|
|
208
|
+
g(e.target)
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ t(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
type: "button",
|
|
216
|
+
onClick: () => R((K) => new Set(K).add(e.id)),
|
|
217
|
+
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",
|
|
218
|
+
children: "Not now"
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
] })
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
e.id
|
|
225
|
+
);
|
|
226
|
+
}) }),
|
|
227
|
+
/* @__PURE__ */ t(J, { bundle: n, collection: m, onOpenLayout: D })
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
export {
|
|
231
|
+
ge as UsagePanel
|
|
232
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useQuery as m, useQueryClient as p } from "@tanstack/react-query";
|
|
2
|
+
import { useCallback as q } from "react";
|
|
3
|
+
import { useNivaroClient as c } from "../../../context.js";
|
|
4
|
+
import { get as b, del as $, post as d } from "../../../lib/commands.js";
|
|
5
|
+
import { useInvalidateLayouts as v } from "../overview/overview-api.js";
|
|
6
|
+
const f = {
|
|
7
|
+
test: (t) => ["layout-editor", "ab-test", t],
|
|
8
|
+
results: (t) => ["layout-editor", "ab-test", t, "results"],
|
|
9
|
+
roles: () => ["layout-editor", "ab-test", "roles"]
|
|
10
|
+
}, y = (t, e) => (t == null ? void 0 : t.data) ?? e;
|
|
11
|
+
function T(t) {
|
|
12
|
+
const e = c();
|
|
13
|
+
return m({
|
|
14
|
+
queryKey: f.test(t),
|
|
15
|
+
queryFn: async () => y(
|
|
16
|
+
await e.request(b(`/collection-layouts/${t}/ab-test`)),
|
|
17
|
+
null
|
|
18
|
+
),
|
|
19
|
+
staleTime: 3e4,
|
|
20
|
+
retry: !1
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function g(t, e) {
|
|
24
|
+
const o = c();
|
|
25
|
+
return m({
|
|
26
|
+
queryKey: f.results(t),
|
|
27
|
+
queryFn: async () => y(
|
|
28
|
+
await o.request(b(`/collection-layouts/${t}/ab-test/results`)),
|
|
29
|
+
null
|
|
30
|
+
),
|
|
31
|
+
enabled: e,
|
|
32
|
+
staleTime: 5 * 6e4,
|
|
33
|
+
retry: !1
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function k(t) {
|
|
37
|
+
const e = c();
|
|
38
|
+
return m({
|
|
39
|
+
queryKey: f.roles(),
|
|
40
|
+
queryFn: async () => y(
|
|
41
|
+
await e.request(b("/roles")),
|
|
42
|
+
[]
|
|
43
|
+
).filter((s) => !s.admin_access).map((s) => ({ id: String(s.id), name: String(s.name) })).sort((s, r) => s.name.localeCompare(r.name)),
|
|
44
|
+
enabled: t,
|
|
45
|
+
staleTime: 5 * 6e4
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function N(t, e) {
|
|
49
|
+
const o = c(), s = p(), r = v(e), w = q(async () => {
|
|
50
|
+
await s.invalidateQueries({ queryKey: ["layout-editor", "ab-test"] }), r();
|
|
51
|
+
}, [s, r]);
|
|
52
|
+
return {
|
|
53
|
+
/** A copy of this form to change and test (create_hidden, never the default). */
|
|
54
|
+
copy: async (n) => {
|
|
55
|
+
var i;
|
|
56
|
+
for (let u = 1; u <= 5; u++)
|
|
57
|
+
try {
|
|
58
|
+
const a = await o.request(
|
|
59
|
+
d(`/collection-layouts/${t}/clone`, {
|
|
60
|
+
name: u === 1 ? `${n} (new version)` : `${n} (new version ${u})`
|
|
61
|
+
})
|
|
62
|
+
), l = Number(y(a, {}).id);
|
|
63
|
+
if (Number.isFinite(l) && l > 0) return l;
|
|
64
|
+
break;
|
|
65
|
+
} catch (a) {
|
|
66
|
+
if (((a == null ? void 0 : a.status) ?? ((i = a == null ? void 0 : a.response) == null ? void 0 : i.status)) !== 409) throw a;
|
|
67
|
+
}
|
|
68
|
+
throw new Error("Could not copy this form");
|
|
69
|
+
},
|
|
70
|
+
start: async (n, i) => {
|
|
71
|
+
await o.request(
|
|
72
|
+
d(`/collection-layouts/${t}/ab-test`, { variant_id: n, role_id: i })
|
|
73
|
+
), await w();
|
|
74
|
+
},
|
|
75
|
+
end: async (n) => {
|
|
76
|
+
await o.request($(`/collection-layouts/${t}/ab-test?keep=${n}`)), await w();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
f as abKeys,
|
|
82
|
+
N as useAbActions,
|
|
83
|
+
g as useAbResults,
|
|
84
|
+
T as useAbTest,
|
|
85
|
+
k as useSplittableRoles
|
|
86
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const h = 20, y = 0.1;
|
|
2
|
+
function _(e, p, r = {}) {
|
|
3
|
+
const u = r.minShown ?? 20, f = r.maxRate ?? 0.1;
|
|
4
|
+
if (e.layout.accordion_mode) return { candidates: [], ops: [] };
|
|
5
|
+
const i = e.groups, c = /* @__PURE__ */ new Map();
|
|
6
|
+
for (const n of [...i].sort((o, t) => o.sort - t.sort || (o.id ?? 0) - (t.id ?? 0))) {
|
|
7
|
+
if (n.type !== "section") continue;
|
|
8
|
+
const o = n.parent_key ?? "";
|
|
9
|
+
c.has(o) || c.set(o, n.key);
|
|
10
|
+
}
|
|
11
|
+
const d = new Map(p.map((n) => [n.key, n])), s = [];
|
|
12
|
+
for (const n of i) {
|
|
13
|
+
if (n.type !== "section" || n.is_collapsed || c.get(n.parent_key ?? "") === n.key) continue;
|
|
14
|
+
const o = d.get(n.key);
|
|
15
|
+
if (!o || o.shown < u) continue;
|
|
16
|
+
const t = Math.min(o.opened, o.shown), a = t / o.shown;
|
|
17
|
+
a > f || s.push({ key: n.key, label: n.label || n.key, shown: o.shown, opened: t, rate: a });
|
|
18
|
+
}
|
|
19
|
+
return s.sort((n, o) => n.rate - o.rate || o.shown - n.shown), {
|
|
20
|
+
candidates: s,
|
|
21
|
+
ops: s.map((n) => ({ op: "group_update", key: n.key, patch: { is_collapsed: !0 } }))
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function k(e) {
|
|
25
|
+
return e <= 0 ? "none" : e < 0.01 ? "under 1%" : `${Math.round(e * 100)}%`;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
y as MAX_OPEN_RATE,
|
|
29
|
+
h as MIN_SHOWN,
|
|
30
|
+
k as rateText,
|
|
31
|
+
_ as suggestCollapse
|
|
32
|
+
};
|
|
@@ -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
|
+
};
|