@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,157 @@
|
|
|
1
|
+
import { parseVisibleWhen as m, matchesVisibleWhen as h } from "../../../lib/visible-when.js";
|
|
2
|
+
const k = {
|
|
3
|
+
desktop: null,
|
|
4
|
+
tablet: 768,
|
|
5
|
+
phone: 390
|
|
6
|
+
};
|
|
7
|
+
function u(e) {
|
|
8
|
+
if (e == null || e === "") return [];
|
|
9
|
+
try {
|
|
10
|
+
const o = typeof e == "string" ? JSON.parse(e) : e;
|
|
11
|
+
return Array.isArray(o) ? o.map((n) => String(n).toUpperCase()) : [];
|
|
12
|
+
} catch {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _(e) {
|
|
17
|
+
if (e == null || e === "") return [];
|
|
18
|
+
try {
|
|
19
|
+
const o = typeof e == "string" ? JSON.parse(e) : e;
|
|
20
|
+
return Array.isArray(o) ? o.flatMap(
|
|
21
|
+
(n) => (n == null ? void 0 : n.type) === "role" && Array.isArray(n.role_ids) ? n.role_ids.map((i) => String(i).toUpperCase()) : []
|
|
22
|
+
) : [];
|
|
23
|
+
} catch {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function a(e, o) {
|
|
28
|
+
const n = String(e.role.id ?? "").toUpperCase(), i = e.role.admin_access, t = new Set(e.hidden_fields), s = new Set(e.readonly_fields), d = /* @__PURE__ */ new Map();
|
|
29
|
+
if (!i)
|
|
30
|
+
for (const l of o.groups) {
|
|
31
|
+
const f = l;
|
|
32
|
+
u(f.hidden_for_roles).includes(n) ? d.set(f.key, "hidden") : u(f.locked_for_roles).includes(n) && d.set(f.key, "locked");
|
|
33
|
+
}
|
|
34
|
+
const r = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const l of o.assignments) {
|
|
36
|
+
if (l.field.startsWith("__")) continue;
|
|
37
|
+
const f = l.group_key ? d.get(l.group_key) : void 0;
|
|
38
|
+
let c;
|
|
39
|
+
!e.can_read || t.has(l.field) || f === "hidden" ? c = "hidden" : !e.can_update || s.has(l.field) || f === "locked" || _(l.lock_conditions).includes(n) ? c = "readonly" : c = "editable";
|
|
40
|
+
const p = r.get(l.field);
|
|
41
|
+
(!p || g(c) > g(p)) && r.set(l.field, c);
|
|
42
|
+
}
|
|
43
|
+
return r;
|
|
44
|
+
}
|
|
45
|
+
const g = (e) => e === "editable" ? 2 : e === "readonly" ? 1 : 0, y = {
|
|
46
|
+
hidden: "hidden",
|
|
47
|
+
readonly: "read-only",
|
|
48
|
+
editable: "can edit"
|
|
49
|
+
};
|
|
50
|
+
function S(e, o, n) {
|
|
51
|
+
const i = a(o, e), t = a(n, e), s = (r, l) => !r.role.admin_access && u(l).includes(String(r.role.id ?? "").toUpperCase()), d = /* @__PURE__ */ new Map();
|
|
52
|
+
for (const r of e.groups) {
|
|
53
|
+
const l = r.hidden_for_roles, f = s(o, l), c = s(n, l);
|
|
54
|
+
f !== c && d.set(r.key, `${f ? o.role.name : n.role.name} does not see this section`);
|
|
55
|
+
}
|
|
56
|
+
return (r) => {
|
|
57
|
+
if (r.kind === "group") {
|
|
58
|
+
const c = d.get(r.key);
|
|
59
|
+
return c ? [{ text: "Differs", tone: "violet", tip: c, highlight: !0 }] : [];
|
|
60
|
+
}
|
|
61
|
+
if (r.kind !== "field" && r.kind !== "header") return [];
|
|
62
|
+
const l = i.get(r.field), f = t.get(r.field);
|
|
63
|
+
return !l || !f || l === f ? [] : [
|
|
64
|
+
{
|
|
65
|
+
text: "Differs",
|
|
66
|
+
tone: "violet",
|
|
67
|
+
tip: `${o.role.name}: ${y[l]} · ${n.role.name}: ${y[f]}`,
|
|
68
|
+
highlight: !0
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function b(e, o) {
|
|
74
|
+
const n = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const i of e)
|
|
76
|
+
for (const [t, s] of a(i, o)) {
|
|
77
|
+
const d = n.get(t) ?? { edit: [], read: [], hidden: [] };
|
|
78
|
+
s === "editable" ? d.edit.push(i.role.name) : s === "readonly" ? d.read.push(i.role.name) : d.hidden.push(i.role.name), n.set(t, d);
|
|
79
|
+
}
|
|
80
|
+
return n;
|
|
81
|
+
}
|
|
82
|
+
function A(e) {
|
|
83
|
+
const o = e.edit.length + e.read.length + e.hidden.length, n = e.edit.length + e.read.length;
|
|
84
|
+
if (o === 0 || n === 0) return "none";
|
|
85
|
+
if (n === o) return "all";
|
|
86
|
+
const i = n / o;
|
|
87
|
+
return i < 1 / 3 ? "few" : i < 2 / 3 ? "some" : "most";
|
|
88
|
+
}
|
|
89
|
+
function C(e, o) {
|
|
90
|
+
const n = [];
|
|
91
|
+
for (const i of e.assignments)
|
|
92
|
+
if (i.lock_conditions)
|
|
93
|
+
try {
|
|
94
|
+
const t = JSON.parse(i.lock_conditions);
|
|
95
|
+
Array.isArray(t) && t.some((s) => {
|
|
96
|
+
var d;
|
|
97
|
+
return (s == null ? void 0 : s.type) === "pipeline_state" && ((d = s.state_keys) == null ? void 0 : d.includes(o));
|
|
98
|
+
}) && n.push(i.field);
|
|
99
|
+
} catch {
|
|
100
|
+
}
|
|
101
|
+
return [...new Set(n)];
|
|
102
|
+
}
|
|
103
|
+
function w(e, o) {
|
|
104
|
+
const n = [];
|
|
105
|
+
for (const i of e)
|
|
106
|
+
if (!(i.from_state != null && i.from_state !== o))
|
|
107
|
+
for (const t of i.requirements ?? []) {
|
|
108
|
+
const s = Array.isArray(t == null ? void 0 : t.fields) ? t.fields.map(String) : [];
|
|
109
|
+
s.length !== 0 && n.push({
|
|
110
|
+
label: i.label,
|
|
111
|
+
fields: s,
|
|
112
|
+
collection: typeof t.collection == "string" && t.collection ? t.collection : null
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return n;
|
|
116
|
+
}
|
|
117
|
+
function M(e) {
|
|
118
|
+
const o = /* @__PURE__ */ new Map();
|
|
119
|
+
for (const n of e.groups) {
|
|
120
|
+
const i = m(n.visible_when);
|
|
121
|
+
for (const t of i) {
|
|
122
|
+
if (!t.field) continue;
|
|
123
|
+
const s = o.get(t.field) ?? { field: t.field, values: [], drives: [] };
|
|
124
|
+
if (t.op === "in")
|
|
125
|
+
for (const r of String(t.value ?? "").split(","))
|
|
126
|
+
r.trim() && !s.values.includes(r.trim()) && s.values.push(r.trim());
|
|
127
|
+
if ((t.op ?? "eq") === "eq" || t.op === "neq") {
|
|
128
|
+
const r = String(t.value ?? "");
|
|
129
|
+
r && !s.values.includes(r) && s.values.push(r);
|
|
130
|
+
}
|
|
131
|
+
const d = n.label || n.key;
|
|
132
|
+
s.drives.includes(d) || s.drives.push(d), o.set(t.field, s);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return [...o.values()].sort((n, i) => n.field.localeCompare(i.field));
|
|
136
|
+
}
|
|
137
|
+
function D(e, o, n) {
|
|
138
|
+
const i = [], t = [];
|
|
139
|
+
for (const s of e.groups) {
|
|
140
|
+
const d = s.visible_when;
|
|
141
|
+
if (m(d).length === 0) continue;
|
|
142
|
+
const r = h(d, o), l = h(d, n);
|
|
143
|
+
r !== l && (l ? i : t).push(s.key);
|
|
144
|
+
}
|
|
145
|
+
return { shown: i, hidden: t };
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
k as DEVICE_WIDTH,
|
|
149
|
+
S as compareMarks,
|
|
150
|
+
M as drivingFields,
|
|
151
|
+
a as fieldAccessForRole,
|
|
152
|
+
C as fieldsLockedInState,
|
|
153
|
+
w as leavingNeeds,
|
|
154
|
+
D as visibilityChanges,
|
|
155
|
+
b as whoSeesFields,
|
|
156
|
+
A as whoTint
|
|
157
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var I = (r, e, t) => e in r ? R(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var w = (r, e, t) => I(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { UNGROUPED_KEY as E, RESERVED_FIELDS as P, isCanvasSlot as _, applyLayoutOps as S, PLACEMENT_PATCH_KEYS as m, newGroup as A, HEADER_GROUP_KEY as $, TABLE_FORM_GROUP_KEYS as N, GROUP_PATCH_KEYS as b } from "../../lib/layout-ops.js";
|
|
5
|
+
import { sectionLabel as g, sameValue as T } from "./canvas-diff.js";
|
|
6
|
+
import { slotName as G } from "./slot-names.js";
|
|
7
|
+
const k = (r, e) => r.sort - e.sort || (r.id ?? Number.MAX_SAFE_INTEGER) - (e.id ?? Number.MAX_SAFE_INTEGER);
|
|
8
|
+
function d(r, e) {
|
|
9
|
+
return r.placements.filter((t) => t.group_key === e && !_(t)).sort(k);
|
|
10
|
+
}
|
|
11
|
+
function O(r, e) {
|
|
12
|
+
const t = r.groups.filter(
|
|
13
|
+
(i) => (i.parent_key ?? null) === e
|
|
14
|
+
);
|
|
15
|
+
return e === null && t.push(...r.placements.filter(_)), t.sort(k);
|
|
16
|
+
}
|
|
17
|
+
const x = (r, e) => "key" in r && "key" in e ? r.key === e.key : "field" in r && "field" in e && r.field === e.field;
|
|
18
|
+
function y(r, e, t) {
|
|
19
|
+
const i = r, u = e, l = {};
|
|
20
|
+
for (const p of t) u[p] !== void 0 && !T(i[p], u[p]) && (l[p] = u[p]);
|
|
21
|
+
return l;
|
|
22
|
+
}
|
|
23
|
+
function j(r, e) {
|
|
24
|
+
return e === null || e === $ || r.layout.layout_type === "table" && N.includes(e) ? !0 : r.groups.some((t) => t.key === e && t.key !== E);
|
|
25
|
+
}
|
|
26
|
+
class C {
|
|
27
|
+
constructor(e, t) {
|
|
28
|
+
w(this, "ops", []);
|
|
29
|
+
this.w = e, this.version = t;
|
|
30
|
+
}
|
|
31
|
+
push(e) {
|
|
32
|
+
this.w = S(this.w, [e]), this.ops.push(e);
|
|
33
|
+
}
|
|
34
|
+
/** Where the version had this placement among its zone (slot cards: among the top level). */
|
|
35
|
+
versionIndex(e) {
|
|
36
|
+
const t = _(e) ? O(this.version, null) : d(this.version, e.group_key), i = t.findIndex((u) => x(u, e));
|
|
37
|
+
return i < 0 ? t.length : i;
|
|
38
|
+
}
|
|
39
|
+
/** A field as the version had it: settings, and the version's section when it is elsewhere. */
|
|
40
|
+
field(e) {
|
|
41
|
+
const t = { field: e.field, group_key: e.group_key }, i = this.w.placements.find((s) => s.field === e.field && s.group_key === e.group_key);
|
|
42
|
+
if (i) {
|
|
43
|
+
const s = y(i, e, m);
|
|
44
|
+
Object.keys(s).length && this.push({ op: "update_placement", at: t, patch: s });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!j(this.w, e.group_key))
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Its section “${g(this.version.groups, e.group_key)}” is not on the form — restore the section instead`
|
|
50
|
+
);
|
|
51
|
+
const u = this.versionIndex(e), l = this.w.placements.filter((s) => s.field === e.field).sort((s, o) => (s.group_key ?? "").localeCompare(o.group_key ?? ""))[0];
|
|
52
|
+
if (l) {
|
|
53
|
+
this.push({
|
|
54
|
+
op: "move",
|
|
55
|
+
from: { field: l.field, group_key: l.group_key },
|
|
56
|
+
to_group_key: e.group_key,
|
|
57
|
+
index: u
|
|
58
|
+
});
|
|
59
|
+
const s = y(l, e, m);
|
|
60
|
+
Object.keys(s).length && this.push({ op: "update_placement", at: t, patch: s });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const p = {}, n = e;
|
|
64
|
+
for (const s of m) n[s] !== void 0 && (p[s] = n[s]);
|
|
65
|
+
this.push({ op: "place", field: e.field, group_key: e.group_key, index: u, patch: p });
|
|
66
|
+
}
|
|
67
|
+
/** A section as the version had it: its row, its tabs, then its fields in the version's order. */
|
|
68
|
+
group(e) {
|
|
69
|
+
if (e.key === E) throw new Error("Ungrouped is not a section");
|
|
70
|
+
const t = e.parent_key != null && this.w.groups.some((n) => n.key === e.parent_key) ? e.parent_key : null, i = O(this.version, e.parent_key ?? null), u = Math.max(
|
|
71
|
+
0,
|
|
72
|
+
i.findIndex((n) => x(n, e))
|
|
73
|
+
), l = this.w.groups.find((n) => n.key === e.key);
|
|
74
|
+
if (l) {
|
|
75
|
+
const n = y(l, e, b);
|
|
76
|
+
Object.keys(n).length && this.push({ op: "group_update", key: e.key, patch: n }), (l.parent_key ?? null) !== t && this.push({ op: "group_move", key: e.key, parent_key: t, index: u });
|
|
77
|
+
} else {
|
|
78
|
+
const n = A(e.key, e.label, e.type, t), s = y(n, e, b);
|
|
79
|
+
delete s.label, delete s.type, this.push({
|
|
80
|
+
op: "group_create",
|
|
81
|
+
key: e.key,
|
|
82
|
+
label: e.label,
|
|
83
|
+
group_type: e.type,
|
|
84
|
+
parent_key: t,
|
|
85
|
+
index: u,
|
|
86
|
+
patch: s
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
for (const n of this.version.groups.filter((s) => s.parent_key === e.key).sort(k))
|
|
90
|
+
this.group(n);
|
|
91
|
+
if (e.type === "container" || e.type === "content") return;
|
|
92
|
+
const p = d(this.version, e.key);
|
|
93
|
+
for (const n of p) this.field(n);
|
|
94
|
+
for (const n of d(this.w, e.key))
|
|
95
|
+
p.some((s) => s.field === n.field) || this.push({ op: "remove", at: { field: n.field, group_key: e.key } });
|
|
96
|
+
p.forEach((n, s) => {
|
|
97
|
+
var o;
|
|
98
|
+
((o = d(this.w, e.key)[s]) == null ? void 0 : o.field) !== n.field && this.push({
|
|
99
|
+
op: "move",
|
|
100
|
+
from: { field: n.field, group_key: e.key },
|
|
101
|
+
to_group_key: e.key,
|
|
102
|
+
index: s
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function M(r, e, t) {
|
|
108
|
+
const i = new C(r, e);
|
|
109
|
+
if (t.kind === "group") {
|
|
110
|
+
const u = e.groups.find((l) => l.key === t.key);
|
|
111
|
+
if (!u) throw new Error("That version has no such section");
|
|
112
|
+
i.group(u);
|
|
113
|
+
} else {
|
|
114
|
+
const u = e.placements.find(
|
|
115
|
+
(l) => l.field === t.field && l.group_key === t.group_key
|
|
116
|
+
);
|
|
117
|
+
if (!u) throw new Error("That version has no such field");
|
|
118
|
+
i.field(u);
|
|
119
|
+
}
|
|
120
|
+
return i.ops;
|
|
121
|
+
}
|
|
122
|
+
const h = (r, e, t = `${e}s`) => `${r} ${r === 1 ? e : t}`;
|
|
123
|
+
function U(r, e) {
|
|
124
|
+
let t = 0, i = 0, u = 0, l = 0, p = 0, n = !1, s = 0, o = 0;
|
|
125
|
+
for (const c of r)
|
|
126
|
+
switch (c.op) {
|
|
127
|
+
case "place":
|
|
128
|
+
t++;
|
|
129
|
+
break;
|
|
130
|
+
case "move":
|
|
131
|
+
(c.from.group_key ?? null) === (c.to_group_key ?? null) ? u++ : i++;
|
|
132
|
+
break;
|
|
133
|
+
case "remove":
|
|
134
|
+
l++;
|
|
135
|
+
break;
|
|
136
|
+
case "update_placement":
|
|
137
|
+
p += Object.keys(c.patch ?? {}).length;
|
|
138
|
+
break;
|
|
139
|
+
case "group_create":
|
|
140
|
+
e.kind === "group" && c.key === e.key ? n = !0 : o++;
|
|
141
|
+
break;
|
|
142
|
+
case "group_update":
|
|
143
|
+
s += Object.keys(c.patch ?? {}).length;
|
|
144
|
+
break;
|
|
145
|
+
case "group_move":
|
|
146
|
+
s++;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
const f = [];
|
|
150
|
+
return n && f.push("Back on the form"), o && f.push(h(o, "tab")), e.kind === "field" ? (t && f.push("Back on the form"), i && f.push("Moves back"), p && f.push(h(p, "setting"))) : (s && f.push(h(s, "section setting")), t && f.push(`${h(t, "field")} back`), i && f.push(`${h(i, "field")} moved in`), l && f.push(`${h(l, "field")} removed`), p && f.push(h(p, "field setting")), u && !t && !i && !l && f.push("Order")), f.join(" · ") || "Nothing differs";
|
|
151
|
+
}
|
|
152
|
+
function D(r, e, t = (i) => i) {
|
|
153
|
+
var s;
|
|
154
|
+
const i = [], u = (o, f, c) => {
|
|
155
|
+
try {
|
|
156
|
+
const a = M(r, e, o);
|
|
157
|
+
if (a.length === 0) return;
|
|
158
|
+
i.push({ piece: o, label: f, where: c, summary: U(a, o), ops: a });
|
|
159
|
+
} catch (a) {
|
|
160
|
+
i.push({
|
|
161
|
+
piece: o,
|
|
162
|
+
label: f,
|
|
163
|
+
where: c,
|
|
164
|
+
summary: "",
|
|
165
|
+
ops: [],
|
|
166
|
+
error: a instanceof Error ? a.message : String(a)
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, l = [...e.groups].filter((o) => o.key !== E).sort(k), p = [
|
|
170
|
+
...l.filter((o) => o.parent_key == null),
|
|
171
|
+
...l.filter((o) => o.parent_key != null)
|
|
172
|
+
];
|
|
173
|
+
for (const o of p)
|
|
174
|
+
u(
|
|
175
|
+
{ kind: "group", key: o.key },
|
|
176
|
+
((s = o.label) == null ? void 0 : s.trim()) || o.key,
|
|
177
|
+
o.parent_key ? `in ${g(e.groups, o.parent_key)}` : null
|
|
178
|
+
);
|
|
179
|
+
const n = [...e.placements].filter((o) => !P.includes(o.field)).sort((o, f) => (o.group_key ?? "").localeCompare(f.group_key ?? "") || k(o, f));
|
|
180
|
+
for (const o of n)
|
|
181
|
+
u(
|
|
182
|
+
{ kind: "field", field: o.field, group_key: o.group_key },
|
|
183
|
+
o.field.startsWith("__") ? G(o.field) : t(o.field),
|
|
184
|
+
_(o) ? null : `in ${g(e.groups, o.group_key)}`
|
|
185
|
+
);
|
|
186
|
+
return i;
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
D as restorablePieces,
|
|
190
|
+
M as restorePieceOps,
|
|
191
|
+
U as summarizeOps
|
|
192
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsxs as c, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowRight as v } from "lucide-react";
|
|
3
|
+
import { useMemo as u, useState as w, useEffect as N } from "react";
|
|
4
|
+
import { titleCase as M } from "../../../lib/utils.js";
|
|
5
|
+
import { SimpleSelect as $ } from "../../ui/SimpleSelect.js";
|
|
6
|
+
import { useOverviewFields as h } from "../overview/overview-api.js";
|
|
7
|
+
import { suggestFieldMap as b } from "./field-match.js";
|
|
8
|
+
const f = "";
|
|
9
|
+
function O(a, m, s) {
|
|
10
|
+
const { data: t, isLoading: i } = h(s), { data: r = [] } = h(m ?? s), p = u(() => new Set((t ?? []).map((l) => l.field)), [t]), e = u(
|
|
11
|
+
() => t ? a.filter((l) => !l.startsWith("__") && !p.has(l)) : [],
|
|
12
|
+
[a, p, t]
|
|
13
|
+
), n = `${s}|${e.join(",")}`, [x, g] = w({});
|
|
14
|
+
return N(() => {
|
|
15
|
+
if (!t) return;
|
|
16
|
+
const l = new Map(r.map((o) => [o.field, o.label ?? null]));
|
|
17
|
+
g(
|
|
18
|
+
b(
|
|
19
|
+
e.map((o) => ({ field: o, label: l.get(o) ?? null })),
|
|
20
|
+
t
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
}, [n, t]), { map: x, setMap: g, needed: e, loading: i, sourceFields: r };
|
|
24
|
+
}
|
|
25
|
+
function W({
|
|
26
|
+
needed: a,
|
|
27
|
+
map: m,
|
|
28
|
+
onChange: s,
|
|
29
|
+
targetCollection: t,
|
|
30
|
+
sourceLabels: i
|
|
31
|
+
}) {
|
|
32
|
+
const { data: r = [] } = h(t), p = u(
|
|
33
|
+
() => [
|
|
34
|
+
{ value: f, label: "Leave out" },
|
|
35
|
+
...r.filter((e) => !e.field.startsWith("__")).map((e) => ({ value: e.field, label: `${e.label || M(e.field)} · ${e.field}` })).sort((e, n) => e.label.localeCompare(n.label))
|
|
36
|
+
],
|
|
37
|
+
[r]
|
|
38
|
+
);
|
|
39
|
+
return a.length ? /* @__PURE__ */ c("div", { "data-reuse-map": "", className: "space-y-1.5", children: [
|
|
40
|
+
/* @__PURE__ */ c("p", { className: "text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: [
|
|
41
|
+
a.length === 1 ? "One field has" : `${a.length} fields have`,
|
|
42
|
+
" no field of the same name here. Pick where each goes:"
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ d("div", { className: "max-h-[240px] space-y-1 overflow-y-auto overscroll-contain pr-0.5", children: a.map((e) => /* @__PURE__ */ c("div", { "data-reuse-map-row": e, className: "flex items-center gap-1.5", children: [
|
|
45
|
+
/* @__PURE__ */ d(
|
|
46
|
+
"span",
|
|
47
|
+
{
|
|
48
|
+
className: "min-w-0 flex-1 truncate font-mono text-[11.5px] text-slate-700 dark:text-foreground",
|
|
49
|
+
"data-tip": (i == null ? void 0 : i.get(e)) ?? void 0,
|
|
50
|
+
children: e
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ d(v, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
54
|
+
/* @__PURE__ */ d(
|
|
55
|
+
$,
|
|
56
|
+
{
|
|
57
|
+
value: m[e] ?? f,
|
|
58
|
+
onChange: (n) => s({ ...m, [e]: n || null }),
|
|
59
|
+
ariaLabel: `Where ${e} goes`,
|
|
60
|
+
className: "h-7 w-[150px] shrink-0 text-[12px]",
|
|
61
|
+
options: p
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] }, e)) })
|
|
65
|
+
] }) : null;
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
W as FieldMapStep,
|
|
69
|
+
O as useFieldMapping
|
|
70
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { jsxs as t, Fragment as P, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { BookmarkPlus as j, FilePlus2 as B, Download as M } from "lucide-react";
|
|
3
|
+
import { useState as n } from "react";
|
|
4
|
+
import { toast as d } from "sonner";
|
|
5
|
+
import { useNivaroClient as O } from "../../../context.js";
|
|
6
|
+
import { Popover as L, PopoverContent as $ } from "../../ui/popover.js";
|
|
7
|
+
import { downloadLayout as A } from "../ops/ops-api.js";
|
|
8
|
+
import { apiFailure as w } from "../overview/overview-api.js";
|
|
9
|
+
import { ToolButton as f } from "../toolbar-kit.js";
|
|
10
|
+
import { useRefreshTemplates as E, saveTemplate as I } from "./reuse-api.js";
|
|
11
|
+
import { reuseLabel as k, reuseInput as C, reusePrimary as K } from "./SectionReuseActions.js";
|
|
12
|
+
import { useFormFromRecord as R } from "./useFormFromRecord.js";
|
|
13
|
+
function Z({
|
|
14
|
+
collection: x,
|
|
15
|
+
bundle: o,
|
|
16
|
+
previewRecord: s,
|
|
17
|
+
onOpenLayout: S
|
|
18
|
+
}) {
|
|
19
|
+
const p = O(), F = E(), r = R(x), [T, l] = n(!1), [u, h] = n(""), [y, v] = n(""), [i, N] = n(!1), m = String((o == null ? void 0 : o.layout.name) ?? "Form"), g = () => {
|
|
20
|
+
l(!1), h(""), v("");
|
|
21
|
+
}, b = async () => {
|
|
22
|
+
if (!o || i) return;
|
|
23
|
+
const e = (u || m).trim();
|
|
24
|
+
N(!0);
|
|
25
|
+
try {
|
|
26
|
+
await I(p, {
|
|
27
|
+
kind: "form",
|
|
28
|
+
name: e,
|
|
29
|
+
description: y || null,
|
|
30
|
+
layout_id: Number(o.layout.id),
|
|
31
|
+
bundle: o
|
|
32
|
+
}), F("form"), d.success(`Saved ${e} as a template. Use it from New form → Template.`), g();
|
|
33
|
+
} catch (D) {
|
|
34
|
+
d.error(w(D, "Could not save the template").message);
|
|
35
|
+
} finally {
|
|
36
|
+
N(!1);
|
|
37
|
+
}
|
|
38
|
+
}, c = o ? Number(o.layout.id) : null;
|
|
39
|
+
return /* @__PURE__ */ t(P, { children: [
|
|
40
|
+
/* @__PURE__ */ t(L, { open: T, onOpenChange: (e) => e ? l(!0) : g(), children: [
|
|
41
|
+
/* @__PURE__ */ a(
|
|
42
|
+
f,
|
|
43
|
+
{
|
|
44
|
+
popover: !0,
|
|
45
|
+
onOpen: () => l(!0),
|
|
46
|
+
label: "Save as template…",
|
|
47
|
+
icon: /* @__PURE__ */ a(j, { className: "h-3.5 w-3.5" }),
|
|
48
|
+
hint: "Start new forms on any collection from this one",
|
|
49
|
+
disabled: !o,
|
|
50
|
+
data: { "data-more-save-template": "" }
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ t($, { align: "end", className: "w-[300px] p-3", children: [
|
|
54
|
+
/* @__PURE__ */ a("p", { className: "mb-2 text-[12px] leading-snug text-slate-600 dark:text-muted-foreground", children: "Sections, fields and how the form behaves are saved by field name. Rules for who gets it, defaults and links stay with this form." }),
|
|
55
|
+
/* @__PURE__ */ t("label", { className: "block", children: [
|
|
56
|
+
/* @__PURE__ */ a("span", { className: k, children: "Template name" }),
|
|
57
|
+
/* @__PURE__ */ a(
|
|
58
|
+
"input",
|
|
59
|
+
{
|
|
60
|
+
value: u,
|
|
61
|
+
placeholder: m,
|
|
62
|
+
onChange: (e) => h(e.target.value),
|
|
63
|
+
onKeyDown: (e) => {
|
|
64
|
+
e.key === "Enter" && b();
|
|
65
|
+
},
|
|
66
|
+
className: C
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] }),
|
|
70
|
+
/* @__PURE__ */ t("label", { className: "mt-2 block", children: [
|
|
71
|
+
/* @__PURE__ */ a("span", { className: k, children: "Description (optional)" }),
|
|
72
|
+
/* @__PURE__ */ a(
|
|
73
|
+
"input",
|
|
74
|
+
{
|
|
75
|
+
value: y,
|
|
76
|
+
onChange: (e) => v(e.target.value),
|
|
77
|
+
placeholder: "What it is for",
|
|
78
|
+
className: C
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ a("div", { className: "mt-3 flex justify-end", children: /* @__PURE__ */ a(
|
|
83
|
+
"button",
|
|
84
|
+
{
|
|
85
|
+
type: "button",
|
|
86
|
+
className: K,
|
|
87
|
+
disabled: i,
|
|
88
|
+
onClick: () => void b(),
|
|
89
|
+
children: i ? "Saving…" : "Save template"
|
|
90
|
+
}
|
|
91
|
+
) })
|
|
92
|
+
] })
|
|
93
|
+
] }),
|
|
94
|
+
s && /* @__PURE__ */ a(
|
|
95
|
+
f,
|
|
96
|
+
{
|
|
97
|
+
label: r.busy ? "Making…" : "New form from this record",
|
|
98
|
+
icon: /* @__PURE__ */ a(B, { className: "h-3.5 w-3.5" }),
|
|
99
|
+
hint: `The fields ${s.label} has filled in, in one section`,
|
|
100
|
+
disabled: r.busy || !r.ready,
|
|
101
|
+
data: { "data-more-from-record": "" },
|
|
102
|
+
onClick: async () => {
|
|
103
|
+
const e = await r.make(s.id, s.label);
|
|
104
|
+
e != null && S(e);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ a(
|
|
109
|
+
f,
|
|
110
|
+
{
|
|
111
|
+
label: "Download this form",
|
|
112
|
+
icon: /* @__PURE__ */ a(M, { className: "h-3.5 w-3.5" }),
|
|
113
|
+
hint: "A file another environment can bring in",
|
|
114
|
+
disabled: c == null,
|
|
115
|
+
data: { "data-more-download": "" },
|
|
116
|
+
onClick: () => {
|
|
117
|
+
c != null && A(p, c, m).catch(
|
|
118
|
+
(e) => d.error(w(e, "Could not download").message)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
Z as FormMoreMenu
|
|
127
|
+
};
|