@btst/stack 1.5.2 → 1.6.0
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/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.cjs +68 -0
- package/dist/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.mjs +60 -0
- package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.cjs +3937 -0
- package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.mjs +3907 -0
- package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.cjs +30 -0
- package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.mjs +28 -0
- package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.cjs +675 -0
- package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.mjs +661 -0
- package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.cjs +358 -0
- package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.mjs +332 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.cjs +211 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.mjs +188 -0
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.cjs +3 -2
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.mjs +3 -2
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.cjs +15 -15
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.mjs +16 -16
- package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.cjs +588 -0
- package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.mjs +586 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +131 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +129 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.cjs +32 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.mjs +30 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.cjs +21 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.mjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.cjs +34 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.mjs +32 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.cjs +20 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.mjs +18 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +186 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +184 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +165 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +163 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +177 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +175 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.cjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.mjs +15 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.cjs +16 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.mjs +14 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +27 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +25 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.cjs +39 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.mjs +37 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +551 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +537 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.cjs +36 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.mjs +34 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.cjs +21 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.mjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.cjs +14 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.mjs +12 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.cjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.mjs +15 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.cjs +278 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.mjs +276 -0
- package/dist/packages/better-stack/src/plugins/form-builder/db.cjs +99 -0
- package/dist/packages/better-stack/src/plugins/form-builder/db.mjs +97 -0
- package/dist/packages/better-stack/src/plugins/form-builder/schemas.cjs +82 -0
- package/dist/packages/better-stack/src/plugins/form-builder/schemas.mjs +74 -0
- package/dist/packages/better-stack/src/plugins/form-builder/utils.cjs +37 -0
- package/dist/packages/better-stack/src/plugins/form-builder/utils.mjs +29 -0
- package/dist/packages/ui/src/components/auto-form/index.cjs +2 -12
- package/dist/packages/ui/src/components/auto-form/index.mjs +2 -9
- package/dist/packages/ui/src/components/auto-form/stepped-auto-form.cjs +377 -0
- package/dist/packages/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/packages/ui/src/components/auto-form/utils.cjs +1 -56
- package/dist/packages/ui/src/components/auto-form/utils.mjs +2 -56
- package/dist/packages/ui/src/components/form-builder/canvas.cjs +111 -0
- package/dist/packages/ui/src/components/form-builder/canvas.mjs +109 -0
- package/dist/packages/ui/src/components/form-builder/components/index.cjs +570 -0
- package/dist/packages/ui/src/components/form-builder/components/index.mjs +553 -0
- package/dist/packages/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
- package/dist/packages/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
- package/dist/packages/ui/src/components/form-builder/form-preview.cjs +73 -0
- package/dist/packages/ui/src/components/form-builder/form-preview.mjs +71 -0
- package/dist/packages/ui/src/components/form-builder/index.cjs +353 -0
- package/dist/packages/ui/src/components/form-builder/index.mjs +344 -0
- package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
- package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
- package/dist/packages/ui/src/components/form-builder/palette.cjs +52 -0
- package/dist/packages/ui/src/components/form-builder/palette.mjs +49 -0
- package/dist/packages/ui/src/components/form-builder/schema-utils.cjs +120 -0
- package/dist/packages/ui/src/components/form-builder/schema-utils.mjs +114 -0
- package/dist/packages/ui/src/components/form-builder/sortable-field.cjs +151 -0
- package/dist/packages/ui/src/components/form-builder/sortable-field.mjs +148 -0
- package/dist/packages/ui/src/components/form-builder/step-tabs.cjs +180 -0
- package/dist/packages/ui/src/components/form-builder/step-tabs.mjs +178 -0
- package/dist/packages/ui/src/components/form-builder/types.cjs +7 -0
- package/dist/packages/ui/src/components/form-builder/types.mjs +5 -0
- package/dist/packages/ui/src/components/form-builder/validation-schemas.cjs +67 -0
- package/dist/packages/ui/src/components/form-builder/validation-schemas.mjs +56 -0
- package/dist/packages/ui/src/components/tabs.cjs +70 -0
- package/dist/packages/ui/src/components/tabs.mjs +65 -0
- package/dist/packages/ui/src/lib/schema-converter.cjs +130 -0
- package/dist/packages/ui/src/lib/schema-converter.mjs +124 -0
- package/dist/plugins/blog/api/index.d.cts +1 -1
- package/dist/plugins/blog/api/index.d.mts +1 -1
- package/dist/plugins/blog/api/index.d.ts +1 -1
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/plugins/cms/client/index.cjs +6 -0
- package/dist/plugins/cms/client/index.d.cts +6 -113
- package/dist/plugins/cms/client/index.d.mts +6 -113
- package/dist/plugins/cms/client/index.d.ts +6 -113
- package/dist/plugins/cms/client/index.mjs +1 -0
- package/dist/plugins/form-builder/api/index.cjs +7 -0
- package/dist/plugins/form-builder/api/index.d.cts +141 -0
- package/dist/plugins/form-builder/api/index.d.mts +141 -0
- package/dist/plugins/form-builder/api/index.d.ts +141 -0
- package/dist/plugins/form-builder/api/index.mjs +1 -0
- package/dist/plugins/form-builder/client/components/index.cjs +29 -0
- package/dist/plugins/form-builder/client/components/index.d.cts +93 -0
- package/dist/plugins/form-builder/client/components/index.d.mts +93 -0
- package/dist/plugins/form-builder/client/components/index.d.ts +93 -0
- package/dist/plugins/form-builder/client/components/index.mjs +18 -0
- package/dist/plugins/form-builder/client/hooks/index.cjs +19 -0
- package/dist/plugins/form-builder/client/hooks/index.d.cts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.d.mts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.d.ts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.mjs +1 -0
- package/dist/plugins/form-builder/client/index.cjs +13 -0
- package/dist/plugins/form-builder/client/index.d.cts +381 -0
- package/dist/plugins/form-builder/client/index.d.mts +381 -0
- package/dist/plugins/form-builder/client/index.d.ts +381 -0
- package/dist/plugins/form-builder/client/index.mjs +2 -0
- package/dist/plugins/form-builder/client.css +3 -0
- package/dist/plugins/form-builder/query-keys.cjs +143 -0
- package/dist/plugins/form-builder/query-keys.d.cts +74 -0
- package/dist/plugins/form-builder/query-keys.d.mts +74 -0
- package/dist/plugins/form-builder/query-keys.d.ts +74 -0
- package/dist/plugins/form-builder/query-keys.mjs +141 -0
- package/dist/plugins/form-builder/style.css +19 -0
- package/dist/shared/stack.AX5nZ6A3.d.cts +86 -0
- package/dist/shared/stack.AX5nZ6A3.d.mts +86 -0
- package/dist/shared/stack.AX5nZ6A3.d.ts +86 -0
- package/dist/shared/stack.BIh2AXaW.d.cts +123 -0
- package/dist/shared/stack.BIh2AXaW.d.mts +123 -0
- package/dist/shared/stack.BIh2AXaW.d.ts +123 -0
- package/dist/shared/stack.DzH_wcvr.d.cts +195 -0
- package/dist/shared/stack.DzH_wcvr.d.mts +195 -0
- package/dist/shared/stack.DzH_wcvr.d.ts +195 -0
- package/package.json +54 -1
- package/src/plugins/cms/api/plugin.ts +9 -4
- package/src/plugins/cms/client/components/forms/content-form.tsx +23 -25
- package/src/plugins/cms/client/index.ts +11 -0
- package/src/plugins/form-builder/api/index.ts +1 -0
- package/src/plugins/form-builder/api/plugin.ts +776 -0
- package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +253 -0
- package/src/plugins/form-builder/client/components/index.tsx +24 -0
- package/src/plugins/form-builder/client/components/loading/form-builder-skeleton.tsx +42 -0
- package/src/plugins/form-builder/client/components/loading/form-list-skeleton.tsx +25 -0
- package/src/plugins/form-builder/client/components/loading/index.tsx +3 -0
- package/src/plugins/form-builder/client/components/loading/submissions-skeleton.tsx +40 -0
- package/src/plugins/form-builder/client/components/pages/404-page.tsx +28 -0
- package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +253 -0
- package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +26 -0
- package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +231 -0
- package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +22 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +268 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +26 -0
- package/src/plugins/form-builder/client/components/shared/default-error.tsx +30 -0
- package/src/plugins/form-builder/client/components/shared/empty-state.tsx +26 -0
- package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/form-builder/client/components/shared/pagination.tsx +52 -0
- package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +799 -0
- package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
- package/src/plugins/form-builder/client/index.ts +22 -0
- package/src/plugins/form-builder/client/localization/form-builder-common.ts +36 -0
- package/src/plugins/form-builder/client/localization/form-builder-editor.ts +18 -0
- package/src/plugins/form-builder/client/localization/form-builder-list.ts +17 -0
- package/src/plugins/form-builder/client/localization/form-builder-submissions.ts +17 -0
- package/src/plugins/form-builder/client/localization/form-builder-toasts.ts +10 -0
- package/src/plugins/form-builder/client/localization/index.ts +15 -0
- package/src/plugins/form-builder/client/overrides.ts +146 -0
- package/src/plugins/form-builder/client/plugin.tsx +488 -0
- package/src/plugins/form-builder/client.css +3 -0
- package/src/plugins/form-builder/db.ts +99 -0
- package/src/plugins/form-builder/query-keys.ts +198 -0
- package/src/plugins/form-builder/schemas.ts +122 -0
- package/src/plugins/form-builder/style.css +19 -0
- package/src/plugins/form-builder/types.ts +317 -0
- package/src/plugins/form-builder/utils.ts +63 -0
- package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.cts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.mts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.ts} +1 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const context = require('@btst/stack/context');
|
|
7
|
+
const button = require('../../../../../../../ui/src/components/button.cjs');
|
|
8
|
+
const input = require('../../../../../../../ui/src/components/input.cjs');
|
|
9
|
+
const label = require('../../../../../../../ui/src/components/label.cjs');
|
|
10
|
+
const select = require('../../../../../../../ui/src/components/select.cjs');
|
|
11
|
+
const lucideReact = require('lucide-react');
|
|
12
|
+
const sonner = require('sonner');
|
|
13
|
+
const index$1 = require('../../../../../../../ui/src/components/form-builder/index.cjs');
|
|
14
|
+
const formBuilderHooks = require('../../hooks/form-builder-hooks.cjs');
|
|
15
|
+
const index = require('../../localization/index.cjs');
|
|
16
|
+
const utils = require('../../../utils.cjs');
|
|
17
|
+
|
|
18
|
+
function FormBuilderPage({ id }) {
|
|
19
|
+
if (id) {
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EditFormBuilderPage, { id });
|
|
21
|
+
}
|
|
22
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CreateFormBuilderPage, {});
|
|
23
|
+
}
|
|
24
|
+
function EditFormBuilderPage({ id }) {
|
|
25
|
+
const { form: existingForm } = formBuilderHooks.useSuspenseFormById(id);
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormBuilderPageContent, { id, existingForm });
|
|
27
|
+
}
|
|
28
|
+
function CreateFormBuilderPage() {
|
|
29
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormBuilderPageContent, {});
|
|
30
|
+
}
|
|
31
|
+
function FormBuilderPageContent({
|
|
32
|
+
id,
|
|
33
|
+
existingForm
|
|
34
|
+
}) {
|
|
35
|
+
const { navigate, Link, localization } = context.usePluginOverrides("form-builder", {
|
|
36
|
+
localization: index.FORM_BUILDER_LOCALIZATION
|
|
37
|
+
});
|
|
38
|
+
const basePath = context.useBasePath();
|
|
39
|
+
const createMutation = formBuilderHooks.useCreateForm();
|
|
40
|
+
const updateMutation = formBuilderHooks.useUpdateForm();
|
|
41
|
+
const loc = localization || index.FORM_BUILDER_LOCALIZATION;
|
|
42
|
+
const LinkComponent = Link || "a";
|
|
43
|
+
const [name, setName] = React.useState(existingForm?.name || "");
|
|
44
|
+
const [slug, setSlug] = React.useState(existingForm?.slug || "");
|
|
45
|
+
const [status, setStatus] = React.useState(
|
|
46
|
+
existingForm?.status || "active"
|
|
47
|
+
);
|
|
48
|
+
const [schema, setSchema] = React.useState(() => {
|
|
49
|
+
if (existingForm?.schema) {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(existingForm.schema);
|
|
52
|
+
} catch {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return void 0;
|
|
57
|
+
});
|
|
58
|
+
const [autoSlug, setAutoSlug] = React.useState(!id);
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
if (autoSlug && name) {
|
|
61
|
+
setSlug(utils.slugify(name));
|
|
62
|
+
}
|
|
63
|
+
}, [name, autoSlug]);
|
|
64
|
+
const handleSchemaChange = React.useCallback((newSchema) => {
|
|
65
|
+
setSchema(newSchema);
|
|
66
|
+
}, []);
|
|
67
|
+
const handleSave = async () => {
|
|
68
|
+
if (!name.trim()) {
|
|
69
|
+
sonner.toast.error("Name is required");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (!slug.trim()) {
|
|
73
|
+
sonner.toast.error("Slug is required");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!schema) {
|
|
77
|
+
sonner.toast.error("Please add at least one field to the form");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const schemaStr = JSON.stringify(schema);
|
|
82
|
+
if (id) {
|
|
83
|
+
await updateMutation.mutateAsync({
|
|
84
|
+
id,
|
|
85
|
+
data: {
|
|
86
|
+
name,
|
|
87
|
+
schema: schemaStr,
|
|
88
|
+
status
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
sonner.toast.success(loc.FORM_BUILDER_TOAST_UPDATE_SUCCESS);
|
|
92
|
+
} else {
|
|
93
|
+
const newForm = await createMutation.mutateAsync({
|
|
94
|
+
name,
|
|
95
|
+
slug,
|
|
96
|
+
schema: schemaStr,
|
|
97
|
+
status
|
|
98
|
+
});
|
|
99
|
+
sonner.toast.success(loc.FORM_BUILDER_TOAST_CREATE_SUCCESS);
|
|
100
|
+
navigate?.(`${basePath}/forms/${newForm.id}/edit`);
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
104
|
+
if (message.includes("slug already exists")) {
|
|
105
|
+
sonner.toast.error(loc.FORM_BUILDER_TOAST_DUPLICATE_SLUG);
|
|
106
|
+
} else {
|
|
107
|
+
sonner.toast.error(loc.FORM_BUILDER_TOAST_ERROR);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const isSaving = createMutation.isPending || updateMutation.isPending;
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", "data-testid": "form-builder-page", children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 border-b p-4", children: [
|
|
114
|
+
/* @__PURE__ */ jsxRuntime.jsx(button.Button, { variant: "ghost", size: "icon", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(LinkComponent, { href: `${basePath}/forms`, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: "h-4 w-4" }) }) }),
|
|
115
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
116
|
+
/* @__PURE__ */ jsxRuntime.jsx(label.Label, { htmlFor: "form-name", className: "text-xs text-muted-foreground", children: loc.FORM_BUILDER_LABEL_NAME }),
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
+
input.Input,
|
|
119
|
+
{
|
|
120
|
+
id: "form-name",
|
|
121
|
+
value: name,
|
|
122
|
+
onChange: (e) => setName(e.target.value),
|
|
123
|
+
placeholder: loc.FORM_BUILDER_EDITOR_NAME_PLACEHOLDER,
|
|
124
|
+
className: "h-8 w-48"
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
] }),
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx(label.Label, { htmlFor: "form-slug", className: "text-xs text-muted-foreground", children: loc.FORM_BUILDER_LABEL_SLUG }),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
+
input.Input,
|
|
132
|
+
{
|
|
133
|
+
id: "form-slug",
|
|
134
|
+
value: slug,
|
|
135
|
+
onChange: (e) => {
|
|
136
|
+
setSlug(e.target.value);
|
|
137
|
+
setAutoSlug(false);
|
|
138
|
+
},
|
|
139
|
+
placeholder: loc.FORM_BUILDER_EDITOR_SLUG_PLACEHOLDER,
|
|
140
|
+
className: "h-8 w-48 font-mono text-sm",
|
|
141
|
+
disabled: !!id
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
] }),
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
147
|
+
label.Label,
|
|
148
|
+
{
|
|
149
|
+
htmlFor: "form-status",
|
|
150
|
+
className: "text-xs text-muted-foreground",
|
|
151
|
+
children: loc.FORM_BUILDER_LABEL_STATUS
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
155
|
+
select.Select,
|
|
156
|
+
{
|
|
157
|
+
value: status,
|
|
158
|
+
onValueChange: (v) => setStatus(v),
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.SelectTrigger, { className: "h-8 w-28", children: /* @__PURE__ */ jsxRuntime.jsx(select.SelectValue, {}) }),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsxs(select.SelectContent, { children: [
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.SelectItem, { value: "active", children: loc.FORM_BUILDER_STATUS_ACTIVE }),
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.SelectItem, { value: "inactive", children: loc.FORM_BUILDER_STATUS_INACTIVE }),
|
|
164
|
+
/* @__PURE__ */ jsxRuntime.jsx(select.SelectItem, { value: "archived", children: loc.FORM_BUILDER_STATUS_ARCHIVED })
|
|
165
|
+
] })
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] }),
|
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsxs(button.Button, { onClick: handleSave, disabled: isSaving, children: [
|
|
171
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "mr-2 h-4 w-4" }),
|
|
172
|
+
isSaving ? loc.FORM_BUILDER_STATUS_SAVING : id ? loc.FORM_BUILDER_BUTTON_SAVE : loc.FORM_BUILDER_BUTTON_CREATE
|
|
173
|
+
] }) })
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
176
|
+
index$1.FormBuilder,
|
|
177
|
+
{
|
|
178
|
+
value: schema,
|
|
179
|
+
onChange: handleSchemaChange,
|
|
180
|
+
className: "flex-1"
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
] });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
exports.FormBuilderPage = FormBuilderPage;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import { usePluginOverrides, useBasePath } from '@btst/stack/context';
|
|
5
|
+
import { Button } from '../../../../../../../ui/src/components/button.mjs';
|
|
6
|
+
import { Input } from '../../../../../../../ui/src/components/input.mjs';
|
|
7
|
+
import { Label } from '../../../../../../../ui/src/components/label.mjs';
|
|
8
|
+
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../../../../../../../ui/src/components/select.mjs';
|
|
9
|
+
import { ArrowLeft, Save } from 'lucide-react';
|
|
10
|
+
import { toast } from 'sonner';
|
|
11
|
+
import { FormBuilder } from '../../../../../../../ui/src/components/form-builder/index.mjs';
|
|
12
|
+
import { useSuspenseFormById, useCreateForm, useUpdateForm } from '../../hooks/form-builder-hooks.mjs';
|
|
13
|
+
import { FORM_BUILDER_LOCALIZATION } from '../../localization/index.mjs';
|
|
14
|
+
import { slugify } from '../../../utils.mjs';
|
|
15
|
+
|
|
16
|
+
function FormBuilderPage({ id }) {
|
|
17
|
+
if (id) {
|
|
18
|
+
return /* @__PURE__ */ jsx(EditFormBuilderPage, { id });
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ jsx(CreateFormBuilderPage, {});
|
|
21
|
+
}
|
|
22
|
+
function EditFormBuilderPage({ id }) {
|
|
23
|
+
const { form: existingForm } = useSuspenseFormById(id);
|
|
24
|
+
return /* @__PURE__ */ jsx(FormBuilderPageContent, { id, existingForm });
|
|
25
|
+
}
|
|
26
|
+
function CreateFormBuilderPage() {
|
|
27
|
+
return /* @__PURE__ */ jsx(FormBuilderPageContent, {});
|
|
28
|
+
}
|
|
29
|
+
function FormBuilderPageContent({
|
|
30
|
+
id,
|
|
31
|
+
existingForm
|
|
32
|
+
}) {
|
|
33
|
+
const { navigate, Link, localization } = usePluginOverrides("form-builder", {
|
|
34
|
+
localization: FORM_BUILDER_LOCALIZATION
|
|
35
|
+
});
|
|
36
|
+
const basePath = useBasePath();
|
|
37
|
+
const createMutation = useCreateForm();
|
|
38
|
+
const updateMutation = useUpdateForm();
|
|
39
|
+
const loc = localization || FORM_BUILDER_LOCALIZATION;
|
|
40
|
+
const LinkComponent = Link || "a";
|
|
41
|
+
const [name, setName] = useState(existingForm?.name || "");
|
|
42
|
+
const [slug, setSlug] = useState(existingForm?.slug || "");
|
|
43
|
+
const [status, setStatus] = useState(
|
|
44
|
+
existingForm?.status || "active"
|
|
45
|
+
);
|
|
46
|
+
const [schema, setSchema] = useState(() => {
|
|
47
|
+
if (existingForm?.schema) {
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(existingForm.schema);
|
|
50
|
+
} catch {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
});
|
|
56
|
+
const [autoSlug, setAutoSlug] = useState(!id);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (autoSlug && name) {
|
|
59
|
+
setSlug(slugify(name));
|
|
60
|
+
}
|
|
61
|
+
}, [name, autoSlug]);
|
|
62
|
+
const handleSchemaChange = useCallback((newSchema) => {
|
|
63
|
+
setSchema(newSchema);
|
|
64
|
+
}, []);
|
|
65
|
+
const handleSave = async () => {
|
|
66
|
+
if (!name.trim()) {
|
|
67
|
+
toast.error("Name is required");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (!slug.trim()) {
|
|
71
|
+
toast.error("Slug is required");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!schema) {
|
|
75
|
+
toast.error("Please add at least one field to the form");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const schemaStr = JSON.stringify(schema);
|
|
80
|
+
if (id) {
|
|
81
|
+
await updateMutation.mutateAsync({
|
|
82
|
+
id,
|
|
83
|
+
data: {
|
|
84
|
+
name,
|
|
85
|
+
schema: schemaStr,
|
|
86
|
+
status
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
toast.success(loc.FORM_BUILDER_TOAST_UPDATE_SUCCESS);
|
|
90
|
+
} else {
|
|
91
|
+
const newForm = await createMutation.mutateAsync({
|
|
92
|
+
name,
|
|
93
|
+
slug,
|
|
94
|
+
schema: schemaStr,
|
|
95
|
+
status
|
|
96
|
+
});
|
|
97
|
+
toast.success(loc.FORM_BUILDER_TOAST_CREATE_SUCCESS);
|
|
98
|
+
navigate?.(`${basePath}/forms/${newForm.id}/edit`);
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
102
|
+
if (message.includes("slug already exists")) {
|
|
103
|
+
toast.error(loc.FORM_BUILDER_TOAST_DUPLICATE_SLUG);
|
|
104
|
+
} else {
|
|
105
|
+
toast.error(loc.FORM_BUILDER_TOAST_ERROR);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const isSaving = createMutation.isPending || updateMutation.isPending;
|
|
110
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col", "data-testid": "form-builder-page", children: [
|
|
111
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 border-b p-4", children: [
|
|
112
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", asChild: true, children: /* @__PURE__ */ jsx(LinkComponent, { href: `${basePath}/forms`, children: /* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4" }) }) }),
|
|
113
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
114
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "form-name", className: "text-xs text-muted-foreground", children: loc.FORM_BUILDER_LABEL_NAME }),
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
Input,
|
|
117
|
+
{
|
|
118
|
+
id: "form-name",
|
|
119
|
+
value: name,
|
|
120
|
+
onChange: (e) => setName(e.target.value),
|
|
121
|
+
placeholder: loc.FORM_BUILDER_EDITOR_NAME_PLACEHOLDER,
|
|
122
|
+
className: "h-8 w-48"
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
127
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "form-slug", className: "text-xs text-muted-foreground", children: loc.FORM_BUILDER_LABEL_SLUG }),
|
|
128
|
+
/* @__PURE__ */ jsx(
|
|
129
|
+
Input,
|
|
130
|
+
{
|
|
131
|
+
id: "form-slug",
|
|
132
|
+
value: slug,
|
|
133
|
+
onChange: (e) => {
|
|
134
|
+
setSlug(e.target.value);
|
|
135
|
+
setAutoSlug(false);
|
|
136
|
+
},
|
|
137
|
+
placeholder: loc.FORM_BUILDER_EDITOR_SLUG_PLACEHOLDER,
|
|
138
|
+
className: "h-8 w-48 font-mono text-sm",
|
|
139
|
+
disabled: !!id
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
Label,
|
|
146
|
+
{
|
|
147
|
+
htmlFor: "form-status",
|
|
148
|
+
className: "text-xs text-muted-foreground",
|
|
149
|
+
children: loc.FORM_BUILDER_LABEL_STATUS
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ jsxs(
|
|
153
|
+
Select,
|
|
154
|
+
{
|
|
155
|
+
value: status,
|
|
156
|
+
onValueChange: (v) => setStatus(v),
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-28", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
159
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
160
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "active", children: loc.FORM_BUILDER_STATUS_ACTIVE }),
|
|
161
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "inactive", children: loc.FORM_BUILDER_STATUS_INACTIVE }),
|
|
162
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "archived", children: loc.FORM_BUILDER_STATUS_ARCHIVED })
|
|
163
|
+
] })
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsx("div", { className: "ml-auto", children: /* @__PURE__ */ jsxs(Button, { onClick: handleSave, disabled: isSaving, children: [
|
|
169
|
+
/* @__PURE__ */ jsx(Save, { className: "mr-2 h-4 w-4" }),
|
|
170
|
+
isSaving ? loc.FORM_BUILDER_STATUS_SAVING : id ? loc.FORM_BUILDER_BUTTON_SAVE : loc.FORM_BUILDER_BUTTON_CREATE
|
|
171
|
+
] }) })
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ jsx(
|
|
174
|
+
FormBuilder,
|
|
175
|
+
{
|
|
176
|
+
value: schema,
|
|
177
|
+
onChange: handleSchemaChange,
|
|
178
|
+
className: "flex-1"
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
] });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export { FormBuilderPage };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Suspense, lazy } from 'react';
|
|
4
|
+
import { FormBuilderSkeleton } from '../loading/form-builder-skeleton.mjs';
|
|
5
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
6
|
+
import { DefaultError } from '../shared/default-error.mjs';
|
|
7
|
+
|
|
8
|
+
const FormBuilderPage = lazy(
|
|
9
|
+
() => import('./form-builder-page.internal.mjs').then((m) => ({
|
|
10
|
+
default: m.FormBuilderPage
|
|
11
|
+
}))
|
|
12
|
+
);
|
|
13
|
+
function FormBuilderPageComponent({ id }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent: DefaultError, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(FormBuilderSkeleton, {}), children: /* @__PURE__ */ jsx(FormBuilderPage, { id }) }) });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { FormBuilderPageComponent };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const formListSkeleton = require('../loading/form-list-skeleton.cjs');
|
|
7
|
+
const reactErrorBoundary = require('react-error-boundary');
|
|
8
|
+
const defaultError = require('../shared/default-error.cjs');
|
|
9
|
+
|
|
10
|
+
const FormListPage = React.lazy(
|
|
11
|
+
() => import('./form-list-page.internal.cjs').then((m) => ({
|
|
12
|
+
default: m.FormListPage
|
|
13
|
+
}))
|
|
14
|
+
);
|
|
15
|
+
function FormListPageComponent() {
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, { FallbackComponent: defaultError.DefaultError, children: /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(formListSkeleton.FormListSkeleton, {}), children: /* @__PURE__ */ jsxRuntime.jsx(FormListPage, {}) }) });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.FormListPageComponent = FormListPageComponent;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const context = require('@btst/stack/context');
|
|
7
|
+
const button = require('../../../../../../../ui/src/components/button.cjs');
|
|
8
|
+
const table = require('../../../../../../../ui/src/components/table.cjs');
|
|
9
|
+
const dropdownMenu = require('../../../../../../../ui/src/components/dropdown-menu.cjs');
|
|
10
|
+
const alertDialog = require('../../../../../../../ui/src/components/alert-dialog.cjs');
|
|
11
|
+
const lucideReact = require('lucide-react');
|
|
12
|
+
const sonner = require('sonner');
|
|
13
|
+
const formBuilderHooks = require('../../hooks/form-builder-hooks.cjs');
|
|
14
|
+
const index = require('../../localization/index.cjs');
|
|
15
|
+
const pageWrapper = require('../shared/page-wrapper.cjs');
|
|
16
|
+
const emptyState = require('../shared/empty-state.cjs');
|
|
17
|
+
const pagination = require('../shared/pagination.cjs');
|
|
18
|
+
|
|
19
|
+
function FormListPage() {
|
|
20
|
+
const { navigate, Link, localization } = context.usePluginOverrides("form-builder", {
|
|
21
|
+
localization: index.FORM_BUILDER_LOCALIZATION
|
|
22
|
+
});
|
|
23
|
+
const basePath = context.useBasePath();
|
|
24
|
+
const { forms, total, hasMore, isLoadingMore, loadMore, refetch } = formBuilderHooks.useSuspenseForms();
|
|
25
|
+
const deleteMutation = formBuilderHooks.useDeleteForm();
|
|
26
|
+
const [deleteId, setDeleteId] = React.useState(null);
|
|
27
|
+
const loc = localization || index.FORM_BUILDER_LOCALIZATION;
|
|
28
|
+
const LinkComponent = Link || "a";
|
|
29
|
+
const handleDelete = async () => {
|
|
30
|
+
if (!deleteId) return;
|
|
31
|
+
try {
|
|
32
|
+
await deleteMutation.mutateAsync(deleteId);
|
|
33
|
+
sonner.toast.success(loc.FORM_BUILDER_TOAST_DELETE_SUCCESS);
|
|
34
|
+
setDeleteId(null);
|
|
35
|
+
await refetch();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
sonner.toast.error(loc.FORM_BUILDER_TOAST_ERROR);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const getStatusBadge = (status) => {
|
|
41
|
+
const colors = {
|
|
42
|
+
active: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",
|
|
43
|
+
inactive: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",
|
|
44
|
+
archived: "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200"
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
"span",
|
|
48
|
+
{
|
|
49
|
+
className: `px-2 py-1 rounded-full text-xs font-medium ${colors[status] || colors.inactive}`,
|
|
50
|
+
children: status
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(pageWrapper.PageWrapper, { testId: "form-list-page", children: [
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-5xl space-y-6", children: [
|
|
56
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
57
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-bold", children: loc.FORM_BUILDER_LIST_TITLE }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: loc.FORM_BUILDER_LIST_SUBTITLE })
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx(button.Button, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(LinkComponent, { href: `${basePath}/forms/new`, children: [
|
|
62
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "mr-2 h-4 w-4" }),
|
|
63
|
+
loc.FORM_BUILDER_BUTTON_NEW_FORM
|
|
64
|
+
] }) })
|
|
65
|
+
] }),
|
|
66
|
+
forms.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
67
|
+
emptyState.EmptyState,
|
|
68
|
+
{
|
|
69
|
+
title: loc.FORM_BUILDER_LIST_EMPTY,
|
|
70
|
+
description: loc.FORM_BUILDER_LIST_EMPTY_DESCRIPTION,
|
|
71
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(button.Button, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(LinkComponent, { href: `${basePath}/forms/new`, children: [
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "mr-2 h-4 w-4" }),
|
|
73
|
+
loc.FORM_BUILDER_BUTTON_NEW_FORM
|
|
74
|
+
] }) })
|
|
75
|
+
}
|
|
76
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsxRuntime.jsxs(table.Table, { children: [
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_NAME }),
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_SLUG }),
|
|
81
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_STATUS }),
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { children: loc.FORM_BUILDER_LIST_COLUMN_CREATED }),
|
|
83
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableHead, { className: "w-12", children: loc.FORM_BUILDER_LIST_COLUMN_ACTIONS })
|
|
84
|
+
] }) }),
|
|
85
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableBody, { children: forms.map((form) => /* @__PURE__ */ jsxRuntime.jsxs(table.TableRow, { children: [
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "font-medium", children: form.name }),
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "text-muted-foreground font-mono text-sm", children: form.slug }),
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: getStatusBadge(form.status) }),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "text-muted-foreground", children: new Date(form.createdAt).toLocaleDateString() }),
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenu, { children: [
|
|
91
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(button.Button, { variant: "ghost", size: "icon", children: [
|
|
92
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "h-4 w-4" }),
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Actions" })
|
|
94
|
+
] }) }),
|
|
95
|
+
/* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenuContent, { align: "end", children: [
|
|
96
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
97
|
+
dropdownMenu.DropdownMenuItem,
|
|
98
|
+
{
|
|
99
|
+
onClick: () => navigate?.(`${basePath}/forms/${form.id}/edit`),
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "mr-2 h-4 w-4" }),
|
|
102
|
+
loc.FORM_BUILDER_LIST_ACTION_EDIT
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
107
|
+
dropdownMenu.DropdownMenuItem,
|
|
108
|
+
{
|
|
109
|
+
onClick: () => navigate?.(
|
|
110
|
+
`${basePath}/forms/${form.id}/submissions`
|
|
111
|
+
),
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "mr-2 h-4 w-4" }),
|
|
114
|
+
loc.FORM_BUILDER_LIST_ACTION_SUBMISSIONS
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
119
|
+
dropdownMenu.DropdownMenuItem,
|
|
120
|
+
{
|
|
121
|
+
className: "text-destructive",
|
|
122
|
+
onClick: () => setDeleteId(form.id),
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "mr-2 h-4 w-4" }),
|
|
125
|
+
loc.FORM_BUILDER_LIST_ACTION_DELETE
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
] })
|
|
130
|
+
] }) })
|
|
131
|
+
] }, form.id)) })
|
|
132
|
+
] }) }),
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
134
|
+
pagination.Pagination,
|
|
135
|
+
{
|
|
136
|
+
total,
|
|
137
|
+
showing: forms.length,
|
|
138
|
+
hasMore,
|
|
139
|
+
isLoadingMore,
|
|
140
|
+
onLoadMore: loadMore
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
] }),
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialog, { open: !!deleteId, onOpenChange: () => setDeleteId(null), children: /* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogContent, { children: [
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogHeader, { children: [
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogTitle, { children: "Delete Form" }),
|
|
148
|
+
/* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogDescription, { children: loc.FORM_BUILDER_EDITOR_DELETE_CONFIRM })
|
|
149
|
+
] }),
|
|
150
|
+
/* @__PURE__ */ jsxRuntime.jsxs(alertDialog.AlertDialogFooter, { children: [
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx(alertDialog.AlertDialogCancel, { children: loc.FORM_BUILDER_BUTTON_CANCEL }),
|
|
152
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
153
|
+
alertDialog.AlertDialogAction,
|
|
154
|
+
{
|
|
155
|
+
onClick: handleDelete,
|
|
156
|
+
className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
157
|
+
children: deleteMutation.isPending ? loc.FORM_BUILDER_STATUS_DELETING : loc.FORM_BUILDER_BUTTON_DELETE
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
] })
|
|
161
|
+
] }) })
|
|
162
|
+
] });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
exports.FormListPage = FormListPage;
|