@nivaro/react 0.2.53 → 0.2.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +113 -2
- package/dist/layout-editor.d.ts +248 -2
- package/dist/shared/components/FormWhatsNew.js +60 -0
- package/dist/shared/components/ItemEditForm.js +4058 -3942
- package/dist/shared/components/RecordReadView.js +219 -211
- package/dist/shared/components/TipLayer.js +27 -27
- package/dist/shared/components/help-videos/api.js +51 -41
- package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
- package/dist/shared/components/item-edit/FieldAffordances.js +7 -6
- package/dist/shared/components/item-edit/FieldRow.js +353 -304
- package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
- package/dist/shared/components/item-edit/GroupSection.js +419 -396
- package/dist/shared/components/item-edit/HeaderTools.js +59 -56
- package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
- package/dist/shared/components/item-edit/lock-why.js +87 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -0
- package/dist/shared/components/layout-editor/AddPanel.js +204 -146
- package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
- package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
- package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
- package/dist/shared/components/layout-editor/ChangeNote.js +146 -0
- package/dist/shared/components/layout-editor/CollabParts.js +170 -0
- package/dist/shared/components/layout-editor/DesignNode.js +304 -115
- package/dist/shared/components/layout-editor/EditorCanvas.js +21 -20
- package/dist/shared/components/layout-editor/EditorTopBar.js +452 -175
- package/dist/shared/components/layout-editor/FindReplace.js +188 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +234 -109
- package/dist/shared/components/layout-editor/LayoutEditor.js +1101 -307
- package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
- package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
- package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
- package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
- package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +413 -0
- package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
- package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
- package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
- package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
- package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
- package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
- package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
- package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
- package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
- package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
- package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
- package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
- package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
- package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
- package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
- package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
- package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
- package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
- package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
- package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
- package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
- package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
- package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
- package/dist/shared/components/layout-editor/assist/jump.js +142 -0
- package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
- package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
- package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
- package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
- package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
- package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
- package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
- package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
- package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
- package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +342 -0
- package/dist/shared/components/layout-editor/collab/collab-api.js +77 -0
- package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
- package/dist/shared/components/layout-editor/commands/intents.js +214 -0
- package/dist/shared/components/layout-editor/commands/parse.js +242 -0
- package/dist/shared/components/layout-editor/design-context.js +26 -6
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +179 -163
- package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
- package/dist/shared/components/layout-editor/draft-recovery.js +61 -0
- package/dist/shared/components/layout-editor/editor-notes.js +78 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
- package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
- package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
- package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
- package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
- package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
- package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
- package/dist/shared/components/layout-editor/field-zones.js +116 -0
- package/dist/shared/components/layout-editor/form-map.js +138 -0
- package/dist/shared/components/layout-editor/history-api.js +87 -0
- package/dist/shared/components/layout-editor/inheritance.js +55 -0
- package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
- package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
- package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
- package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +175 -0
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +146 -92
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +256 -175
- package/dist/shared/components/layout-editor/inspector/LookTab.js +46 -40
- package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +167 -141
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +175 -128
- package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +3 -3
- package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
- package/dist/shared/components/layout-editor/is-typing.js +9 -0
- package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
- package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
- package/dist/shared/components/layout-editor/load-error.js +37 -0
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
- package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
- package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
- package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
- package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
- package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
- package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
- package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
- package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
- package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
- package/dist/shared/components/layout-editor/nav/find.js +20 -0
- package/dist/shared/components/layout-editor/nav/tree.js +142 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
- package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
- package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
- package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
- package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
- package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
- package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +18 -14
- package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
- package/dist/shared/components/layout-editor/panel-style.js +8 -7
- package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
- package/dist/shared/components/layout-editor/pin.js +25 -0
- package/dist/shared/components/layout-editor/presence.js +111 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
- package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
- package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
- package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
- package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
- package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
- package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
- package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
- package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
- package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
- package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +123 -103
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +174 -100
- package/dist/shared/components/layout-editor/settings/WhoSection.js +136 -100
- package/dist/shared/components/layout-editor/settings/controls.js +8 -8
- package/dist/shared/components/layout-editor/settings/settings-registry.js +35 -11
- package/dist/shared/components/layout-editor/shortcuts.js +88 -0
- package/dist/shared/components/layout-editor/show-when.js +35 -0
- package/dist/shared/components/layout-editor/slot-names.js +4 -3
- package/dist/shared/components/layout-editor/structure-ops.js +399 -0
- package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +551 -0
- package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
- package/dist/shared/components/layout-editor/testing/testing-model.js +393 -0
- package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
- package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
- package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
- package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +158 -0
- package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -307
- package/dist/shared/components/support/SuggestFormChange.js +143 -0
- package/dist/shared/lib/ai-fill.js +37 -0
- package/dist/shared/lib/form-usage-beacon.js +84 -0
- package/dist/shared/lib/layout-i18n.js +66 -0
- package/dist/shared/lib/layout-lint.js +490 -0
- package/dist/shared/lib/layout-ops.js +110 -106
- package/dist/shared/lib/screenshot.js +54 -28
- package/dist/shared/lib/visible-when.js +34 -0
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { UNGROUPED_KEY as l, HEADER_GROUP_KEY as d } from "../../lib/layout-ops.js";
|
|
2
|
+
import { targetKey as c } from "./design-context.js";
|
|
3
|
+
function g(e) {
|
|
4
|
+
return e.group_key === d ? { kind: "header", field: e.field } : {
|
|
5
|
+
kind: e.field.startsWith("__") ? "slot" : "field",
|
|
6
|
+
field: e.field,
|
|
7
|
+
group_key: e.group_key
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function _(e, n) {
|
|
11
|
+
const t = String(n.layout.name ?? "the parent layout"), s = new Set(n.placements.map((r) => r.field)), i = new Set(n.groups.filter((r) => r.key !== l).map((r) => r.key)), f = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const r of e.placements)
|
|
13
|
+
s.has(r.field) && f.set(c(g(r)), t);
|
|
14
|
+
for (const r of e.groups)
|
|
15
|
+
r.key !== l && i.has(r.key) && f.set(c({ kind: "group", key: r.key }), t);
|
|
16
|
+
return f;
|
|
17
|
+
}
|
|
18
|
+
function v(e) {
|
|
19
|
+
return {
|
|
20
|
+
text: "Overrides parent",
|
|
21
|
+
tone: "slate",
|
|
22
|
+
tip: `Changed on this form; ${e} has its own. Select it to reset it to the parent.`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function m(e, n) {
|
|
26
|
+
return e.placements.filter((t) => t.field === n).map((t) => ({ op: "remove", at: { field: t.field, group_key: t.group_key } }));
|
|
27
|
+
}
|
|
28
|
+
function w(e, n, t) {
|
|
29
|
+
if (!e.groups.find((o) => o.key === t) || !n.groups.some((o) => o.key === t))
|
|
30
|
+
return { ok: !1, why: "This section is not an override of the parent" };
|
|
31
|
+
const i = e.groups.filter((o) => o.parent_key === t);
|
|
32
|
+
if (i.length > 0)
|
|
33
|
+
return {
|
|
34
|
+
ok: !1,
|
|
35
|
+
why: `Reset its ${i.length === 1 ? "tab" : `${i.length} tabs`} to the parent first`
|
|
36
|
+
};
|
|
37
|
+
const f = new Set(n.placements.map((o) => o.field)), r = e.placements.filter((o) => o.group_key === t), p = [], u = [], a = [];
|
|
38
|
+
for (const o of r)
|
|
39
|
+
f.has(o.field) ? (p.push(o.field), a.push(...m(e, o.field))) : u.push(o.field);
|
|
40
|
+
return a.push({ op: "group_remove", key: t, placements: "ungroup" }), { ok: !0, ops: h(a), reset: p, ungrouped: u };
|
|
41
|
+
}
|
|
42
|
+
function h(e) {
|
|
43
|
+
const n = /* @__PURE__ */ new Set();
|
|
44
|
+
return e.filter((t) => {
|
|
45
|
+
if (t.op !== "remove") return !0;
|
|
46
|
+
const s = `${t.at.field}\0${t.at.group_key ?? ""}`;
|
|
47
|
+
return n.has(s) ? !1 : (n.add(s), !0);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
_ as overriddenTargets,
|
|
52
|
+
v as overrideMark,
|
|
53
|
+
w as resetGroupPlan,
|
|
54
|
+
m as resetPlacementOps
|
|
55
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useQuery as r } from "@tanstack/react-query";
|
|
2
|
+
import { useNivaroClient as s } from "../../../context.js";
|
|
3
|
+
import { get as a } from "../../../lib/commands.js";
|
|
4
|
+
const u = {
|
|
5
|
+
columns: (e) => ["layout-editor", "inspect", "columns", e],
|
|
6
|
+
lengths: (e, t) => ["layout-editor", "inspect", "lengths", e, t],
|
|
7
|
+
formFields: (e) => ["layout-editor", "inspect", "form-fields", e],
|
|
8
|
+
orphans: (e) => ["layout-editor", "inspect", "orphans", e],
|
|
9
|
+
translations: (e) => ["layout-editor", "inspect", "translations", e]
|
|
10
|
+
}, i = (e) => !!e && typeof e == "object" && !Array.isArray(e);
|
|
11
|
+
function p(e) {
|
|
12
|
+
const t = s();
|
|
13
|
+
return r({
|
|
14
|
+
queryKey: u.columns(e ?? ""),
|
|
15
|
+
queryFn: () => t.request(a(`/layout-inspect/${e}/columns`)).then((n) => i(n.data) ? n.data : {}),
|
|
16
|
+
enabled: !!e,
|
|
17
|
+
staleTime: 5 * 6e4,
|
|
18
|
+
retry: !1
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function c(e, t) {
|
|
22
|
+
if (!e) return null;
|
|
23
|
+
if (e[t]) return e[t];
|
|
24
|
+
const n = Object.keys(e).find((o) => o.toLowerCase() === t.toLowerCase());
|
|
25
|
+
return n ? e[n] : null;
|
|
26
|
+
}
|
|
27
|
+
function f(e, t, n) {
|
|
28
|
+
const o = s();
|
|
29
|
+
return r({
|
|
30
|
+
queryKey: u.lengths(e, t),
|
|
31
|
+
queryFn: () => o.request(a(`/layout-inspect/${e}/value-lengths`, { field: t })).then((l) => i(l.data) ? l.data : null),
|
|
32
|
+
enabled: n && !!e && !!t,
|
|
33
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
34
|
+
retry: !1
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function q(e) {
|
|
38
|
+
const t = s();
|
|
39
|
+
return r({
|
|
40
|
+
queryKey: u.formFields(e),
|
|
41
|
+
queryFn: () => t.request(a(`/layout-inspect/${e}/form-fields`)).then((n) => Array.isArray(n.data) ? n.data : []),
|
|
42
|
+
enabled: !!e,
|
|
43
|
+
staleTime: 6e4,
|
|
44
|
+
retry: !1
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function h(e) {
|
|
48
|
+
const t = s();
|
|
49
|
+
return r({
|
|
50
|
+
queryKey: u.translations(e),
|
|
51
|
+
queryFn: () => t.request(a(`/layout-inspect/${e}/translations`)).then(
|
|
52
|
+
(n) => i(n.data) && Array.isArray(n.data.locales) ? n.data : null
|
|
53
|
+
),
|
|
54
|
+
enabled: !!e,
|
|
55
|
+
staleTime: 6e4,
|
|
56
|
+
retry: !1
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
c as columnOf,
|
|
61
|
+
u as inspectKeys,
|
|
62
|
+
p as useColumnFacts,
|
|
63
|
+
q as useFormFields,
|
|
64
|
+
h as useTranslationSummary,
|
|
65
|
+
f as useValueLengths
|
|
66
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { resolveOptionFilterTokens as f } from "../../../lib/option-filter-tokens.js";
|
|
2
|
+
import { userOptionFilter as c } from "../../../lib/utils.js";
|
|
3
|
+
import { buildCascadeFilter as d } from "../../item-edit/helpers.js";
|
|
4
|
+
function y(t) {
|
|
5
|
+
const a = t.linked ?? {}, l = d({
|
|
6
|
+
rules: t.rules,
|
|
7
|
+
parentValue: (n) => {
|
|
8
|
+
const e = t.record[n];
|
|
9
|
+
if (e != null && e !== "" && !(Array.isArray(e) && e.length === 0) && typeof e != "object")
|
|
10
|
+
return e;
|
|
11
|
+
const i = a[n];
|
|
12
|
+
return i != null && i.length ? i.length === 1 ? String(i[0]) : i.map(String) : e && typeof e == "object" && !Array.isArray(e) && "id" in e ? e.id : null;
|
|
13
|
+
}
|
|
14
|
+
}), o = f(
|
|
15
|
+
t.optionFilter && typeof t.optionFilter == "object" ? t.optionFilter : void 0,
|
|
16
|
+
t.record,
|
|
17
|
+
t.itemId
|
|
18
|
+
), r = [];
|
|
19
|
+
return t.target === "nivaro_users" && r.push({ key: "people", label: "Active people", filter: c(!0) }), t.rules.length && r.push({
|
|
20
|
+
key: "cascade",
|
|
21
|
+
label: l.satisfiedParents.length ? `Cascade filters (${l.satisfiedParents.map(t.labelOf).join(", ")})` : "Cascade filters (no parent value)",
|
|
22
|
+
filter: l.filter ?? null
|
|
23
|
+
}), t.optionFilter && Object.keys(t.optionFilter).length && r.push({ key: "option_filter", label: "Option filter", filter: o ?? null }), {
|
|
24
|
+
steps: r,
|
|
25
|
+
satisfied: l.satisfiedParents,
|
|
26
|
+
waitsFor: l.missingRequiredParents[0] ?? null
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function _(t, a, l) {
|
|
30
|
+
const o = [];
|
|
31
|
+
for (const r of [...new Set(t.map((n) => n.parent_field))]) {
|
|
32
|
+
const n = l.find((i) => i.one_collection === a && i.one_field === r);
|
|
33
|
+
if (!(n != null && n.many_collection) || !n.many_field) continue;
|
|
34
|
+
let e = n.junction_field ?? null;
|
|
35
|
+
if (!e) {
|
|
36
|
+
const i = l.find(
|
|
37
|
+
(s) => s.many_collection === n.many_collection && s !== n && s.many_field !== n.many_field
|
|
38
|
+
);
|
|
39
|
+
e = (i == null ? void 0 : i.many_field) ?? null;
|
|
40
|
+
}
|
|
41
|
+
e && o.push({ parent: r, junction: n.many_collection, parentFk: n.many_field, targetFk: e });
|
|
42
|
+
}
|
|
43
|
+
return o;
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
_ as m2mParents,
|
|
47
|
+
y as previewNarrowing
|
|
48
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const s = [12, 6, 4, 3], x = { 12: "Full", 6: "½", 4: "⅓", 3: "¼" }, f = 960, h = 40, c = 7;
|
|
2
|
+
function a(t) {
|
|
3
|
+
const e = Math.max(1, Math.min(12, Number(t) || 12));
|
|
4
|
+
return Math.max(1, Math.floor((e / 12 * f - h) / c));
|
|
5
|
+
}
|
|
6
|
+
function m(t) {
|
|
7
|
+
for (const e of [...s].reverse()) if (a(e) >= t) return e;
|
|
8
|
+
return 12;
|
|
9
|
+
}
|
|
10
|
+
function y(t, e) {
|
|
11
|
+
const n = Number(t) || 12, l = m(e);
|
|
12
|
+
return {
|
|
13
|
+
cut: a(n) < e,
|
|
14
|
+
suggest: l,
|
|
15
|
+
roomy: e > 0 && s.indexOf(l) - s.indexOf(n) >= 2
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function p(t) {
|
|
19
|
+
if (t.relKind || t.isPath || ["text", "json", "boolean", "alias"].includes(t.type)) return !1;
|
|
20
|
+
const e = t.iface ?? "";
|
|
21
|
+
return !/textarea|rich|markdown|wysiwyg|code|tags|repeater|file|image/i.test(e);
|
|
22
|
+
}
|
|
23
|
+
function b(t) {
|
|
24
|
+
return t.max_length != null ? `${t.type}(${t.max_length})` : /^n?varchar$/.test(t.type) ? `${t.type}(max)` : t.precision != null ? `${t.type}(${t.precision},${t.scale ?? 0})` : t.type;
|
|
25
|
+
}
|
|
26
|
+
function g(t) {
|
|
27
|
+
return [...t].filter((e) => e === "#" || e === "A" || e === "*").length;
|
|
28
|
+
}
|
|
29
|
+
const d = {
|
|
30
|
+
tinyint: 255,
|
|
31
|
+
smallint: 32767,
|
|
32
|
+
int: 2147483647,
|
|
33
|
+
integer: 2147483647
|
|
34
|
+
};
|
|
35
|
+
function $(t, e) {
|
|
36
|
+
if (e == null || e === "" || typeof e == "object") return null;
|
|
37
|
+
const n = String(e);
|
|
38
|
+
if (n.startsWith("$") || n.includes("{{")) return null;
|
|
39
|
+
if (t.max_length != null && n.length > t.max_length)
|
|
40
|
+
return `${n.length} characters; the column holds ${t.max_length}`;
|
|
41
|
+
const l = d[t.type];
|
|
42
|
+
if (l != null) {
|
|
43
|
+
const r = Number(n);
|
|
44
|
+
if (Number.isFinite(r) && Math.abs(r) > l) return `larger than ${t.type} holds (${l})`;
|
|
45
|
+
}
|
|
46
|
+
if (t.precision != null && /^-?\d+(\.\d+)?$/.test(n)) {
|
|
47
|
+
const [r = "", i = ""] = n.replace("-", "").split("."), o = r.replace(/^0+/, "").length, u = t.precision - (t.scale ?? 0);
|
|
48
|
+
if (o > u) return `${o} digits before the point; the column allows ${u}`;
|
|
49
|
+
if (t.scale != null && i.length > t.scale)
|
|
50
|
+
return `${i.length} decimals; the column keeps ${t.scale}`;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function _(t) {
|
|
55
|
+
const e = [], n = t.column;
|
|
56
|
+
if (n && t.mask) {
|
|
57
|
+
const l = g(t.mask);
|
|
58
|
+
n.max_length != null && l > n.max_length && e.push({
|
|
59
|
+
key: "mask",
|
|
60
|
+
text: `The input mask stores ${l} characters; the column holds ${n.max_length}.`
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (n && t.defaultValue !== void 0) {
|
|
64
|
+
const l = $(n, t.defaultValue);
|
|
65
|
+
l && e.push({ key: "default", text: `This form's default value does not fit: ${l}.` });
|
|
66
|
+
}
|
|
67
|
+
if (t.label && t.layoutType !== "table") {
|
|
68
|
+
const l = a(t.span);
|
|
69
|
+
t.label.length > l && e.push({
|
|
70
|
+
key: "label",
|
|
71
|
+
text: `The label (${t.label.length} characters) is cut off at this width, which shows about ${l}.`
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return e;
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
s as SPANS,
|
|
78
|
+
x as SPAN_WORDS,
|
|
79
|
+
a as capacityChars,
|
|
80
|
+
_ as fitWarnings,
|
|
81
|
+
g as maskStoredLength,
|
|
82
|
+
m as suggestSpan,
|
|
83
|
+
b as typeWords,
|
|
84
|
+
$ as valueMisfit,
|
|
85
|
+
p as widthCheckApplies,
|
|
86
|
+
y as widthVerdict
|
|
87
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsxs as p, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as c } from "react";
|
|
3
|
+
import { readAiFill as I, promptTokens as x, AI_FILL_KEY as w, PROMPT_MAX as $ } from "../../../lib/ai-fill.js";
|
|
4
|
+
import { SimpleSelect as v } from "../../ui/SimpleSelect.js";
|
|
5
|
+
import { useFieldCtx as k } from "./field-context.js";
|
|
6
|
+
import { Toggle as _, Setting as g, TextArea as y } from "./kit.js";
|
|
7
|
+
function j() {
|
|
8
|
+
const m = k(), { ov: h, info: n, globals: i } = m, t = I(h), f = !!(t != null && t.enabled), o = (t == null ? void 0 : t.prompt) ?? "", r = n.label, u = c(() => new Set(i.map((e) => e.field)), [i]), d = x(o).filter((e) => !u.has(e)), b = c(
|
|
9
|
+
() => [
|
|
10
|
+
{ value: "", label: "Insert a field…" },
|
|
11
|
+
...i.filter((e) => e.field !== n.field && !e.field.startsWith("__")).map((e) => {
|
|
12
|
+
var l;
|
|
13
|
+
return { value: e.field, label: ((l = e.label) == null ? void 0 : l.trim()) || e.field };
|
|
14
|
+
})
|
|
15
|
+
],
|
|
16
|
+
[i, n.field]
|
|
17
|
+
), s = (e, l, A) => m.setOverride(
|
|
18
|
+
w,
|
|
19
|
+
{ enabled: e.enabled, prompt: e.prompt.slice(0, $) },
|
|
20
|
+
l,
|
|
21
|
+
A
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ p("div", { className: "space-y-3", "data-ai-fill-setting": "", children: [
|
|
24
|
+
/* @__PURE__ */ a(
|
|
25
|
+
_,
|
|
26
|
+
{
|
|
27
|
+
k: "field.ai_generate",
|
|
28
|
+
label: "AI fill button",
|
|
29
|
+
effect: `Shows an AI button on ${r} that writes a value from your prompt. Overrides the form-wide AI switch for this field.`,
|
|
30
|
+
checked: f,
|
|
31
|
+
onChange: (e) => s(
|
|
32
|
+
{
|
|
33
|
+
enabled: e,
|
|
34
|
+
prompt: o || `Write the ${r.toLowerCase()} for this record.`
|
|
35
|
+
},
|
|
36
|
+
e ? `Turn on AI fill for ${r}` : `Turn off AI fill for ${r}`
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
f && /* @__PURE__ */ p(
|
|
41
|
+
g,
|
|
42
|
+
{
|
|
43
|
+
k: "field.ai_generate_prompt",
|
|
44
|
+
label: "AI prompt",
|
|
45
|
+
effect: "What the AI is asked. {{field_name}} is replaced by that field’s current value; nothing else from the record is sent.",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ a(
|
|
48
|
+
y,
|
|
49
|
+
{
|
|
50
|
+
ariaLabel: "AI prompt",
|
|
51
|
+
rows: 4,
|
|
52
|
+
value: o,
|
|
53
|
+
onChange: (e) => s({ enabled: !0, prompt: e }, `Edit the AI prompt of ${r}`, !0)
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ a(
|
|
57
|
+
v,
|
|
58
|
+
{
|
|
59
|
+
value: "",
|
|
60
|
+
ariaLabel: "Insert a field into the prompt",
|
|
61
|
+
className: "h-7 flex-1 text-[12px]",
|
|
62
|
+
options: b,
|
|
63
|
+
onChange: (e) => {
|
|
64
|
+
if (!e) return;
|
|
65
|
+
const l = o && !/\s$/.test(o) ? " " : "";
|
|
66
|
+
s(
|
|
67
|
+
{ enabled: !0, prompt: `${o}${l}{{${e}}}` },
|
|
68
|
+
`Edit the AI prompt of ${r}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
) }),
|
|
73
|
+
d.length > 0 && /* @__PURE__ */ p("p", { className: "text-[12px] text-amber-700 dark:text-amber-300", "data-ai-fill-unknown": "", children: [
|
|
74
|
+
"Not fields of this collection: ",
|
|
75
|
+
d.map((e) => `{{${e}}}`).join(", "),
|
|
76
|
+
" — they stay empty."
|
|
77
|
+
] })
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] });
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
j as AiFillSetting
|
|
85
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as n, Fragment as d, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as m, Fragment as b } from "react";
|
|
3
|
+
import { crumbsOf as c, KIND_WORDS as f } from "../nav/tree.js";
|
|
4
|
+
import { useInspectorEnv as p } from "./kit.js";
|
|
5
|
+
function k({
|
|
6
|
+
kind: r,
|
|
7
|
+
target: o,
|
|
8
|
+
where: a = null
|
|
9
|
+
}) {
|
|
10
|
+
const t = p(), l = m(() => c(t.bundle, o), [t.bundle, o]);
|
|
11
|
+
return l.length === 0 ? /* @__PURE__ */ n(d, { children: a ? `${r} · ${a}` : r }) : /* @__PURE__ */ i("span", { "data-breadcrumb": "", children: [
|
|
12
|
+
r,
|
|
13
|
+
" ·",
|
|
14
|
+
" ",
|
|
15
|
+
l.map((e, s) => /* @__PURE__ */ i(b, { children: [
|
|
16
|
+
s > 0 && /* @__PURE__ */ n("span", { "aria-hidden": "true", children: " › " }),
|
|
17
|
+
t.select ? /* @__PURE__ */ n(
|
|
18
|
+
"button",
|
|
19
|
+
{
|
|
20
|
+
type: "button",
|
|
21
|
+
"data-crumb": e.target.kind === "group" ? e.target.key : void 0,
|
|
22
|
+
"data-tip": `Select the ${f[e.kind].toLowerCase()} ${e.label}`,
|
|
23
|
+
onClick: () => {
|
|
24
|
+
var u;
|
|
25
|
+
return (u = t.select) == null ? void 0 : u.call(t, e.target);
|
|
26
|
+
},
|
|
27
|
+
className: "rounded-sm text-slate-600 underline-offset-2 hover:text-slate-900 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-nvr-cyan dark:text-slate-300 dark:hover:text-foreground",
|
|
28
|
+
children: e.label
|
|
29
|
+
}
|
|
30
|
+
) : e.label
|
|
31
|
+
] }, e.target.kind === "group" ? e.target.key : s))
|
|
32
|
+
] });
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
k as Breadcrumb
|
|
36
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsxs as c, jsx as o, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { X as R } from "lucide-react";
|
|
3
|
+
import { useMemo as w } from "react";
|
|
4
|
+
import { UNGROUPED_KEY as D } from "../../../lib/layout-ops.js";
|
|
5
|
+
import { TipLayer as H } from "../../TipLayer.js";
|
|
6
|
+
import { ArrangeButton as I } from "../ArrangeButton.js";
|
|
7
|
+
import { targetKey as S } from "../design-context.js";
|
|
8
|
+
import { inPageOrder as j, selectedPlacements as z, fieldZones as B, isFieldRow as E, plural as u, widthOf as F, targetOfKey as N, keyOf as G, widthOps as K, GRID_WIDTHS as U, WIDTH_LABELS as O, flagOn as W, flagOps as q, moveToZoneOps as A } from "../field-zones.js";
|
|
9
|
+
import { PanelHeader as Z, PanelBody as V } from "../panel-frame.js";
|
|
10
|
+
import { effectText as X } from "../panel-style.js";
|
|
11
|
+
import { slotName as Y } from "../slot-names.js";
|
|
12
|
+
import { useCollectionMeta as J } from "./field-context.js";
|
|
13
|
+
import { Setting as $, Segmented as Q, Toggle as ee, Choice as te } from "./kit.js";
|
|
14
|
+
import { describeField as oe } from "./model.js";
|
|
15
|
+
const ne = [
|
|
16
|
+
{
|
|
17
|
+
k: "required",
|
|
18
|
+
label: "Required",
|
|
19
|
+
on: "Make {n} required",
|
|
20
|
+
off: "Make {n} optional",
|
|
21
|
+
effect: "The form will not save without a value."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
k: "readonly",
|
|
25
|
+
label: "Read-only",
|
|
26
|
+
on: "Make {n} read-only",
|
|
27
|
+
off: "Make {n} editable",
|
|
28
|
+
effect: "Shown but not editable on this form."
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
k: "hidden",
|
|
32
|
+
label: "Hidden",
|
|
33
|
+
on: "Hide {n}",
|
|
34
|
+
off: "Show {n}",
|
|
35
|
+
effect: "Leaves them off this form; their values are kept."
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
function be({
|
|
39
|
+
bundle: r,
|
|
40
|
+
selection: s,
|
|
41
|
+
apply: p,
|
|
42
|
+
collection: _,
|
|
43
|
+
onSelection: m
|
|
44
|
+
}) {
|
|
45
|
+
const { data: a } = J(_), n = w(
|
|
46
|
+
() => j(r, z(r, s)),
|
|
47
|
+
[r, s]
|
|
48
|
+
), k = w(() => B(r), [r]), g = (e) => e.startsWith("__") ? Y(e) : oe(
|
|
49
|
+
e,
|
|
50
|
+
(a == null ? void 0 : a.fields) ?? [],
|
|
51
|
+
(a == null ? void 0 : a.relations) ?? [],
|
|
52
|
+
n.find((t) => t.field === e) ?? null
|
|
53
|
+
).label, C = n.filter(E), d = s.length - n.length, h = u(n.length, "item"), b = new Set(n.map(F)), P = b.size === 1 ? String([...b][0]) : "", x = new Set(n.map((e) => e.group_key)), v = x.size === 1 ? M([...x][0] ?? null) : "", y = (e, t) => {
|
|
54
|
+
e.length && p(e, { label: t });
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ c(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
"data-inspector": "",
|
|
60
|
+
"data-bulk-inspector": "",
|
|
61
|
+
className: "flex h-full min-h-0 min-w-0 flex-col text-[12px]",
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ o(H, {}),
|
|
64
|
+
/* @__PURE__ */ o(
|
|
65
|
+
Z,
|
|
66
|
+
{
|
|
67
|
+
eyebrow: "Several selected",
|
|
68
|
+
title: `${h} selected`,
|
|
69
|
+
sub: "Shift- or ⌘-click to add or take out"
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ c(V, { children: [
|
|
73
|
+
/* @__PURE__ */ o("ul", { className: "flex flex-wrap gap-1.5", "aria-label": "Selected", children: n.map((e) => /* @__PURE__ */ c(
|
|
74
|
+
"li",
|
|
75
|
+
{
|
|
76
|
+
className: "inline-flex max-w-full items-center gap-1 rounded-full bg-nvr-cyan/10 py-0.5 pl-2.5 pr-1 text-[12px] font-medium text-slate-800 dark:text-foreground",
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ o("span", { className: "truncate", children: g(e.field) }),
|
|
79
|
+
/* @__PURE__ */ o(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
type: "button",
|
|
83
|
+
"aria-label": `Take ${g(e.field)} out of the selection`,
|
|
84
|
+
onClick: () => {
|
|
85
|
+
const t = S(N(G(e)));
|
|
86
|
+
m(s.filter((l) => S(l) !== t));
|
|
87
|
+
},
|
|
88
|
+
className: "inline-flex h-4 w-4 items-center justify-center rounded-full text-slate-500 hover:bg-nvr-cyan/20 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
89
|
+
children: /* @__PURE__ */ o(R, { className: "h-3 w-3" })
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
`${e.field}:${e.group_key ?? ""}`
|
|
95
|
+
)) }),
|
|
96
|
+
/* @__PURE__ */ o(I, { targets: s }),
|
|
97
|
+
d > 0 && /* @__PURE__ */ c("p", { className: X, children: [
|
|
98
|
+
u(d, "item"),
|
|
99
|
+
" from the parent form ",
|
|
100
|
+
d === 1 ? "is" : "are",
|
|
101
|
+
" left out: override ",
|
|
102
|
+
d === 1 ? "it" : "them",
|
|
103
|
+
" on this form first."
|
|
104
|
+
] }),
|
|
105
|
+
n.length > 0 && /* @__PURE__ */ c(L, { children: [
|
|
106
|
+
/* @__PURE__ */ o($, { k: "bulk.col_span", label: "Width", effect: "Share of the row each one takes.", children: /* @__PURE__ */ o(
|
|
107
|
+
Q,
|
|
108
|
+
{
|
|
109
|
+
value: P,
|
|
110
|
+
options: U.map((e) => ({ value: String(e), label: O[e] })),
|
|
111
|
+
onChange: (e) => y(
|
|
112
|
+
K(n, Number(e)),
|
|
113
|
+
`Set the width of ${h} to ${O[Number(e)]}`
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
) }),
|
|
117
|
+
ne.map((e) => {
|
|
118
|
+
const t = e.k === "hidden" ? n : C;
|
|
119
|
+
if (t.length === 0) return null;
|
|
120
|
+
const l = t.filter((i) => W(i, e.k)).length, f = u(t.length, e.k === "hidden" ? "item" : "field");
|
|
121
|
+
return /* @__PURE__ */ o(
|
|
122
|
+
ee,
|
|
123
|
+
{
|
|
124
|
+
k: `bulk.${e.k}`,
|
|
125
|
+
label: e.label,
|
|
126
|
+
effect: l > 0 && l < t.length ? `${l} of ${t.length} now. ${e.effect}` : e.effect,
|
|
127
|
+
checked: l === t.length,
|
|
128
|
+
onChange: (i) => y(q(t, e.k, i), (i ? e.on : e.off).replace("{n}", f))
|
|
129
|
+
},
|
|
130
|
+
e.k
|
|
131
|
+
);
|
|
132
|
+
}),
|
|
133
|
+
/* @__PURE__ */ o(
|
|
134
|
+
$,
|
|
135
|
+
{
|
|
136
|
+
k: "bulk.move",
|
|
137
|
+
label: "Section",
|
|
138
|
+
effect: "Moves them to the end of that section, in the order they are on the form.",
|
|
139
|
+
children: /* @__PURE__ */ o(
|
|
140
|
+
te,
|
|
141
|
+
{
|
|
142
|
+
ariaLabel: "Move to section",
|
|
143
|
+
value: v,
|
|
144
|
+
options: [
|
|
145
|
+
...v ? [] : [{ value: "", label: "Several sections" }],
|
|
146
|
+
...k.map((e) => ({ value: M(e.key), label: e.label }))
|
|
147
|
+
],
|
|
148
|
+
onChange: (e) => {
|
|
149
|
+
if (!e) return;
|
|
150
|
+
const t = e === T ? null : e, l = k.find((i) => i.key === t), f = A(r, n, t);
|
|
151
|
+
f.ops.length && (p(f.ops, { label: `Move ${h} to ${(l == null ? void 0 : l.label) ?? "another section"}` }), m(f.moved.map(N)));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] }),
|
|
158
|
+
/* @__PURE__ */ o(
|
|
159
|
+
"button",
|
|
160
|
+
{
|
|
161
|
+
type: "button",
|
|
162
|
+
onClick: () => m([]),
|
|
163
|
+
className: "text-[12px] font-medium text-sky-700 hover:underline dark:text-nvr-cyan",
|
|
164
|
+
children: "Clear the selection"
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const T = D, M = (r) => r ?? T;
|
|
173
|
+
export {
|
|
174
|
+
be as BulkInspector
|
|
175
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsxs as s, jsx as l, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { AlertTriangle as F, Ruler as R } from "lucide-react";
|
|
3
|
+
import { useContext as A, useState as L } from "react";
|
|
4
|
+
import { cn as O } from "../../../lib/utils.js";
|
|
5
|
+
import { useColumnFacts as V, columnOf as $, useValueLengths as P } from "../inspect/inspect-api.js";
|
|
6
|
+
import { fitWarnings as U, widthCheckApplies as D, widthVerdict as E, typeWords as G, SPAN_WORDS as i, capacityChars as q } from "../inspect/width-fit.js";
|
|
7
|
+
import { labelText as z, effectText as c, tintCard as B } from "../panel-style.js";
|
|
8
|
+
import { useFieldCtx as H } from "./field-context.js";
|
|
9
|
+
import { GlobalWriterContext as I } from "./kit.js";
|
|
10
|
+
import { asObject as J } from "./model.js";
|
|
11
|
+
const p = (d) => d.toLocaleString();
|
|
12
|
+
function le() {
|
|
13
|
+
var w, N;
|
|
14
|
+
const d = H(), { info: h, row: o, ov: m, env: r, globalOptions: v } = d, { data: C } = V(r.collection), a = $(C, o.field), f = (w = A(I)) == null ? void 0 : w.draft.options, T = String((f == null ? void 0 : f.input_mask) ?? v.input_mask ?? ""), b = J(r.bundle.layout.default_values), _ = typeof m.label == "string" && m.label ? m.label : h.label, S = r.layoutType !== "table", y = U({
|
|
15
|
+
column: a,
|
|
16
|
+
mask: T || null,
|
|
17
|
+
defaultValue: o.field in b ? b[o.field] : void 0,
|
|
18
|
+
label: m.label === "" ? null : _,
|
|
19
|
+
span: o.col_span,
|
|
20
|
+
layoutType: r.layoutType
|
|
21
|
+
}), g = S && !!a && D(h), [x, W] = L(!1), t = P(r.collection, o.field, x && g);
|
|
22
|
+
if (!a && !y.length) return null;
|
|
23
|
+
const u = o.col_span ?? 12, e = t.data ? E(u, t.data.p95) : null, k = (n) => d.setPlacement(
|
|
24
|
+
{ col_span: n === 12 ? null : n },
|
|
25
|
+
`Set the width of ${h.label} to ${i[n]}`
|
|
26
|
+
);
|
|
27
|
+
return /* @__PURE__ */ s("div", { "data-setting": "field.column_fit", className: "space-y-1.5", children: [
|
|
28
|
+
/* @__PURE__ */ s("div", { className: "flex min-h-5 items-center justify-between gap-3", children: [
|
|
29
|
+
/* @__PURE__ */ l("span", { className: z, children: "Stored as" }),
|
|
30
|
+
a && /* @__PURE__ */ l("span", { className: "font-mono text-[12px] text-slate-700 dark:text-foreground", children: G(a) })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ l("p", { "data-effect": "", className: c, children: (a == null ? void 0 : a.max_length) != null ? `The database keeps up to ${p(a.max_length)} characters.` : a ? "What the database column holds." : "This field has no column of its own." }),
|
|
33
|
+
y.map((n) => /* @__PURE__ */ s(
|
|
34
|
+
"p",
|
|
35
|
+
{
|
|
36
|
+
"data-fit-warning": n.key,
|
|
37
|
+
className: "flex items-start gap-1.5 text-[12px] leading-snug text-amber-700 dark:text-amber-300",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ l(F, { className: "mt-[2px] h-3 w-3 shrink-0" }),
|
|
40
|
+
n.text
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
n.key
|
|
44
|
+
)),
|
|
45
|
+
g && !x && /* @__PURE__ */ s(
|
|
46
|
+
"button",
|
|
47
|
+
{
|
|
48
|
+
type: "button",
|
|
49
|
+
"data-width-check": "",
|
|
50
|
+
onClick: () => W(!0),
|
|
51
|
+
className: "inline-flex items-center gap-1.5 text-[12px] font-medium text-sky-700 hover:underline dark:text-nvr-cyan",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ l(R, { className: "h-3.5 w-3.5" }),
|
|
54
|
+
"Check the width against stored values"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
g && x && /* @__PURE__ */ l("div", { "data-width-result": "", className: O(B, "space-y-1.5 p-2.5"), children: t.isLoading ? /* @__PURE__ */ l("p", { className: c, children: "Reading the newest stored values…" }) : t.isError ? /* @__PURE__ */ l("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: ((N = t.error) == null ? void 0 : N.message) || "The stored values could not be read." }) : !t.data || t.data.filled === 0 ? /* @__PURE__ */ l("p", { className: c, children: "No stored values to measure yet." }) : /* @__PURE__ */ s(j, { children: [
|
|
59
|
+
/* @__PURE__ */ s("p", { className: "text-[12px] leading-snug text-slate-700 dark:text-foreground", children: [
|
|
60
|
+
"95% of ",
|
|
61
|
+
p(t.data.filled),
|
|
62
|
+
t.data.capped ? " recent" : "",
|
|
63
|
+
" values are ",
|
|
64
|
+
p(t.data.p95),
|
|
65
|
+
" characters or fewer (longest ",
|
|
66
|
+
p(t.data.max),
|
|
67
|
+
"). ",
|
|
68
|
+
i[u] ?? u,
|
|
69
|
+
" width shows about ",
|
|
70
|
+
q(u),
|
|
71
|
+
"."
|
|
72
|
+
] }),
|
|
73
|
+
e != null && e.cut ? /* @__PURE__ */ s("p", { className: "text-[12px] leading-snug text-amber-700 dark:text-amber-300", children: [
|
|
74
|
+
"This width cuts them off.",
|
|
75
|
+
" ",
|
|
76
|
+
/* @__PURE__ */ s(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
type: "button",
|
|
80
|
+
"data-width-apply": e.suggest,
|
|
81
|
+
onClick: () => k(e.suggest),
|
|
82
|
+
className: "font-medium underline",
|
|
83
|
+
children: [
|
|
84
|
+
"Use ",
|
|
85
|
+
i[e.suggest]
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }) : e != null && e.roomy ? /* @__PURE__ */ s("p", { className: c, children: [
|
|
90
|
+
i[e.suggest],
|
|
91
|
+
" would be enough.",
|
|
92
|
+
" ",
|
|
93
|
+
/* @__PURE__ */ s(
|
|
94
|
+
"button",
|
|
95
|
+
{
|
|
96
|
+
type: "button",
|
|
97
|
+
"data-width-apply": e.suggest,
|
|
98
|
+
onClick: () => k(e.suggest),
|
|
99
|
+
className: "font-medium text-sky-700 hover:underline dark:text-nvr-cyan",
|
|
100
|
+
children: [
|
|
101
|
+
"Use ",
|
|
102
|
+
i[e.suggest]
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] }) : /* @__PURE__ */ l("p", { className: c, children: "The width fits them." })
|
|
107
|
+
] }) })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
le as ColumnFit
|
|
112
|
+
};
|