@btst/components 0.0.0-stage → 1.0.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/LICENSE.md +17 -0
- package/dist/_private/ui/styles/markdown-editor.css +31 -0
- package/dist/auto-form/index.cjs +8 -0
- package/dist/auto-form/index.d.cts +26 -0
- package/dist/auto-form/index.d.mts +26 -0
- package/dist/auto-form/index.d.ts +26 -0
- package/dist/auto-form/index.mjs +1 -0
- package/dist/empty/index.cjs +12 -0
- package/dist/empty/index.d.cts +15 -0
- package/dist/empty/index.d.mts +15 -0
- package/dist/empty/index.d.ts +15 -0
- package/dist/empty/index.mjs +1 -0
- package/dist/form-builder/index.cjs +16 -0
- package/dist/form-builder/index.d.cts +395 -0
- package/dist/form-builder/index.d.mts +395 -0
- package/dist/form-builder/index.d.ts +395 -0
- package/dist/form-builder/index.mjs +4 -0
- package/dist/markdown/index.cjs +9 -0
- package/dist/markdown/index.d.cts +46 -0
- package/dist/markdown/index.d.mts +46 -0
- package/dist/markdown/index.d.ts +46 -0
- package/dist/markdown/index.mjs +2 -0
- package/dist/multi-select/index.cjs +7 -0
- package/dist/multi-select/index.d.cts +78 -0
- package/dist/multi-select/index.d.mts +78 -0
- package/dist/multi-select/index.d.ts +78 -0
- package/dist/multi-select/index.mjs +1 -0
- package/dist/search-select/index.cjs +7 -0
- package/dist/search-select/index.d.cts +16 -0
- package/dist/search-select/index.d.mts +16 -0
- package/dist/search-select/index.d.ts +16 -0
- package/dist/search-select/index.mjs +1 -0
- package/dist/shared/components.BdvBiegH.d.cts +291 -0
- package/dist/shared/components.BdvBiegH.d.mts +291 -0
- package/dist/shared/components.BdvBiegH.d.ts +291 -0
- package/dist/shared/components.CZMWR72v.d.cts +10 -0
- package/dist/shared/components.CZMWR72v.d.mts +10 -0
- package/dist/shared/components.CZMWR72v.d.ts +10 -0
- package/dist/stepped-auto-form/index.cjs +7 -0
- package/dist/stepped-auto-form/index.d.cts +37 -0
- package/dist/stepped-auto-form/index.d.mts +37 -0
- package/dist/stepped-auto-form/index.d.ts +37 -0
- package/dist/stepped-auto-form/index.mjs +1 -0
- package/dist/style.css +440 -0
- package/dist/ui/src/components/accordion.cjs +81 -0
- package/dist/ui/src/components/accordion.mjs +62 -0
- package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
- package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
- package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
- package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
- package/dist/ui/src/components/auto-form/config.cjs +40 -0
- package/dist/ui/src/components/auto-form/config.mjs +37 -0
- package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
- package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
- package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
- package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
- package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
- package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
- package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
- package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
- package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
- package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
- package/dist/ui/src/components/auto-form/index.cjs +102 -0
- package/dist/ui/src/components/auto-form/index.mjs +93 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/ui/src/components/auto-form/types.cjs +11 -0
- package/dist/ui/src/components/auto-form/types.mjs +9 -0
- package/dist/ui/src/components/badge.cjs +42 -0
- package/dist/ui/src/components/badge.mjs +39 -0
- package/dist/ui/src/components/button.cjs +56 -0
- package/dist/ui/src/components/button.mjs +53 -0
- package/dist/ui/src/components/calendar.cjs +207 -0
- package/dist/ui/src/components/calendar.mjs +190 -0
- package/dist/ui/src/components/checkbox.cjs +48 -0
- package/dist/ui/src/components/checkbox.mjs +32 -0
- package/dist/ui/src/components/command.cjs +118 -0
- package/dist/ui/src/components/command.mjs +111 -0
- package/dist/ui/src/components/date-picker.cjs +41 -0
- package/dist/ui/src/components/date-picker.mjs +39 -0
- package/dist/ui/src/components/dialog.cjs +141 -0
- package/dist/ui/src/components/dialog.mjs +118 -0
- package/dist/ui/src/components/empty.cjs +104 -0
- package/dist/ui/src/components/empty.mjs +97 -0
- package/dist/ui/src/components/form-builder/canvas.cjs +111 -0
- package/dist/ui/src/components/form-builder/canvas.mjs +109 -0
- package/dist/ui/src/components/form-builder/components/index.cjs +571 -0
- package/dist/ui/src/components/form-builder/components/index.mjs +554 -0
- package/dist/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
- package/dist/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
- package/dist/ui/src/components/form-builder/form-preview.cjs +73 -0
- package/dist/ui/src/components/form-builder/form-preview.mjs +71 -0
- package/dist/ui/src/components/form-builder/index.cjs +350 -0
- package/dist/ui/src/components/form-builder/index.mjs +344 -0
- package/dist/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
- package/dist/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
- package/dist/ui/src/components/form-builder/palette.cjs +52 -0
- package/dist/ui/src/components/form-builder/palette.mjs +49 -0
- package/dist/ui/src/components/form-builder/schema-utils.cjs +128 -0
- package/dist/ui/src/components/form-builder/schema-utils.mjs +122 -0
- package/dist/ui/src/components/form-builder/sortable-field.cjs +151 -0
- package/dist/ui/src/components/form-builder/sortable-field.mjs +148 -0
- package/dist/ui/src/components/form-builder/step-tabs.cjs +180 -0
- package/dist/ui/src/components/form-builder/step-tabs.mjs +178 -0
- package/dist/ui/src/components/form-builder/types.cjs +7 -0
- package/dist/ui/src/components/form-builder/types.mjs +5 -0
- package/dist/ui/src/components/form-builder/validation-schemas.cjs +67 -0
- package/dist/ui/src/components/form-builder/validation-schemas.mjs +56 -0
- package/dist/ui/src/components/form.cjs +120 -0
- package/dist/ui/src/components/form.mjs +98 -0
- package/dist/ui/src/components/input.cjs +23 -0
- package/dist/ui/src/components/input.mjs +21 -0
- package/dist/ui/src/components/label.cjs +39 -0
- package/dist/ui/src/components/label.mjs +23 -0
- package/dist/ui/src/components/markdown-content.cjs +334 -0
- package/dist/ui/src/components/markdown-content.mjs +325 -0
- package/dist/ui/src/components/markdown-editor.cjs +180 -0
- package/dist/ui/src/components/markdown-editor.mjs +178 -0
- package/dist/ui/src/components/multi-select.cjs +555 -0
- package/dist/ui/src/components/multi-select.mjs +540 -0
- package/dist/ui/src/components/popover.cjs +60 -0
- package/dist/ui/src/components/popover.mjs +42 -0
- package/dist/ui/src/components/radio-group.cjs +62 -0
- package/dist/ui/src/components/radio-group.mjs +45 -0
- package/dist/ui/src/components/search-select.cjs +99 -0
- package/dist/ui/src/components/search-select.mjs +83 -0
- package/dist/ui/src/components/select.cjs +161 -0
- package/dist/ui/src/components/select.mjs +139 -0
- package/dist/ui/src/components/separator.cjs +43 -0
- package/dist/ui/src/components/separator.mjs +27 -0
- package/dist/ui/src/components/switch.cjs +48 -0
- package/dist/ui/src/components/switch.mjs +32 -0
- package/dist/ui/src/components/tabs.cjs +84 -0
- package/dist/ui/src/components/tabs.mjs +65 -0
- package/dist/ui/src/components/textarea.cjs +20 -0
- package/dist/ui/src/components/textarea.mjs +18 -0
- package/dist/ui/src/hooks/use-debounce.cjs +16 -0
- package/dist/ui/src/hooks/use-debounce.mjs +14 -0
- package/dist/ui/src/lib/schema-converter.cjs +94 -0
- package/dist/ui/src/lib/schema-converter.mjs +92 -0
- package/dist/ui/src/lib/throttle.cjs +56 -0
- package/dist/ui/src/lib/throttle.mjs +54 -0
- package/dist/ui/src/lib/utils.cjs +10 -0
- package/dist/ui/src/lib/utils.mjs +8 -0
- package/dist/ui.css +131 -0
- package/package.json +176 -3
- package/README.md +0 -3
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const core = require('@dnd-kit/core');
|
|
7
|
+
const sortable = require('@dnd-kit/sortable');
|
|
8
|
+
const utils = require('../../lib/utils.cjs');
|
|
9
|
+
const sortableField = require('./sortable-field.cjs');
|
|
10
|
+
const stepTabs = require('./step-tabs.cjs');
|
|
11
|
+
|
|
12
|
+
function DropZone({ id, isDraggingFromPalette }) {
|
|
13
|
+
const { setNodeRef, isOver } = core.useDroppable({
|
|
14
|
+
id
|
|
15
|
+
});
|
|
16
|
+
if (!isDraggingFromPalette) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
ref: setNodeRef,
|
|
23
|
+
className: utils.cn(
|
|
24
|
+
"h-2 rounded-full transition-all duration-200",
|
|
25
|
+
isOver ? "h-3 bg-primary animate-pulse" : "bg-muted-foreground/20"
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function Canvas({
|
|
31
|
+
fields,
|
|
32
|
+
components,
|
|
33
|
+
onEditField,
|
|
34
|
+
onDeleteField,
|
|
35
|
+
onConfigureNested,
|
|
36
|
+
isDraggingFromPalette,
|
|
37
|
+
className,
|
|
38
|
+
steps,
|
|
39
|
+
activeStepIndex,
|
|
40
|
+
onActiveStepChange,
|
|
41
|
+
onAddStep,
|
|
42
|
+
onDeleteStep,
|
|
43
|
+
onRenameStep,
|
|
44
|
+
hideStepControls
|
|
45
|
+
}) {
|
|
46
|
+
const { setNodeRef, isOver } = core.useDroppable({
|
|
47
|
+
id: "canvas"
|
|
48
|
+
});
|
|
49
|
+
const getComponent = (type) => components.find((c) => c.type === type);
|
|
50
|
+
const visibleFields = React.useMemo(() => {
|
|
51
|
+
if (steps.length <= 1) {
|
|
52
|
+
return fields;
|
|
53
|
+
}
|
|
54
|
+
return fields.filter((f) => (f.stepGroup ?? 0) === activeStepIndex);
|
|
55
|
+
}, [fields, steps.length, activeStepIndex]);
|
|
56
|
+
const sortableItems = React.useMemo(() => visibleFields.map((f) => f.id), [visibleFields]);
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils.cn("flex flex-col h-full", className), children: [
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
stepTabs.StepTabs,
|
|
60
|
+
{
|
|
61
|
+
steps,
|
|
62
|
+
activeStepIndex,
|
|
63
|
+
onActiveStepChange,
|
|
64
|
+
onAddStep,
|
|
65
|
+
onDeleteStep,
|
|
66
|
+
onRenameStep,
|
|
67
|
+
hideStepControls
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
ref: setNodeRef,
|
|
74
|
+
"data-testid": "form-builder-canvas",
|
|
75
|
+
className: utils.cn(
|
|
76
|
+
"flex-1 p-4 rounded-lg border-2 border-dashed min-h-[400px] transition-colors",
|
|
77
|
+
isOver && isDraggingFromPalette ? "border-primary bg-primary/5" : "border-muted-foreground/20"
|
|
78
|
+
),
|
|
79
|
+
children: visibleFields.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center h-full text-muted-foreground", "data-testid": "canvas-drop-zone", children: [
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium", children: "Drop components here" }),
|
|
81
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: steps.length > 1 ? `Drag components from the palette to add to ${steps[activeStepIndex]?.title || "this step"}` : "Drag components from the palette to build your form" })
|
|
82
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
83
|
+
sortable.SortableContext,
|
|
84
|
+
{
|
|
85
|
+
items: sortableItems,
|
|
86
|
+
strategy: sortable.verticalListSortingStrategy,
|
|
87
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropZone, { id: "drop-zone-start", isDraggingFromPalette }),
|
|
89
|
+
visibleFields.map((field, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
+
sortableField.SortableField,
|
|
92
|
+
{
|
|
93
|
+
field,
|
|
94
|
+
index,
|
|
95
|
+
component: getComponent(field.type),
|
|
96
|
+
onEdit: () => onEditField(field.id),
|
|
97
|
+
onDelete: () => onDeleteField(field.id),
|
|
98
|
+
onConfigureNested: onConfigureNested ? () => onConfigureNested(field.id) : void 0
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropZone, { id: `drop-zone-${field.id}`, isDraggingFromPalette })
|
|
102
|
+
] }, field.id))
|
|
103
|
+
] })
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
exports.Canvas = Canvas;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
5
|
+
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
6
|
+
import { cn } from '../../lib/utils.mjs';
|
|
7
|
+
import { SortableField } from './sortable-field.mjs';
|
|
8
|
+
import { StepTabs } from './step-tabs.mjs';
|
|
9
|
+
|
|
10
|
+
function DropZone({ id, isDraggingFromPalette }) {
|
|
11
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
12
|
+
id
|
|
13
|
+
});
|
|
14
|
+
if (!isDraggingFromPalette) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
ref: setNodeRef,
|
|
21
|
+
className: cn(
|
|
22
|
+
"h-2 rounded-full transition-all duration-200",
|
|
23
|
+
isOver ? "h-3 bg-primary animate-pulse" : "bg-muted-foreground/20"
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function Canvas({
|
|
29
|
+
fields,
|
|
30
|
+
components,
|
|
31
|
+
onEditField,
|
|
32
|
+
onDeleteField,
|
|
33
|
+
onConfigureNested,
|
|
34
|
+
isDraggingFromPalette,
|
|
35
|
+
className,
|
|
36
|
+
steps,
|
|
37
|
+
activeStepIndex,
|
|
38
|
+
onActiveStepChange,
|
|
39
|
+
onAddStep,
|
|
40
|
+
onDeleteStep,
|
|
41
|
+
onRenameStep,
|
|
42
|
+
hideStepControls
|
|
43
|
+
}) {
|
|
44
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
45
|
+
id: "canvas"
|
|
46
|
+
});
|
|
47
|
+
const getComponent = (type) => components.find((c) => c.type === type);
|
|
48
|
+
const visibleFields = useMemo(() => {
|
|
49
|
+
if (steps.length <= 1) {
|
|
50
|
+
return fields;
|
|
51
|
+
}
|
|
52
|
+
return fields.filter((f) => (f.stepGroup ?? 0) === activeStepIndex);
|
|
53
|
+
}, [fields, steps.length, activeStepIndex]);
|
|
54
|
+
const sortableItems = useMemo(() => visibleFields.map((f) => f.id), [visibleFields]);
|
|
55
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col h-full", className), children: [
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
StepTabs,
|
|
58
|
+
{
|
|
59
|
+
steps,
|
|
60
|
+
activeStepIndex,
|
|
61
|
+
onActiveStepChange,
|
|
62
|
+
onAddStep,
|
|
63
|
+
onDeleteStep,
|
|
64
|
+
onRenameStep,
|
|
65
|
+
hideStepControls
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
ref: setNodeRef,
|
|
72
|
+
"data-testid": "form-builder-canvas",
|
|
73
|
+
className: cn(
|
|
74
|
+
"flex-1 p-4 rounded-lg border-2 border-dashed min-h-[400px] transition-colors",
|
|
75
|
+
isOver && isDraggingFromPalette ? "border-primary bg-primary/5" : "border-muted-foreground/20"
|
|
76
|
+
),
|
|
77
|
+
children: visibleFields.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full text-muted-foreground", "data-testid": "canvas-drop-zone", children: [
|
|
78
|
+
/* @__PURE__ */ jsx("p", { className: "text-lg font-medium", children: "Drop components here" }),
|
|
79
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm", children: steps.length > 1 ? `Drag components from the palette to add to ${steps[activeStepIndex]?.title || "this step"}` : "Drag components from the palette to build your form" })
|
|
80
|
+
] }) : /* @__PURE__ */ jsx(
|
|
81
|
+
SortableContext,
|
|
82
|
+
{
|
|
83
|
+
items: sortableItems,
|
|
84
|
+
strategy: verticalListSortingStrategy,
|
|
85
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
86
|
+
/* @__PURE__ */ jsx(DropZone, { id: "drop-zone-start", isDraggingFromPalette }),
|
|
87
|
+
visibleFields.map((field, index) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
SortableField,
|
|
90
|
+
{
|
|
91
|
+
field,
|
|
92
|
+
index,
|
|
93
|
+
component: getComponent(field.type),
|
|
94
|
+
onEdit: () => onEditField(field.id),
|
|
95
|
+
onDelete: () => onDeleteField(field.id),
|
|
96
|
+
onConfigureNested: onConfigureNested ? () => onConfigureNested(field.id) : void 0
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx(DropZone, { id: `drop-zone-${field.id}`, isDraggingFromPalette })
|
|
100
|
+
] }, field.id))
|
|
101
|
+
] })
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { Canvas };
|