@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,150 @@
|
|
|
1
|
+
import { jsxs as i, Fragment as w, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { BookMarked as C, X as R } from "lucide-react";
|
|
3
|
+
import { useState as u } from "react";
|
|
4
|
+
import { toast as p } from "sonner";
|
|
5
|
+
import { useNivaroClient as $ } from "../../../context.js";
|
|
6
|
+
import { cn as j } from "../../../lib/utils.js";
|
|
7
|
+
import { sectionOp as F } from "../add-target.js";
|
|
8
|
+
import { apiFailure as v } from "../overview/overview-api.js";
|
|
9
|
+
import { useFieldMapping as M, FieldMapStep as B } from "./FieldMapStep.js";
|
|
10
|
+
import { useTemplates as S, useRefreshTemplates as A, planBlock as T, leftOutWords as L, deleteTemplate as O } from "./reuse-api.js";
|
|
11
|
+
import { reusePrimary as E } from "./SectionReuseActions.js";
|
|
12
|
+
const I = "px-2 pb-1 pt-3 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground";
|
|
13
|
+
function K(e, t) {
|
|
14
|
+
const r = F(e, t);
|
|
15
|
+
return r.op === "group_create" && r.parent_key === null ? r.index : void 0;
|
|
16
|
+
}
|
|
17
|
+
function P({ t: e, ...t }) {
|
|
18
|
+
const r = $(), n = A(), [f, c] = u(!1), [y, h] = u(!1), [s, x] = u(!1), m = !!e.source_collection && e.source_collection !== t.collection, a = M(m ? e.fields : [], e.source_collection, t.collection), b = async () => {
|
|
19
|
+
if (!s) {
|
|
20
|
+
if (m && !f && a.needed.length) {
|
|
21
|
+
c(!0);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
x(!0);
|
|
25
|
+
try {
|
|
26
|
+
const l = await T(r, {
|
|
27
|
+
source: { template_id: e.id },
|
|
28
|
+
target_collection: t.collection,
|
|
29
|
+
target_bundle: t.bundle,
|
|
30
|
+
field_map: m ? a.map : void 0,
|
|
31
|
+
index: K(t.bundle, t.selected)
|
|
32
|
+
});
|
|
33
|
+
if (!l.ops.length) throw new Error("Nothing to add");
|
|
34
|
+
t.apply(l.ops, { label: `Add ${e.name}` });
|
|
35
|
+
const d = l.ops.find((_) => _.op === "group_create");
|
|
36
|
+
(d == null ? void 0 : d.op) === "group_create" && t.onSelect({ kind: "group", key: d.key });
|
|
37
|
+
const g = L(l);
|
|
38
|
+
g && p(`${e.name} added: ${g}`), c(!1);
|
|
39
|
+
} catch (l) {
|
|
40
|
+
p.error(v(l, "Could not add the section").message);
|
|
41
|
+
} finally {
|
|
42
|
+
x(!1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, k = async () => {
|
|
46
|
+
try {
|
|
47
|
+
await O(r, e.id), n("section");
|
|
48
|
+
} catch (l) {
|
|
49
|
+
p.error(v(l, "Could not remove it").message);
|
|
50
|
+
}
|
|
51
|
+
}, N = [
|
|
52
|
+
`${e.fields.length} ${e.fields.length === 1 ? "field" : "fields"}`,
|
|
53
|
+
e.source_collection && e.source_collection !== t.collection ? `from ${e.source_collection}` : null,
|
|
54
|
+
e.description
|
|
55
|
+
].filter(Boolean).join(" · ");
|
|
56
|
+
return /* @__PURE__ */ i("div", { "data-library-section": e.id, children: [
|
|
57
|
+
/* @__PURE__ */ i("div", { className: "group flex items-center gap-0.5", children: [
|
|
58
|
+
/* @__PURE__ */ i(
|
|
59
|
+
"button",
|
|
60
|
+
{
|
|
61
|
+
type: "button",
|
|
62
|
+
disabled: s || a.loading,
|
|
63
|
+
onClick: () => void b(),
|
|
64
|
+
className: "flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted disabled:opacity-60",
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ i("span", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
67
|
+
/* @__PURE__ */ o("span", { className: "truncate text-[12.5px] font-medium text-slate-900 dark:text-foreground", children: e.name }),
|
|
68
|
+
/* @__PURE__ */ o("span", { className: "truncate text-[11.5px] text-slate-500 dark:text-muted-foreground", children: N })
|
|
69
|
+
] }),
|
|
70
|
+
/* @__PURE__ */ o(C, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
/* @__PURE__ */ o(
|
|
75
|
+
"button",
|
|
76
|
+
{
|
|
77
|
+
type: "button",
|
|
78
|
+
"aria-label": `Remove ${e.name} from the library`,
|
|
79
|
+
"data-tip": "Remove from the library",
|
|
80
|
+
onClick: () => h(!0),
|
|
81
|
+
className: "invisible inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-slate-400 transition-colors hover:bg-muted hover:text-slate-700 group-hover:visible focus-visible:visible dark:hover:text-foreground",
|
|
82
|
+
children: /* @__PURE__ */ o(R, { className: "h-3.5 w-3.5" })
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
] }),
|
|
86
|
+
y && /* @__PURE__ */ i("div", { className: "mx-2 mb-1 flex items-center gap-2 text-[12px] text-slate-600 dark:text-muted-foreground", children: [
|
|
87
|
+
/* @__PURE__ */ o("span", { className: "flex-1", children: "Remove from the library? Forms keep their copies." }),
|
|
88
|
+
/* @__PURE__ */ o(
|
|
89
|
+
"button",
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
onClick: () => void k(),
|
|
93
|
+
className: "font-medium text-red-600 hover:underline dark:text-red-400",
|
|
94
|
+
children: "Remove"
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ o("button", { type: "button", onClick: () => h(!1), className: "hover:underline", children: "Keep" })
|
|
98
|
+
] }),
|
|
99
|
+
f && /* @__PURE__ */ i(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className: j(
|
|
103
|
+
"mx-1 mb-2 rounded-md border border-slate-200 bg-slate-50 p-2 dark:border-border dark:bg-muted/40"
|
|
104
|
+
),
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ o(
|
|
107
|
+
B,
|
|
108
|
+
{
|
|
109
|
+
needed: a.needed,
|
|
110
|
+
map: a.map,
|
|
111
|
+
onChange: a.setMap,
|
|
112
|
+
targetCollection: t.collection
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ i("div", { className: "mt-2 flex justify-end gap-2", children: [
|
|
116
|
+
/* @__PURE__ */ o(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
type: "button",
|
|
120
|
+
onClick: () => c(!1),
|
|
121
|
+
className: "text-[12px] text-slate-500 hover:underline dark:text-muted-foreground",
|
|
122
|
+
children: "Cancel"
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ o(
|
|
126
|
+
"button",
|
|
127
|
+
{
|
|
128
|
+
type: "button",
|
|
129
|
+
className: E,
|
|
130
|
+
disabled: s,
|
|
131
|
+
onClick: () => void b(),
|
|
132
|
+
children: s ? "Adding…" : "Add section"
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
] })
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] });
|
|
140
|
+
}
|
|
141
|
+
function Y(e) {
|
|
142
|
+
const { data: t = [] } = S("section"), r = t.filter((n) => e.matches(n.name, n.description, ...n.fields));
|
|
143
|
+
return r.length ? /* @__PURE__ */ i(w, { children: [
|
|
144
|
+
/* @__PURE__ */ o("p", { className: I, children: "Section library" }),
|
|
145
|
+
r.map((n) => /* @__PURE__ */ o(P, { t: n, ...e }, n.id))
|
|
146
|
+
] }) : null;
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
Y as LibraryRows
|
|
150
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "lucide-react";
|
|
3
|
+
import "react";
|
|
4
|
+
import "sonner";
|
|
5
|
+
import { post as r } from "../../../lib/commands.js";
|
|
6
|
+
async function s(l, t) {
|
|
7
|
+
var i;
|
|
8
|
+
const o = await l.request(
|
|
9
|
+
r("/collection-layouts", {
|
|
10
|
+
collection: t.collection,
|
|
11
|
+
name: t.name,
|
|
12
|
+
layout_type: "grouped",
|
|
13
|
+
seed_fields: t.fields
|
|
14
|
+
})
|
|
15
|
+
), e = (i = o == null ? void 0 : o.data) == null ? void 0 : i.id;
|
|
16
|
+
return e == null ? null : Number(e);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
s as createFormFromFields
|
|
20
|
+
};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as V } from "@tanstack/react-query";
|
|
3
|
+
import { Copy as X, ChevronLeft as Y, BookmarkPlus as Z } from "lucide-react";
|
|
4
|
+
import { useState as u, useMemo as ee } from "react";
|
|
5
|
+
import { toast as v } from "sonner";
|
|
6
|
+
import { useNivaroClient as F } from "../../../context.js";
|
|
7
|
+
import { get as te } from "../../../lib/commands.js";
|
|
8
|
+
import { titleCase as T, cn as ae } from "../../../lib/utils.js";
|
|
9
|
+
import { Popover as M, PopoverTrigger as W, PopoverContent as A } from "../../ui/popover.js";
|
|
10
|
+
import { useLayoutOverview as oe, useInvalidateLayouts as ne, apiFailure as D } from "../overview/overview-api.js";
|
|
11
|
+
import { useFieldMapping as re, FieldMapStep as se } from "./FieldMapStep.js";
|
|
12
|
+
import { useRefreshTemplates as le, copySection as ie, leftOutWords as ce, saveTemplate as de } from "./reuse-api.js";
|
|
13
|
+
const K = "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted", Q = "inline-flex h-7 items-center gap-1.5 rounded-md bg-nvr-cyan px-2.5 text-[12px] font-semibold text-white transition-opacity hover:opacity-90 disabled:opacity-50", S = "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12.5px] text-slate-800 outline-none placeholder:text-slate-400 focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground", L = "mb-1 block text-[11.5px] font-semibold text-slate-600 dark:text-muted-foreground", q = "flex w-full items-center gap-2 truncate rounded px-2 py-1.5 text-left text-[12.5px] text-slate-700 hover:bg-muted dark:text-foreground";
|
|
14
|
+
function ue(s, r) {
|
|
15
|
+
const o = /* @__PURE__ */ new Set([r]);
|
|
16
|
+
for (let a = !0; a; ) {
|
|
17
|
+
a = !1;
|
|
18
|
+
for (const d of s.groups)
|
|
19
|
+
d.parent_key && o.has(d.parent_key) && !o.has(d.key) && (o.add(d.key), a = !0);
|
|
20
|
+
}
|
|
21
|
+
return [
|
|
22
|
+
...new Set(
|
|
23
|
+
s.placements.filter((a) => a.group_key && o.has(a.group_key) && !a.field.startsWith("__")).map((a) => a.field)
|
|
24
|
+
)
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function me(s) {
|
|
28
|
+
const r = F();
|
|
29
|
+
return V({
|
|
30
|
+
queryKey: ["layout-editor", "collection-names"],
|
|
31
|
+
queryFn: () => r.request(
|
|
32
|
+
te("/collections")
|
|
33
|
+
).then(
|
|
34
|
+
(o) => (o.data ?? []).filter((a) => !a.collection.startsWith("nivaro_")).map((a) => ({
|
|
35
|
+
collection: a.collection,
|
|
36
|
+
label: a.display_name || T(a.collection)
|
|
37
|
+
})).sort((a, d) => a.label.localeCompare(d.label))
|
|
38
|
+
),
|
|
39
|
+
enabled: s,
|
|
40
|
+
staleTime: 5 * 6e4
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function pe({
|
|
44
|
+
bundle: s,
|
|
45
|
+
collection: r,
|
|
46
|
+
group: o,
|
|
47
|
+
onCopied: a
|
|
48
|
+
}) {
|
|
49
|
+
const d = F(), [f, h] = u(!1), [i, y] = u(r), [b, m] = u(!1), [x, p] = u(""), [c, l] = u(null), [g, O] = u(!1), { data: N, isLoading: R } = oe(i), { data: E = [] } = me(f && b), z = ee(() => ue(s, o.key), [s, o.key]), k = re(z, r, i), G = ne(i), P = Number(s.layout.id), C = ((N == null ? void 0 : N.rows) ?? []).filter(
|
|
50
|
+
(t) => !(i === r && t.layout_id === P)
|
|
51
|
+
), j = o.label || T(o.key), w = x.trim().toLowerCase(), B = () => {
|
|
52
|
+
y(r), m(!1), p(""), l(null);
|
|
53
|
+
}, H = async () => {
|
|
54
|
+
var t;
|
|
55
|
+
if (!(c == null || g)) {
|
|
56
|
+
O(!0);
|
|
57
|
+
try {
|
|
58
|
+
const _ = await ie(d, c, {
|
|
59
|
+
source_layout_id: P,
|
|
60
|
+
group_key: o.key,
|
|
61
|
+
source_bundle: s,
|
|
62
|
+
field_map: i === r ? void 0 : k.map
|
|
63
|
+
});
|
|
64
|
+
G();
|
|
65
|
+
const J = ((t = C.find((U) => U.layout_id === c)) == null ? void 0 : t.name) ?? "the form", I = ce(_);
|
|
66
|
+
v.success(`Copied ${j} to ${J}${I ? ` (${I})` : ""}`), a == null || a(c, i), h(!1), B();
|
|
67
|
+
} catch (_) {
|
|
68
|
+
v.error(D(_, "Could not copy the section").message);
|
|
69
|
+
} finally {
|
|
70
|
+
O(!1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return /* @__PURE__ */ n(
|
|
75
|
+
M,
|
|
76
|
+
{
|
|
77
|
+
open: f,
|
|
78
|
+
onOpenChange: (t) => {
|
|
79
|
+
h(t), t || B();
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ e(W, { asChild: !0, children: /* @__PURE__ */ n("button", { type: "button", className: K, "data-reuse-copy": "", children: [
|
|
83
|
+
/* @__PURE__ */ e(X, { className: "h-3.5 w-3.5" }),
|
|
84
|
+
"Copy to layout…"
|
|
85
|
+
] }) }),
|
|
86
|
+
/* @__PURE__ */ n(A, { align: "start", className: "w-[340px] p-3", children: [
|
|
87
|
+
/* @__PURE__ */ n("p", { className: "mb-2 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: [
|
|
88
|
+
"Copy ",
|
|
89
|
+
/* @__PURE__ */ e("b", { className: "font-semibold text-slate-800 dark:text-foreground", children: j }),
|
|
90
|
+
" with its fields and settings. Tip: drag the section onto a form in the Forms list."
|
|
91
|
+
] }),
|
|
92
|
+
b ? /* @__PURE__ */ n($, { children: [
|
|
93
|
+
/* @__PURE__ */ n(
|
|
94
|
+
"button",
|
|
95
|
+
{
|
|
96
|
+
type: "button",
|
|
97
|
+
onClick: () => m(!1),
|
|
98
|
+
className: "mb-1 inline-flex items-center gap-0.5 text-[12px] text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5" }),
|
|
101
|
+
"Back"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ e(
|
|
106
|
+
"input",
|
|
107
|
+
{
|
|
108
|
+
value: x,
|
|
109
|
+
onChange: (t) => p(t.target.value),
|
|
110
|
+
placeholder: "Find a collection",
|
|
111
|
+
"aria-label": "Find a collection",
|
|
112
|
+
className: S
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ e("div", { className: "mt-1 max-h-[220px] overflow-y-auto overscroll-contain", children: E.filter(
|
|
116
|
+
(t) => !w || t.label.toLowerCase().includes(w) || t.collection.includes(w)
|
|
117
|
+
).slice(0, 60).map((t) => /* @__PURE__ */ n(
|
|
118
|
+
"button",
|
|
119
|
+
{
|
|
120
|
+
type: "button",
|
|
121
|
+
className: q,
|
|
122
|
+
onClick: () => {
|
|
123
|
+
y(t.collection), l(null), m(!1), p("");
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ e("span", { className: "truncate", children: t.label }),
|
|
127
|
+
/* @__PURE__ */ e("span", { className: "ml-auto shrink-0 font-mono text-[11px] text-slate-400", children: t.collection })
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
t.collection
|
|
131
|
+
)) })
|
|
132
|
+
] }) : /* @__PURE__ */ n($, { children: [
|
|
133
|
+
/* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
|
|
134
|
+
/* @__PURE__ */ n("span", { className: L, children: [
|
|
135
|
+
"Layouts of ",
|
|
136
|
+
/* @__PURE__ */ e("span", { className: "font-mono font-normal", children: i })
|
|
137
|
+
] }),
|
|
138
|
+
/* @__PURE__ */ e(
|
|
139
|
+
"button",
|
|
140
|
+
{
|
|
141
|
+
type: "button",
|
|
142
|
+
onClick: () => m(!0),
|
|
143
|
+
className: "mb-1 text-[11.5px] font-medium text-[#0089ad] hover:underline dark:text-nvr-cyan",
|
|
144
|
+
children: "Another collection…"
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ n(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
role: "listbox",
|
|
152
|
+
"aria-label": "Copy to layout",
|
|
153
|
+
className: "max-h-[200px] overflow-y-auto overscroll-contain",
|
|
154
|
+
children: [
|
|
155
|
+
C.map((t) => /* @__PURE__ */ e(
|
|
156
|
+
"button",
|
|
157
|
+
{
|
|
158
|
+
type: "button",
|
|
159
|
+
role: "option",
|
|
160
|
+
"aria-selected": c === t.layout_id,
|
|
161
|
+
"data-reuse-target": t.layout_id,
|
|
162
|
+
onClick: () => l(t.layout_id),
|
|
163
|
+
className: ae(q, c === t.layout_id && "bg-accent hover:bg-accent"),
|
|
164
|
+
children: /* @__PURE__ */ e("span", { className: "truncate", children: t.name })
|
|
165
|
+
},
|
|
166
|
+
t.layout_id
|
|
167
|
+
)),
|
|
168
|
+
!R && C.length === 0 && /* @__PURE__ */ e("p", { className: "px-2 py-1.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: "No other layout here yet." })
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
c != null && i !== r && /* @__PURE__ */ e("div", { className: "mt-2 border-t border-slate-200 pt-2 dark:border-border", children: /* @__PURE__ */ e(
|
|
173
|
+
se,
|
|
174
|
+
{
|
|
175
|
+
needed: k.needed,
|
|
176
|
+
map: k.map,
|
|
177
|
+
onChange: k.setMap,
|
|
178
|
+
targetCollection: i
|
|
179
|
+
}
|
|
180
|
+
) }),
|
|
181
|
+
/* @__PURE__ */ e("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ e(
|
|
182
|
+
"button",
|
|
183
|
+
{
|
|
184
|
+
type: "button",
|
|
185
|
+
className: Q,
|
|
186
|
+
disabled: c == null || g || k.loading,
|
|
187
|
+
onClick: () => void H(),
|
|
188
|
+
children: g ? "Copying…" : "Copy"
|
|
189
|
+
}
|
|
190
|
+
) })
|
|
191
|
+
] })
|
|
192
|
+
] })
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
function fe({ bundle: s, group: r }) {
|
|
198
|
+
const o = F(), a = le(), [d, f] = u(!1), [h, i] = u(""), [y, b] = u(""), [m, x] = u(!1), p = r.label || T(r.key), c = async () => {
|
|
199
|
+
const l = (h || p).trim();
|
|
200
|
+
if (!(!l || m)) {
|
|
201
|
+
x(!0);
|
|
202
|
+
try {
|
|
203
|
+
await de(o, {
|
|
204
|
+
kind: "section",
|
|
205
|
+
name: l,
|
|
206
|
+
description: y || null,
|
|
207
|
+
layout_id: Number(s.layout.id),
|
|
208
|
+
group_key: r.key,
|
|
209
|
+
bundle: s
|
|
210
|
+
}), a("section"), v.success(`Saved ${l} to the section library`), f(!1), i(""), b("");
|
|
211
|
+
} catch (g) {
|
|
212
|
+
v.error(D(g, "Could not save the section").message);
|
|
213
|
+
} finally {
|
|
214
|
+
x(!1);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
return /* @__PURE__ */ n(M, { open: d, onOpenChange: f, children: [
|
|
219
|
+
/* @__PURE__ */ e(W, { asChild: !0, children: /* @__PURE__ */ n("button", { type: "button", className: K, "data-reuse-save-section": "", children: [
|
|
220
|
+
/* @__PURE__ */ e(Z, { className: "h-3.5 w-3.5" }),
|
|
221
|
+
"Save to library…"
|
|
222
|
+
] }) }),
|
|
223
|
+
/* @__PURE__ */ n(A, { align: "start", className: "w-[320px] p-3", children: [
|
|
224
|
+
/* @__PURE__ */ e("p", { className: "mb-2 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: "Saved sections show under Add → Section library on every collection’s forms." }),
|
|
225
|
+
/* @__PURE__ */ n("label", { className: "block", children: [
|
|
226
|
+
/* @__PURE__ */ e("span", { className: L, children: "Name" }),
|
|
227
|
+
/* @__PURE__ */ e(
|
|
228
|
+
"input",
|
|
229
|
+
{
|
|
230
|
+
value: h,
|
|
231
|
+
placeholder: p,
|
|
232
|
+
onChange: (l) => i(l.target.value),
|
|
233
|
+
onKeyDown: (l) => {
|
|
234
|
+
l.key === "Enter" && c();
|
|
235
|
+
},
|
|
236
|
+
className: S
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ n("label", { className: "mt-2 block", children: [
|
|
241
|
+
/* @__PURE__ */ e("span", { className: L, children: "Description (optional)" }),
|
|
242
|
+
/* @__PURE__ */ e(
|
|
243
|
+
"input",
|
|
244
|
+
{
|
|
245
|
+
value: y,
|
|
246
|
+
onChange: (l) => b(l.target.value),
|
|
247
|
+
placeholder: "What it is for",
|
|
248
|
+
className: S
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
] }),
|
|
252
|
+
/* @__PURE__ */ e("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ e(
|
|
253
|
+
"button",
|
|
254
|
+
{
|
|
255
|
+
type: "button",
|
|
256
|
+
className: Q,
|
|
257
|
+
disabled: m,
|
|
258
|
+
onClick: () => void c(),
|
|
259
|
+
children: m ? "Saving…" : "Save"
|
|
260
|
+
}
|
|
261
|
+
) })
|
|
262
|
+
] })
|
|
263
|
+
] });
|
|
264
|
+
}
|
|
265
|
+
function Le({
|
|
266
|
+
bundle: s,
|
|
267
|
+
collection: r,
|
|
268
|
+
group: o
|
|
269
|
+
}) {
|
|
270
|
+
return /* @__PURE__ */ n(
|
|
271
|
+
"div",
|
|
272
|
+
{
|
|
273
|
+
"data-reuse-actions": "",
|
|
274
|
+
className: "flex flex-wrap gap-1.5 border-t border-slate-200 pt-3 dark:border-border",
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ e(pe, { bundle: s, collection: r, group: o }),
|
|
277
|
+
/* @__PURE__ */ e(fe, { bundle: s, group: o })
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
export {
|
|
283
|
+
pe as CopyToLayout,
|
|
284
|
+
fe as SaveSectionToLibrary,
|
|
285
|
+
Le as SectionReuseActions,
|
|
286
|
+
K as reuseBtn,
|
|
287
|
+
S as reuseInput,
|
|
288
|
+
L as reuseLabel,
|
|
289
|
+
Q as reusePrimary,
|
|
290
|
+
ue as sectionFields
|
|
291
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const w = (i) => i.toLowerCase().replace(/[^a-z0-9]/g, ""), M = (i) => i.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
2
|
+
function j(i, l, c) {
|
|
3
|
+
if (Math.abs(i.length - l.length) > c) return c + 1;
|
|
4
|
+
let s = Array.from({ length: l.length + 1 }, (f, o) => o);
|
|
5
|
+
for (let f = 1; f <= i.length; f++) {
|
|
6
|
+
const o = [f];
|
|
7
|
+
let a = f;
|
|
8
|
+
for (let t = 1; t <= l.length; t++)
|
|
9
|
+
o[t] = Math.min(s[t] + 1, o[t - 1] + 1, s[t - 1] + (i[f - 1] === l[t - 1] ? 0 : 1)), a = Math.min(a, o[t]);
|
|
10
|
+
if (a > c) return c + 1;
|
|
11
|
+
s = o;
|
|
12
|
+
}
|
|
13
|
+
return s[l.length];
|
|
14
|
+
}
|
|
15
|
+
function v(i, l, c = []) {
|
|
16
|
+
const s = new Set(c), f = new Map(l.map((t) => [t.field, t])), o = [], a = (t, e, u) => {
|
|
17
|
+
e && s.add(e), o.push({ input: t, field: e, how: e ? u : null });
|
|
18
|
+
};
|
|
19
|
+
for (const t of i) {
|
|
20
|
+
const e = t.trim();
|
|
21
|
+
if (!e) continue;
|
|
22
|
+
const u = l.filter((n) => !s.has(n.field));
|
|
23
|
+
if (f.has(e) && !s.has(e)) {
|
|
24
|
+
a(e, e, "exact");
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const r = w(e), m = u.find((n) => w(n.field) === r);
|
|
28
|
+
if (m) {
|
|
29
|
+
a(e, m.field, "same");
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const p = u.find((n) => n.label && w(n.label) === r);
|
|
33
|
+
if (p) {
|
|
34
|
+
a(e, p.field, "label");
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const b = r.length >= 8 ? 2 : r.length >= 4 ? 1 : 0;
|
|
38
|
+
let d = null;
|
|
39
|
+
for (const n of u)
|
|
40
|
+
for (const g of [n.field, n.label ?? ""]) {
|
|
41
|
+
if (!g) continue;
|
|
42
|
+
const h = j(r, w(g), b);
|
|
43
|
+
h <= b && (!d || h < d.d) && (d = { field: n.field, d: h });
|
|
44
|
+
}
|
|
45
|
+
if (!d) {
|
|
46
|
+
const n = M(e), g = n.length ? u.filter(
|
|
47
|
+
(h) => [h.field, h.label ?? ""].some((y) => {
|
|
48
|
+
const z = new Set(M(y));
|
|
49
|
+
return n.every((S) => z.has(S));
|
|
50
|
+
})
|
|
51
|
+
) : [];
|
|
52
|
+
g.length === 1 && (d = { field: g[0].field, d: 0 });
|
|
53
|
+
}
|
|
54
|
+
a(e, (d == null ? void 0 : d.field) ?? null, d ? "close" : null);
|
|
55
|
+
}
|
|
56
|
+
return o;
|
|
57
|
+
}
|
|
58
|
+
function k(i, l) {
|
|
59
|
+
const c = new Set(l.map((e) => e.field)), s = i.map((e) => typeof e == "string" ? { field: e } : e), f = s.filter((e) => !c.has(e.field)), o = s.filter((e) => c.has(e.field)).map((e) => e.field), a = v(
|
|
60
|
+
f.map((e) => e.field),
|
|
61
|
+
l,
|
|
62
|
+
o
|
|
63
|
+
), t = {};
|
|
64
|
+
return f.forEach((e, u) => {
|
|
65
|
+
var m, p;
|
|
66
|
+
let r = ((m = a[u]) == null ? void 0 : m.field) ?? null;
|
|
67
|
+
!r && e.label && (r = ((p = v([e.label], l, [
|
|
68
|
+
...o,
|
|
69
|
+
...Object.values(t).filter(Boolean)
|
|
70
|
+
])[0]) == null ? void 0 : p.field) ?? null), t[e.field] = r;
|
|
71
|
+
}), t;
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
v as matchNames,
|
|
75
|
+
w as squash,
|
|
76
|
+
k as suggestFieldMap
|
|
77
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useQueryClient as m, useQuery as f } from "@tanstack/react-query";
|
|
2
|
+
import { useCallback as d } from "react";
|
|
3
|
+
import { useNivaroClient as y } from "../../../context.js";
|
|
4
|
+
import { post as s, get as h, del as g } from "../../../lib/commands.js";
|
|
5
|
+
const c = {
|
|
6
|
+
templates: (e) => ["layout-editor", "templates", e]
|
|
7
|
+
}, q = (e) => {
|
|
8
|
+
const t = (e == null ? void 0 : e.data) ?? e;
|
|
9
|
+
return Array.isArray(t) ? t : [];
|
|
10
|
+
};
|
|
11
|
+
function T(e, t = !0) {
|
|
12
|
+
const n = y();
|
|
13
|
+
return f({
|
|
14
|
+
queryKey: c.templates(e),
|
|
15
|
+
queryFn: () => n.request(h("/collection-layouts/templates", { kind: e })).then(q),
|
|
16
|
+
enabled: t,
|
|
17
|
+
staleTime: 3e4
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function v() {
|
|
21
|
+
const e = m();
|
|
22
|
+
return d(
|
|
23
|
+
(t) => void e.invalidateQueries({ queryKey: c.templates(t) }),
|
|
24
|
+
[e]
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const u = (e) => ({ groups: e.groups, placements: e.placements });
|
|
28
|
+
function C(e, t) {
|
|
29
|
+
const { bundle: n, ...l } = t;
|
|
30
|
+
return e.request(
|
|
31
|
+
s("/collection-layouts/templates", { ...l, ...n ? { bundle: u(n) } : {} })
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function K(e, t) {
|
|
35
|
+
return e.request(g(`/collection-layouts/templates/${t}`));
|
|
36
|
+
}
|
|
37
|
+
function Q(e, t) {
|
|
38
|
+
const n = "bundle" in t.source && t.source.bundle ? { ...t.source, bundle: u(t.source.bundle) } : t.source;
|
|
39
|
+
return e.request(
|
|
40
|
+
s("/collection-layouts/blocks/plan", {
|
|
41
|
+
...t,
|
|
42
|
+
source: n,
|
|
43
|
+
target_bundle: {
|
|
44
|
+
layout: { layout_type: t.target_bundle.layout.layout_type },
|
|
45
|
+
...u(t.target_bundle)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function A(e, t, n) {
|
|
51
|
+
const { source_bundle: l, ...o } = n;
|
|
52
|
+
return e.request(
|
|
53
|
+
s(`/collection-layouts/${t}/copy-section`, {
|
|
54
|
+
...o,
|
|
55
|
+
...l ? { source_bundle: u(l) } : {}
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function O(e) {
|
|
60
|
+
var l, o, r;
|
|
61
|
+
const t = [], n = (a, i, p) => `${a} ${a === 1 ? i : p}`;
|
|
62
|
+
return (l = e.already) != null && l.length && t.push(`${n(e.already.length, "field was", "fields were")} already on the form`), (o = e.unmapped) != null && o.length && t.push(`${n(e.unmapped.length, "field", "fields")} with no match left out`), (r = e.dropped) != null && r.length && t.push("conditions written for the other collection were left out"), t.join("; ");
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
A as copySection,
|
|
66
|
+
K as deleteTemplate,
|
|
67
|
+
O as leftOutWords,
|
|
68
|
+
Q as planBlock,
|
|
69
|
+
c as reuseKeys,
|
|
70
|
+
C as saveTemplate,
|
|
71
|
+
v as useRefreshTemplates,
|
|
72
|
+
T as useTemplates
|
|
73
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const d = /* @__PURE__ */ new Set(["id", "user_created", "user_updated", "date_created", "date_updated"]), r = (e) => /^(group-|presentation-)/.test(e ?? "");
|
|
2
|
+
function n(e) {
|
|
3
|
+
return e == null ? !1 : typeof e == "string" ? e.trim() !== "" : Array.isArray(e) ? e.length > 0 : typeof e == "object" ? Object.keys(e).length > 0 : !0;
|
|
4
|
+
}
|
|
5
|
+
function s(e, i) {
|
|
6
|
+
return i.filter(
|
|
7
|
+
(t) => t.field && !t.field.startsWith("__") && !d.has(t.field) && !t.hidden && !r(t.type) && !r(t.interface) && n(e[t.field])
|
|
8
|
+
).map((t) => t.field);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
n as isFilled,
|
|
12
|
+
s as recordSeedFields
|
|
13
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useState as y, useCallback as F } from "react";
|
|
2
|
+
import { toast as c } from "sonner";
|
|
3
|
+
import { useNivaroClient as $ } from "../../../context.js";
|
|
4
|
+
import { get as g } from "../../../lib/commands.js";
|
|
5
|
+
import { useCollectionMeta as C } from "../inspector/field-context.js";
|
|
6
|
+
import { useInvalidateLayouts as b, apiFailure as h } from "../overview/overview-api.js";
|
|
7
|
+
import { createFormFromFields as k } from "./NewFormStart.js";
|
|
8
|
+
import { recordSeedFields as v } from "./seed.js";
|
|
9
|
+
function x(e) {
|
|
10
|
+
const a = $(), { data: t } = C(e), l = b(e), [n, u] = y(!1);
|
|
11
|
+
return { make: F(
|
|
12
|
+
async (p, w) => {
|
|
13
|
+
if (n) return null;
|
|
14
|
+
u(!0);
|
|
15
|
+
try {
|
|
16
|
+
const r = await a.request(
|
|
17
|
+
g(`/items/${encodeURIComponent(e)}/${encodeURIComponent(String(p))}`)
|
|
18
|
+
);
|
|
19
|
+
if (!(r != null && r.data)) throw new Error("That record could not be read");
|
|
20
|
+
const s = v(r.data, (t == null ? void 0 : t.fields) ?? []);
|
|
21
|
+
if (!s.length) throw new Error("This record has nothing filled in yet");
|
|
22
|
+
const d = `Form from ${w}`.slice(0, 90);
|
|
23
|
+
let o = null, i = d;
|
|
24
|
+
for (let m = 2; o == null; m++)
|
|
25
|
+
try {
|
|
26
|
+
if (o = await k(a, { collection: e, name: i, fields: s }), o == null) throw new Error("No id came back");
|
|
27
|
+
} catch (f) {
|
|
28
|
+
if (h(f, "").status !== 409 || m > 6) throw f;
|
|
29
|
+
i = `${d} (${m})`;
|
|
30
|
+
}
|
|
31
|
+
return l(), c.success(`Made ${i} with ${s.length} fields`), o;
|
|
32
|
+
} catch (r) {
|
|
33
|
+
return c.error(h(r, "Could not make the form").message), null;
|
|
34
|
+
} finally {
|
|
35
|
+
u(!1);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
[n, a, e, t, l]
|
|
39
|
+
), busy: n, ready: !!t };
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
x as useFormFromRecord
|
|
43
|
+
};
|