@nextlyhq/plugin-form-builder 0.0.2-alpha.71 → 0.0.2-alpha.73
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/admin/index.d.ts +5 -1
- package/dist/admin/index.js +133 -4
- package/dist/admin/index.js.map +1 -1
- package/dist/{field-references-BshlgMcn.js → field-references-CtzGg51W.js} +272 -2
- package/dist/field-references-CtzGg51W.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +152 -15
- package/dist/index.js.map +1 -1
- package/dist/{types-BHReIA0j.d.ts → new-submissions-CzlhVGhH.d.ts} +34 -2
- package/package.json +12 -12
- package/dist/field-references-BshlgMcn.js.map +0 -1
package/dist/admin/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as
|
|
1
|
+
import { O as FormSettings, S as FormFieldTypeId, T as FormNotification, b as FormField, i as AnyFormField, r as NewSubmissionsData } from "../new-submissions-CzlhVGhH.js";
|
|
2
2
|
import { ComponentPath, DocumentLockGates } from "@nextlyhq/plugin-sdk/admin";
|
|
3
3
|
import React, { JSX, ReactNode } from "react";
|
|
4
4
|
import { FieldTypeCatalogEntry, FormFieldCatalogType } from "nextly/field-catalog";
|
|
@@ -69,6 +69,10 @@ interface SubmissionSheetProps {
|
|
|
69
69
|
onSave: (changes: Record<string, unknown>) => Promise<void>;
|
|
70
70
|
}
|
|
71
71
|
export declare function SubmissionSheet({ submission, form, canUpdate, onClose, onPrev, onNext, onSave }: SubmissionSheetProps): JSX.Element;
|
|
72
|
+
/** The card's rows, as many as its size holds. */
|
|
73
|
+
export declare function NewSubmissionsCard({ data }: {
|
|
74
|
+
data: NewSubmissionsData;
|
|
75
|
+
}): JSX.Element;
|
|
72
76
|
interface FieldCardsProps {
|
|
73
77
|
/**
|
|
74
78
|
* Form-surface types the host has NOT excluded (the plugin's field
|
package/dist/admin/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as isKnownFormField, C as enforcedValidationRules,
|
|
2
|
-
import { ConditionRow, DataTableView, FieldOptionsEditor, FieldTypePicker, ValidationRulesEditor, drawsAnyValidationRule, registerComponents, registerKnownPlugin, usePluginFieldTypeEntries, withOptionIds } from "@nextlyhq/plugin-sdk/admin";
|
|
1
|
+
import { A as isKnownFormField, C as enforcedValidationRules, L as documentReachability, R as parseRedirectReference, l as evaluateConditions, m as DEFAULT_FORM_SETTINGS, n as parseFieldRef, p as normalizeFormSettings, s as formatExportValue, t as buildFieldReferenceMap } from "../field-references-CtzGg51W.js";
|
|
2
|
+
import { ConditionRow, DataTableView, FieldOptionsEditor, FieldTypePicker, FrameState, ValidationRulesEditor, Widget, drawsAnyValidationRule, formatWidgetTime, registerComponents, registerKnownPlugin, usePluginFieldTypeEntries, useRefreshDashboard, useWidgetClock, withOptionIds } from "@nextlyhq/plugin-sdk/admin";
|
|
3
3
|
import { Badge, Button, Card, Checkbox, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, FieldShell, FormActions, FormLabelWithTooltip, FormSection, Grid, Input, Label, RadioGroup, RadioGroupItem, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipTrigger, toast } from "@nextlyhq/ui";
|
|
4
4
|
import * as Lucide from "lucide-react";
|
|
5
5
|
import { ChevronLeft, ChevronRight, Columns3, Copy, Download, ExternalLink, Eye, Filter, Mail, Monitor, MoreHorizontal, Paperclip, Pencil, Plus, RotateCcw, Smartphone, Trash2, TriangleAlert, X } from "lucide-react";
|
|
@@ -2427,7 +2427,7 @@ async function fetchCanEditTemplates() {
|
|
|
2427
2427
|
if (!res.ok) return false;
|
|
2428
2428
|
const json = await res.json();
|
|
2429
2429
|
const held = json.permissions ?? [];
|
|
2430
|
-
return Boolean(json.isSuperAdmin) || held.includes("update-email-templates")
|
|
2430
|
+
return Boolean(json.isSuperAdmin) || held.includes("update-email-templates");
|
|
2431
2431
|
} catch {
|
|
2432
2432
|
return false;
|
|
2433
2433
|
}
|
|
@@ -4776,6 +4776,135 @@ function FormBuilderView({ id, entryId, collection, collectionSlug, isCreating,
|
|
|
4776
4776
|
}, providerKey);
|
|
4777
4777
|
}
|
|
4778
4778
|
|
|
4779
|
+
// src/dashboard/mark-read.ts
|
|
4780
|
+
/**
|
|
4781
|
+
* Marking a submission read when it is opened from the New form submissions
|
|
4782
|
+
* card: the status the submissions list sets, through the same collection
|
|
4783
|
+
* update the list's own status changes are sent through, as the reader.
|
|
4784
|
+
*
|
|
4785
|
+
* Sent as an update of the submissions that match the id AND are still new,
|
|
4786
|
+
* so a submission someone archived, flagged or read since the card loaded is
|
|
4787
|
+
* matched by nothing and keeps its status. The update is judged as every
|
|
4788
|
+
* update of the collection is (`update-<slug>` and its rule): a reader who
|
|
4789
|
+
* may not update submissions is refused, and the submission stays new.
|
|
4790
|
+
*
|
|
4791
|
+
* @module dashboard/mark-read
|
|
4792
|
+
*/
|
|
4793
|
+
/** The status an opened submission moves to, as the submissions list names it. */
|
|
4794
|
+
const READ_STATUS = "read";
|
|
4795
|
+
/** The admin's API root, which the submissions list sends its updates to. */
|
|
4796
|
+
const ADMIN_API = "/admin/api";
|
|
4797
|
+
/** The request that marks submission `id` of `collection` read while it is still new. */
|
|
4798
|
+
function markReadRequest(collection, id) {
|
|
4799
|
+
return {
|
|
4800
|
+
url: `${ADMIN_API}/collections/${encodeURIComponent(collection)}/entries`,
|
|
4801
|
+
init: {
|
|
4802
|
+
method: "PATCH",
|
|
4803
|
+
headers: { "Content-Type": "application/json" },
|
|
4804
|
+
credentials: "include",
|
|
4805
|
+
keepalive: true,
|
|
4806
|
+
body: JSON.stringify({
|
|
4807
|
+
where: {
|
|
4808
|
+
id: { equals: id },
|
|
4809
|
+
status: { equals: "new" }
|
|
4810
|
+
},
|
|
4811
|
+
data: { status: READ_STATUS }
|
|
4812
|
+
})
|
|
4813
|
+
}
|
|
4814
|
+
};
|
|
4815
|
+
}
|
|
4816
|
+
/**
|
|
4817
|
+
* Marks submission `id` read, answering whether the update was taken. A
|
|
4818
|
+
* refusal or a failed request answers `false` and leaves it new, which the
|
|
4819
|
+
* card and the list then still say; it never rejects.
|
|
4820
|
+
*/
|
|
4821
|
+
async function markRead(collection, id) {
|
|
4822
|
+
const { url, init } = markReadRequest(collection, id);
|
|
4823
|
+
try {
|
|
4824
|
+
return (await fetch(url, init)).ok;
|
|
4825
|
+
} catch {
|
|
4826
|
+
return false;
|
|
4827
|
+
}
|
|
4828
|
+
}
|
|
4829
|
+
|
|
4830
|
+
// src/dashboard/NewSubmissionsCard.tsx
|
|
4831
|
+
/**
|
|
4832
|
+
* The New form submissions card's body: the newest new submissions as core's
|
|
4833
|
+
* list rows, each opening its submission and marking it read, with the
|
|
4834
|
+
* card's footer leading to every submission, and how many are new beside its
|
|
4835
|
+
* title. While nothing is new it says so, with a link to every submission,
|
|
4836
|
+
* and its title carries no count.
|
|
4837
|
+
*
|
|
4838
|
+
* Drawn only with data: the frame draws loading and every failure itself.
|
|
4839
|
+
* The empty state is drawn here rather than by the frame, because its link
|
|
4840
|
+
* is the submissions collection the site installed, which only the card's
|
|
4841
|
+
* data knows; the frame's would name the slug the plugin declared. Built from
|
|
4842
|
+
* the widget kit alone, so it reads like core's list cards beside it.
|
|
4843
|
+
*
|
|
4844
|
+
* @module dashboard/NewSubmissionsCard
|
|
4845
|
+
*/
|
|
4846
|
+
/** The mouse button that opens a link in a new tab. */
|
|
4847
|
+
const MIDDLE_BUTTON = 1;
|
|
4848
|
+
/** What a row says under its title: its form, and the first line of its first text answer. */
|
|
4849
|
+
function metaOf(row) {
|
|
4850
|
+
return [row.form, row.excerpt].filter((part) => part !== void 0);
|
|
4851
|
+
}
|
|
4852
|
+
/** The row whose link a click landed on, if it landed on one. */
|
|
4853
|
+
function openedRow(event, rows) {
|
|
4854
|
+
if (!(event.target instanceof Element)) return void 0;
|
|
4855
|
+
const href = event.target.closest("a[href]")?.getAttribute("href");
|
|
4856
|
+
return href === null || href === void 0 ? void 0 : rows.find((row) => row.href === href);
|
|
4857
|
+
}
|
|
4858
|
+
/**
|
|
4859
|
+
* Nothing new, with a way to every submission. Offered to whoever sees the
|
|
4860
|
+
* card: the card is shown only to a reader who may read the submissions
|
|
4861
|
+
* collection the site installed, which is where the link leads.
|
|
4862
|
+
*/
|
|
4863
|
+
function NothingNew({ allHref }) {
|
|
4864
|
+
return /* @__PURE__ */ jsx(FrameState, { state: {
|
|
4865
|
+
kind: "empty",
|
|
4866
|
+
empty: {
|
|
4867
|
+
title: "No new submissions",
|
|
4868
|
+
action: {
|
|
4869
|
+
label: "All submissions",
|
|
4870
|
+
href: allHref
|
|
4871
|
+
}
|
|
4872
|
+
}
|
|
4873
|
+
} });
|
|
4874
|
+
}
|
|
4875
|
+
/** The card's rows, as many as its size holds. */
|
|
4876
|
+
function NewSubmissionsCard({ data }) {
|
|
4877
|
+
const now = useWidgetClock();
|
|
4878
|
+
const refresh = useRefreshDashboard();
|
|
4879
|
+
Widget.useTitleCount(data.total > 0 ? data.total : void 0, data.atLeast === true);
|
|
4880
|
+
if (data.total === 0) return /* @__PURE__ */ jsx(NothingNew, { allHref: data.allHref });
|
|
4881
|
+
const opened = (event) => {
|
|
4882
|
+
const row = openedRow(event, data.items);
|
|
4883
|
+
if (row === void 0) return;
|
|
4884
|
+
markRead(data.collection, row.id).then((taken) => {
|
|
4885
|
+
if (taken) refresh();
|
|
4886
|
+
});
|
|
4887
|
+
};
|
|
4888
|
+
return /* @__PURE__ */ jsx("div", {
|
|
4889
|
+
className: "contents",
|
|
4890
|
+
onClickCapture: opened,
|
|
4891
|
+
onAuxClickCapture: (event) => {
|
|
4892
|
+
if (event.button === MIDDLE_BUTTON) opened(event);
|
|
4893
|
+
},
|
|
4894
|
+
children: /* @__PURE__ */ jsx(Widget.List, {
|
|
4895
|
+
rows: data.items,
|
|
4896
|
+
title: (row) => row.title,
|
|
4897
|
+
href: (row) => row.href,
|
|
4898
|
+
meta: metaOf,
|
|
4899
|
+
trailing: (row) => row.at === void 0 ? void 0 : /* @__PURE__ */ jsx("time", {
|
|
4900
|
+
dateTime: row.at,
|
|
4901
|
+
children: formatWidgetTime(row.at, now)
|
|
4902
|
+
}),
|
|
4903
|
+
viewAllHref: data.allHref
|
|
4904
|
+
})
|
|
4905
|
+
});
|
|
4906
|
+
}
|
|
4907
|
+
|
|
4779
4908
|
// src/admin/index.ts
|
|
4780
4909
|
/**
|
|
4781
4910
|
* Form Builder Admin Components
|
|
@@ -4823,5 +4952,5 @@ registerKnownPlugin("@nextlyhq/plugin-form-builder", async () => {
|
|
|
4823
4952
|
});
|
|
4824
4953
|
});
|
|
4825
4954
|
|
|
4826
|
-
export { AddFieldDialog, DEFAULT_SETTINGS, FORM_BUILDER_VIEW_PATH, FieldCards, FieldEditor, FormBuilderProvider, FormBuilderView, FormNotificationsTab, FormPreview, FormSettingsTab, SUBMISSIONS_VIEW_PATH, SubmissionSheet, SubmissionsView, createFieldFromType, createNotification, generateFieldLabel, generateFieldName, useFormBuilder, useOptionalFormBuilder };
|
|
4955
|
+
export { AddFieldDialog, DEFAULT_SETTINGS, FORM_BUILDER_VIEW_PATH, FieldCards, FieldEditor, FormBuilderProvider, FormBuilderView, FormNotificationsTab, FormPreview, FormSettingsTab, NewSubmissionsCard, SUBMISSIONS_VIEW_PATH, SubmissionSheet, SubmissionsView, createFieldFromType, createNotification, generateFieldLabel, generateFieldName, useFormBuilder, useOptionalFormBuilder };
|
|
4827
4956
|
//# sourceMappingURL=index.js.map
|