@bluprynt/forms-builder 3.0.0 → 4.1.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/README.md +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +7 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ const [selectedId, setSelectedId] = useState<number | null>(null)
|
|
|
112
112
|
| `index` | `number` | Position index in the flat list |
|
|
113
113
|
| `parentId` | `number \| null` | Parent section ID, or `null` for root-level |
|
|
114
114
|
| `type` | `FieldType` | Field type (`'string'`, `'number'`, etc.) |
|
|
115
|
-
| `item` | `
|
|
115
|
+
| `item` | `AnyFieldContentItem` | Full field content item from the definition. This is `FieldContentItem \| StaticFieldContentItem`, so `item.label` is `string \| undefined` — narrow with `item.type === 'static'` to reach `item.text`. |
|
|
116
116
|
| `isDragging` | `boolean` | `true` when this item is being dragged |
|
|
117
117
|
| `isSelected` | `boolean` | `true` when this item's ID matches `selectedId` |
|
|
118
118
|
| `onAdd` | `(item: NewContentItem) => number` | Add a new item to this field's parent section; returns the new ID |
|
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,11 @@ const AddPlaceholder = ({ depth, parentId, component: Component, onAdd, onChange
|
|
|
19
19
|
*/
|
|
20
20
|
const isSection = (item) => item.type === "section";
|
|
21
21
|
/**
|
|
22
|
-
* Type guard that narrows a `TreeItem` to a field (`type` is not `'section'`,
|
|
22
|
+
* Type guard that narrows a `TreeItem` to a field (`type` is not `'section'`,
|
|
23
|
+
* `item` is {@link AnyFieldContentItem}).
|
|
24
|
+
*
|
|
25
|
+
* Note that this includes `static` blocks, which are fields in the tree but
|
|
26
|
+
* carry `text` instead of a required `label`.
|
|
23
27
|
*/
|
|
24
28
|
const isField = (item) => item.type !== "section" && item.type !== "add-placeholder";
|
|
25
29
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { ContentItem, FieldContentItem, FieldType, FormDefinition, SectionContentItem } from "@bluprynt/forms-core";
|
|
2
|
+
import { AnyFieldContentItem, ContentItem, FieldContentItem, FieldType, FormDefinition, SectionContentItem, StaticFieldContentItem } from "@bluprynt/forms-core";
|
|
3
3
|
|
|
4
4
|
//#region src/core/types.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A `ContentItem` without an `id` — used when adding new items (id is auto-generated).
|
|
7
|
+
*
|
|
8
|
+
* Written as an explicit union rather than `Omit<ContentItem, 'id'>` because
|
|
9
|
+
* `Omit` does not distribute over a union: it would collapse to the properties
|
|
10
|
+
* the members share, dropping `label`, `text` and `content`.
|
|
7
11
|
*/
|
|
8
|
-
type NewContentItem = Omit<FieldContentItem, 'id'> | Omit<SectionContentItem, 'id'>;
|
|
12
|
+
type NewContentItem = Omit<FieldContentItem, 'id'> | Omit<StaticFieldContentItem, 'id'> | Omit<SectionContentItem, 'id'>;
|
|
9
13
|
//#endregion
|
|
10
14
|
//#region src/add-placeholder.d.ts
|
|
11
15
|
type AddPlaceholderRenderProps = {
|
|
@@ -24,7 +28,7 @@ type FieldRenderProps = {
|
|
|
24
28
|
index: number;
|
|
25
29
|
parentId: number | null;
|
|
26
30
|
type: FieldType;
|
|
27
|
-
item:
|
|
31
|
+
item: AnyFieldContentItem;
|
|
28
32
|
isDragging: boolean;
|
|
29
33
|
isSelected: boolean;
|
|
30
34
|
onAdd: (item: NewContentItem) => number;
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/types.ts","../src/add-placeholder.tsx","../src/field.tsx","../src/section.tsx","../src/builder.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/types.ts","../src/add-placeholder.tsx","../src/field.tsx","../src/section.tsx","../src/builder.tsx"],"mappings":";;;;;;;AAgBA;;;;KAAY,cAAA,GACN,IAAA,CAAK,gBAAA,UACL,IAAA,CAAK,sBAAA,UACL,IAAA,CAAK,kBAAA;;;KCbC,yBAAA;EACR,KAAA;EACA,QAAA;EACA,KAAA,GAAQ,IAAA,EAAM,cAAA;EACd,QAAA,GAAW,EAAA,UAAY,IAAA,EAAM,WAAA;AAAA;;;KCFrB,gBAAA;EACR,GAAA,GAAM,OAAA,EAAS,OAAA;EACf,SAAA,GAAY,OAAA,EAAS,OAAA;EACrB,EAAA;EACA,KAAA;EACA,KAAA;EACA,QAAA;EACA,IAAA,EAAM,SAAA;EACN,IAAA,EAAM,mBAAA;EACN,UAAA;EACA,UAAA;EACA,KAAA,GAAQ,IAAA,EAAM,cAAA;EACd,QAAA;EACA,QAAA,GAAW,IAAA,EAAM,WAAA;AAAA;;;KCbT,kBAAA;EACR,GAAA,GAAM,OAAA,EAAS,OAAA;EACf,SAAA,GAAY,OAAA,EAAS,OAAA;EACrB,EAAA;EACA,KAAA;EACA,KAAA;EACA,QAAA;EACA,IAAA,EAAM,kBAAA;EACN,UAAA;EACA,UAAA;EACA,KAAA,GAAQ,IAAA,EAAM,cAAA;EACd,QAAA;EACA,QAAA,GAAW,IAAA,EAAM,WAAA;AAAA;;;KCThB,gBAAA;EACD,UAAA,EAAY,cAAA;EACZ,SAAA,EAAW,EAAA,CAAG,iBAAA;EACd,OAAA,EAAS,EAAA,CAAG,kBAAA;EACZ,KAAA,EAAO,EAAA,CAAG,gBAAA;EACV,cAAA,EAAgB,EAAA,CAAG,yBAAA;EACnB,UAAA;EACA,kBAAA,IAAsB,UAAA,EAAY,cAAA;AAAA;AAAA,cAGzB,WAAA,EAAa,EAAA,CAAG,gBAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { ContentItem, FieldContentItem, FieldType, FormDefinition, SectionContentItem } from "@bluprynt/forms-core";
|
|
2
|
+
import { AnyFieldContentItem, ContentItem, FieldContentItem, FieldType, FormDefinition, SectionContentItem, StaticFieldContentItem } from "@bluprynt/forms-core";
|
|
3
3
|
|
|
4
4
|
//#region src/core/types.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A `ContentItem` without an `id` — used when adding new items (id is auto-generated).
|
|
7
|
+
*
|
|
8
|
+
* Written as an explicit union rather than `Omit<ContentItem, 'id'>` because
|
|
9
|
+
* `Omit` does not distribute over a union: it would collapse to the properties
|
|
10
|
+
* the members share, dropping `label`, `text` and `content`.
|
|
7
11
|
*/
|
|
8
|
-
type NewContentItem = Omit<FieldContentItem, 'id'> | Omit<SectionContentItem, 'id'>;
|
|
12
|
+
type NewContentItem = Omit<FieldContentItem, 'id'> | Omit<StaticFieldContentItem, 'id'> | Omit<SectionContentItem, 'id'>;
|
|
9
13
|
//#endregion
|
|
10
14
|
//#region src/add-placeholder.d.ts
|
|
11
15
|
type AddPlaceholderRenderProps = {
|
|
@@ -24,7 +28,7 @@ type FieldRenderProps = {
|
|
|
24
28
|
index: number;
|
|
25
29
|
parentId: number | null;
|
|
26
30
|
type: FieldType;
|
|
27
|
-
item:
|
|
31
|
+
item: AnyFieldContentItem;
|
|
28
32
|
isDragging: boolean;
|
|
29
33
|
isSelected: boolean;
|
|
30
34
|
onAdd: (item: NewContentItem) => number;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/types.ts","../src/add-placeholder.tsx","../src/field.tsx","../src/section.tsx","../src/builder.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/types.ts","../src/add-placeholder.tsx","../src/field.tsx","../src/section.tsx","../src/builder.tsx"],"mappings":";;;;;;;AAgBA;;;;KAAY,cAAA,GACN,IAAA,CAAK,gBAAA,UACL,IAAA,CAAK,sBAAA,UACL,IAAA,CAAK,kBAAA;;;KCbC,yBAAA;EACR,KAAA;EACA,QAAA;EACA,KAAA,GAAQ,IAAA,EAAM,cAAA;EACd,QAAA,GAAW,EAAA,UAAY,IAAA,EAAM,WAAA;AAAA;;;KCFrB,gBAAA;EACR,GAAA,GAAM,OAAA,EAAS,OAAA;EACf,SAAA,GAAY,OAAA,EAAS,OAAA;EACrB,EAAA;EACA,KAAA;EACA,KAAA;EACA,QAAA;EACA,IAAA,EAAM,SAAA;EACN,IAAA,EAAM,mBAAA;EACN,UAAA;EACA,UAAA;EACA,KAAA,GAAQ,IAAA,EAAM,cAAA;EACd,QAAA;EACA,QAAA,GAAW,IAAA,EAAM,WAAA;AAAA;;;KCbT,kBAAA;EACR,GAAA,GAAM,OAAA,EAAS,OAAA;EACf,SAAA,GAAY,OAAA,EAAS,OAAA;EACrB,EAAA;EACA,KAAA;EACA,KAAA;EACA,QAAA;EACA,IAAA,EAAM,kBAAA;EACN,UAAA;EACA,UAAA;EACA,KAAA,GAAQ,IAAA,EAAM,cAAA;EACd,QAAA;EACA,QAAA,GAAW,IAAA,EAAM,WAAA;AAAA;;;KCThB,gBAAA;EACD,UAAA,EAAY,cAAA;EACZ,SAAA,EAAW,EAAA,CAAG,iBAAA;EACd,OAAA,EAAS,EAAA,CAAG,kBAAA;EACZ,KAAA,EAAO,EAAA,CAAG,gBAAA;EACV,cAAA,EAAgB,EAAA,CAAG,yBAAA;EACnB,UAAA;EACA,kBAAA,IAAsB,UAAA,EAAY,cAAA;AAAA;AAAA,cAGzB,WAAA,EAAa,EAAA,CAAG,gBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,11 @@ const AddPlaceholder = ({ depth, parentId, component: Component, onAdd, onChange
|
|
|
18
18
|
*/
|
|
19
19
|
const isSection = (item) => item.type === "section";
|
|
20
20
|
/**
|
|
21
|
-
* Type guard that narrows a `TreeItem` to a field (`type` is not `'section'`,
|
|
21
|
+
* Type guard that narrows a `TreeItem` to a field (`type` is not `'section'`,
|
|
22
|
+
* `item` is {@link AnyFieldContentItem}).
|
|
23
|
+
*
|
|
24
|
+
* Note that this includes `static` blocks, which are fields in the tree but
|
|
25
|
+
* carry `text` instead of a required `label`.
|
|
22
26
|
*/
|
|
23
27
|
const isField = (item) => item.type !== "section" && item.type !== "add-placeholder";
|
|
24
28
|
/**
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/add-placeholder.tsx","../src/core/types.ts","../src/core/constants.ts","../src/field.tsx","../src/section.tsx","../src/core/projection.ts","../src/core/tree.ts","../src/use-form-builder.ts","../src/builder.tsx"],"sourcesContent":["import type { FC } from 'react'\n\nimport type { ContentItem } from '@bluprynt/forms-core'\n\nimport type { NewContentItem } from './core/types'\n\nexport type AddPlaceholderRenderProps = {\n depth: number\n parentId: number | null\n onAdd: (item: NewContentItem) => number\n onChange: (id: number, item: ContentItem) => void\n}\n\ntype AddPlaceholderProps = {\n depth: number\n parentId: number | null\n component: FC<AddPlaceholderRenderProps>\n onAdd: (item: NewContentItem) => number\n onChange: (id: number, item: ContentItem) => void\n}\n\nexport const AddPlaceholder: FC<AddPlaceholderProps> = ({ depth, parentId, component: Component, onAdd, onChange }) => (\n <Component depth={depth} parentId={parentId} onAdd={onAdd} onChange={onChange} />\n)\n","import type { ContentItem, ContentItemType, FieldContentItem, SectionContentItem } from '@bluprynt/forms-core'\n\n/**\n * A `ContentItem` without an `id` — used when adding new items (id is auto-generated).\n */\nexport type NewContentItem = Omit<FieldContentItem, 'id'> | Omit<SectionContentItem, 'id'>\n\n/**\n * Flat representation of a content item within the sortable tree.\n * Carries depth, parent reference, and the original `ContentItem` for rendering and reconstruction.\n */\nexport type TreeItem = {\n id: number\n type: ContentItemType | 'add-placeholder'\n parentId: number | null\n depth: number\n index: number\n collapsed?: boolean\n item: ContentItem | undefined\n onChange?: (item: ContentItem) => void\n}\n\n/**\n * Type guard that narrows a `TreeItem` to a section (`type` is `'section'`, `item` is `SectionContentItem`).\n */\nexport const isSection = (item: TreeItem): item is TreeItem & { type: 'section'; item: SectionContentItem } =>\n item.type === 'section'\n\n/**\n * Type guard that narrows a `TreeItem` to a field (`type` is not `'section'`, `item` is `FieldContentItem`).\n */\nexport const isField = (\n item: TreeItem,\n): item is TreeItem & { type: Exclude<ContentItemType, 'section'>; item: FieldContentItem } =>\n item.type !== 'section' && item.type !== 'add-placeholder'\n\n/**\n * Type guard that narrows a `TreeItem` to an \"add\" placeholder.\n */\nexport const isAddPlaceholder = (item: TreeItem): item is TreeItem & { type: 'add-placeholder'; item: undefined } =>\n item.type === 'add-placeholder'\n","export const INDENTATION = 40\nexport const MAX_DEPTH = 3\n\nexport const SORTABLE_CONFIG = {\n alignment: {\n x: 'start',\n y: 'center',\n },\n transition: {\n idle: true,\n },\n} as const\n","import type { FC } from 'react'\n\nimport type { ContentItem, FieldContentItem, FieldType } from '@bluprynt/forms-core'\nimport { useSortable } from '@dnd-kit/react/sortable'\n\nimport { SORTABLE_CONFIG } from './core/constants'\nimport type { NewContentItem } from './core/types'\n\nexport type FieldRenderProps = {\n ref: (element: Element | null) => void\n handleRef: (element: Element | null) => void\n id: number\n depth: number\n index: number\n parentId: number | null\n type: FieldType\n item: FieldContentItem\n isDragging: boolean\n isSelected: boolean\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\ntype FieldProps = {\n id: number\n depth: number\n index: number\n parentId: number | null\n type: FieldType\n item: FieldContentItem\n isSelected: boolean\n component: FC<FieldRenderProps>\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\nexport const Field: FC<FieldProps> = ({\n id,\n depth,\n index,\n parentId,\n type,\n item,\n isSelected,\n component: Component,\n onAdd,\n onRemove,\n onChange,\n}) => {\n const { ref, handleRef, isDragSource } = useSortable({\n ...SORTABLE_CONFIG,\n id,\n index,\n data: { depth, parentId },\n })\n\n return (\n <Component\n ref={ref}\n handleRef={handleRef}\n id={id}\n depth={depth}\n index={index}\n parentId={parentId}\n type={type}\n item={item}\n isDragging={isDragSource}\n isSelected={isSelected}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n )\n}\n","import { type FC } from 'react'\n\nimport type { ContentItem, SectionContentItem } from '@bluprynt/forms-core'\nimport { useSortable } from '@dnd-kit/react/sortable'\n\nimport { SORTABLE_CONFIG } from './core/constants'\nimport type { NewContentItem } from './core/types'\n\nexport type SectionRenderProps = {\n ref: (element: Element | null) => void\n handleRef: (element: Element | null) => void\n id: number\n depth: number\n index: number\n parentId: number | null\n item: SectionContentItem\n isDragging: boolean\n isSelected: boolean\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\ntype SectionProps = {\n id: number\n depth: number\n index: number\n parentId: number | null\n item: SectionContentItem\n isSelected: boolean\n component: FC<SectionRenderProps>\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\nexport const Section: FC<SectionProps> = ({\n id,\n depth,\n index,\n parentId,\n item,\n isSelected,\n component: Component,\n onAdd,\n onRemove,\n onChange,\n}) => {\n const { ref, handleRef, isDragSource } = useSortable({\n ...SORTABLE_CONFIG,\n id,\n index,\n data: { depth, parentId },\n })\n\n return (\n <Component\n ref={ref}\n handleRef={handleRef}\n id={id}\n depth={depth}\n index={index}\n parentId={parentId}\n item={item}\n isDragging={isDragSource}\n isSelected={isSelected}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n )\n}\n","import type { TreeItem } from './types'\n\n/**\n * Converts a horizontal pixel offset into a depth level based on indentation width.\n */\nexport const getDragDepth = (offset: number, indentationWidth: number): number => Math.round(offset / indentationWidth)\n\n/**\n * Returns the maximum allowed nesting depth when dragging above a target item.\n * Only sections can accept nested children.\n */\nconst getMaxDepth = (targetItem: TreeItem, previousItem: TreeItem | undefined): number => {\n if (!previousItem) return 0\n if (previousItem.type !== 'section') {\n return previousItem.depth\n }\n return Math.min(targetItem.depth + 1, previousItem.depth + 1)\n}\n\n/**\n * Returns the minimum depth based on the next sibling item.\n * If there is no next item, the minimum depth is 0 (root level).\n */\nconst getMinDepth = (nextItem: TreeItem | undefined): number => (nextItem ? nextItem.depth : 0)\n\n/**\n * Calculates the projected depth and parent for a dragged item relative to a target position.\n * Clamps depth between min/max bounds and enforces `maxAllowedDepth`.\n */\nexport const getProjection = (\n items: TreeItem[],\n targetId: number,\n projectedDepth: number,\n maxAllowedDepth: number,\n): { depth: number; maxDepth: number; minDepth: number; parentId: number | null } => {\n const targetItemIndex = items.findIndex(({ id }) => id === targetId)\n const previousItem = items[targetItemIndex - 1]\n const targetItem = items[targetItemIndex]\n const nextItem = items[targetItemIndex + 1]\n if (!targetItem) return { depth: 0, maxDepth: 0, minDepth: 0, parentId: null }\n\n const maxDepth = getMaxDepth(targetItem, previousItem)\n const minDepth = getMinDepth(nextItem)\n let depth = projectedDepth\n\n if (depth >= maxDepth) {\n depth = maxDepth\n } else if (depth < minDepth) {\n depth = minDepth\n }\n\n if (depth > maxAllowedDepth) {\n depth = maxAllowedDepth\n }\n\n const getParentId = (): number | null => {\n if (depth === 0 || !previousItem) {\n return null\n }\n\n if (depth === previousItem.depth) {\n return previousItem.parentId\n }\n\n if (depth > previousItem.depth) {\n if (previousItem.type !== 'section') {\n return previousItem.parentId\n }\n return previousItem.id\n }\n\n const newParent = items\n .slice(0, targetItemIndex)\n .reverse()\n .find((item) => item.depth === depth)?.parentId\n\n return newParent ?? null\n }\n\n return { depth, maxDepth, minDepth, parentId: getParentId() }\n}\n","import type { ContentItem } from '@bluprynt/forms-core'\n\nimport type { TreeItem } from './types'\n\nlet placeholderIdCounter = -1000\n\n/**\n * Resets the placeholder id counter. Call before each full flatten to ensure stable ids per flatten pass.\n */\nconst resetPlaceholderIds = () => {\n placeholderIdCounter = -1000\n}\n\nconst nextPlaceholderId = () => --placeholderIdCounter\n\n/**\n * Flattens a nested content tree into a flat list of items with depth and parent info.\n * Each item preserves its position metadata for rendering in a sortable tree.\n * Appends an \"add-placeholder\" at the end of each section and at the root level.\n */\nexport const flattenTree = (items: ContentItem[], parentId: number | null = null, depth = 0): TreeItem[] => {\n if (parentId === null) resetPlaceholderIds()\n\n const result = items.reduce<TreeItem[]>((result, current, index) => {\n const isSection = current.type === 'section'\n\n result.push({\n id: current.id,\n type: current.type,\n parentId,\n depth,\n index,\n item: current,\n })\n\n if (isSection) {\n const children = (current as { content: ContentItem[] }).content\n result.push(...flattenTree(children, current.id, depth + 1))\n }\n\n return result\n }, [])\n\n result.push({\n id: nextPlaceholderId(),\n type: 'add-placeholder',\n parentId,\n depth,\n index: items.length,\n item: undefined,\n })\n\n return result\n}\n\n/**\n * Collects all transitive descendant ids for a given parent from a flat item list.\n */\nexport const getDescendants = (items: TreeItem[], parentId: number): Set<number> => {\n const directChildren = items.filter((item) => item.parentId === parentId)\n\n return directChildren.reduce((result, child) => {\n result.add(child.id)\n for (const descendant of getDescendants(items, child.id)) {\n result.add(descendant)\n }\n return result\n }, new Set<number>())\n}\n","import { type ComponentProps, useCallback, useEffect, useRef, useState } from 'react'\n\nimport {\n type ContentItem,\n type FieldContentItem,\n type FormDefinition,\n FormDefinitionEditor,\n type SectionContentItem,\n} from '@bluprynt/forms-core'\nimport { move } from '@dnd-kit/helpers'\nimport { DragDropProvider } from '@dnd-kit/react'\n\nimport { INDENTATION, MAX_DEPTH } from './core/constants'\nimport { getDragDepth, getProjection } from './core/projection'\nimport { flattenTree, getDescendants } from './core/tree'\nimport type { NewContentItem, TreeItem } from './core/types'\n\n/**\n * Manages the form builder state: flattened tree items, drag-and-drop reordering,\n * item editing, and removal. Uses {@link FormDefinitionEditor} for all definition mutations\n * and notifies the consumer of structural changes via {@link onDefinitionChange}.\n *\n * @param definition - The current form definition to build upon.\n * @param onDefinitionChange - Optional callback invoked with the updated `FormDefinition`\n * whenever the tree structure, item content, or item order changes.\n * @returns Flattened items and handlers for item/drag operations.\n */\nexport const useFormBuilder = (\n definition: FormDefinition,\n onDefinitionChange?: (definition: FormDefinition) => void,\n): {\n items: TreeItem[]\n handleItemAdd: (sectionId: number | null, item: NewContentItem) => number\n handleItemChange: (id: number, newItem: ContentItem) => void\n handleItemRemove: (itemId: number) => void\n handleDragStart: ComponentProps<typeof DragDropProvider>['onDragStart']\n handleDragOver: ComponentProps<typeof DragDropProvider>['onDragOver']\n handleDragMove: ComponentProps<typeof DragDropProvider>['onDragMove']\n handleDragEnd: ComponentProps<typeof DragDropProvider>['onDragEnd']\n} => {\n const [items, setItems] = useState<TreeItem[]>(() => flattenTree(definition.content))\n const initialDepth = useRef(0)\n const sourceChildren = useRef<TreeItem[]>([])\n const dragSourceId = useRef<number | null>(null)\n\n const definitionRef = useRef(definition)\n definitionRef.current = definition\n\n const onDefinitionChangeRef = useRef(onDefinitionChange)\n onDefinitionChangeRef.current = onDefinitionChange\n\n // Re-sync items when definition changes externally (e.g. from field editor sheet)\n useEffect(() => {\n setItems(flattenTree(definition.content))\n }, [definition])\n\n const applyEditor = useCallback((editor: FormDefinitionEditor) => {\n const updated = editor.toJSON()\n setItems(flattenTree(updated.content))\n onDefinitionChangeRef.current?.(updated)\n }, [])\n\n const handleItemAdd = useCallback(\n (sectionId: number | null, item: NewContentItem): number => {\n const editor = new FormDefinitionEditor(definitionRef.current)\n const parentId = sectionId ?? undefined\n const id = editor.nextId()\n\n if (item.type === 'section') editor.addSection({ ...item, id }, parentId)\n else editor.addField({ ...item, id } as FieldContentItem, parentId)\n\n applyEditor(editor)\n return id\n },\n [applyEditor],\n )\n\n const handleItemChange = useCallback(\n (id: number, newItem: ContentItem) => {\n const editor = new FormDefinitionEditor(definitionRef.current)\n\n if (newItem.type === 'section') {\n const { id: _, type: __, content: ___, ...updates } = newItem as SectionContentItem\n editor.updateSection(id, updates)\n } else {\n const { id: _, type: __, ...updates } = newItem as FieldContentItem\n editor.updateField(id, updates)\n }\n\n applyEditor(editor)\n },\n [applyEditor],\n )\n\n const handleItemRemove = useCallback(\n (itemId: number) => {\n const editor = new FormDefinitionEditor(definitionRef.current)\n editor.removeItem(itemId)\n applyEditor(editor)\n },\n [applyEditor],\n )\n\n const handleDragStart: ComponentProps<typeof DragDropProvider>['onDragStart'] = (event) => {\n const { source } = event.operation\n if (!source) return\n\n const item = items.find(({ id }) => id === source.id)\n if (!item) return\n\n initialDepth.current = item.depth\n dragSourceId.current = source.id as number\n\n setItems((prev) => {\n sourceChildren.current = []\n const descendants = getDescendants(prev, source.id as number)\n\n return prev.filter((i) => {\n if (descendants.has(i.id)) {\n sourceChildren.current = [...sourceChildren.current, i]\n return false\n }\n return true\n })\n })\n }\n\n const handleDragOver: ComponentProps<typeof DragDropProvider>['onDragOver'] = (event, manager) => {\n const { source, target } = event.operation\n event.preventDefault()\n\n if (source && target && source.id !== target.id) {\n setItems((prev) => {\n const offsetLeft = manager.dragOperation.transform.x\n const dragDepth = getDragDepth(offsetLeft, INDENTATION)\n const projectedDepth = initialDepth.current + dragDepth\n\n const { depth, parentId } = getProjection(prev, target.id as number, projectedDepth, MAX_DEPTH)\n\n const sorted = move(prev, event)\n return sorted.map((item) => (item.id === source.id ? { ...item, depth, parentId } : item))\n })\n }\n }\n\n const handleDragMove: ComponentProps<typeof DragDropProvider>['onDragMove'] = (event, manager) => {\n if (event.defaultPrevented) return\n\n const { source, target } = event.operation\n if (!source || !target) return\n\n const offsetLeft = manager.dragOperation.transform.x\n const dragDepth = getDragDepth(offsetLeft, INDENTATION)\n const projectedDepth = initialDepth.current + dragDepth\n\n const { depth, parentId } = getProjection(items, source.id as number, projectedDepth, MAX_DEPTH)\n\n if (\n (source.data as { depth: number })?.depth !== depth ||\n (source.data as { parentId: number | null })?.parentId !== parentId\n ) {\n setItems((prev) => prev.map((item) => (item.id === source.id ? { ...item, depth, parentId } : item)))\n }\n }\n\n const handleDragEnd: ComponentProps<typeof DragDropProvider>['onDragEnd'] = (event) => {\n if (event.canceled) {\n setItems(flattenTree(definitionRef.current.content))\n dragSourceId.current = null\n sourceChildren.current = []\n return\n }\n\n const draggedId = dragSourceId.current\n if (draggedId === null) return\n\n const draggedItem = items.find((i) => i.id === draggedId)\n if (!draggedItem) return\n\n // Compute sibling index in the new parent\n const targetParentId = draggedItem.parentId\n const draggedFlatIndex = items.findIndex((i) => i.id === draggedId)\n let siblingIndex = 0\n for (let i = 0; i < draggedFlatIndex; i++) {\n const current = items[i]\n if (current && current.parentId === targetParentId && current.type !== 'add-placeholder') {\n siblingIndex++\n }\n }\n\n const editor = new FormDefinitionEditor(definitionRef.current)\n editor.moveItem(draggedId, targetParentId ?? undefined, siblingIndex)\n applyEditor(editor)\n\n dragSourceId.current = null\n sourceChildren.current = []\n }\n\n return {\n items,\n handleItemAdd,\n handleItemChange,\n handleItemRemove,\n handleDragStart,\n handleDragOver,\n handleDragMove,\n handleDragEnd,\n } as const\n}\n","import type { FC, PropsWithChildren } from 'react'\n\nimport type { ContentItem, FormDefinition } from '@bluprynt/forms-core'\nimport { DragDropProvider } from '@dnd-kit/react'\n\nimport { AddPlaceholder, type AddPlaceholderRenderProps } from './add-placeholder'\nimport { isAddPlaceholder, isField, isSection, NewContentItem } from './core/types'\nimport { Field, type FieldRenderProps } from './field'\nimport { Section, type SectionRenderProps } from './section'\nimport { useFormBuilder } from './use-form-builder'\n\ntype FormBuilderProps = {\n definition: FormDefinition\n container: FC<PropsWithChildren>\n section: FC<SectionRenderProps>\n field: FC<FieldRenderProps>\n addPlaceholder: FC<AddPlaceholderRenderProps>\n selectedId?: number | null\n onDefinitionChange?: (definition: FormDefinition) => void\n}\n\nexport const FormBuilder: FC<FormBuilderProps> = ({\n definition,\n container: Container,\n section: SectionComponent,\n field: FieldComponent,\n addPlaceholder: AddPlaceholderComponent,\n selectedId,\n onDefinitionChange,\n}) => {\n const {\n items,\n handleItemAdd,\n handleItemChange,\n handleItemRemove,\n handleDragStart,\n handleDragOver,\n handleDragMove,\n handleDragEnd,\n } = useFormBuilder(definition, onDefinitionChange)\n\n return (\n <DragDropProvider\n onDragStart={handleDragStart}\n onDragOver={handleDragOver}\n onDragMove={handleDragMove}\n onDragEnd={handleDragEnd}>\n <Container>\n {items.map((item, index) => {\n const onAdd = (value: NewContentItem) =>\n handleItemAdd(item.type === 'section' ? item.id : item.parentId, value)\n const onRemove = () => handleItemRemove(item.id)\n const onChange = (value: ContentItem) => handleItemChange(value.id, value)\n\n return isSection(item) ? (\n <Section\n key={item.id}\n id={item.id}\n depth={item.depth}\n index={index}\n parentId={item.parentId}\n item={item.item}\n isSelected={selectedId === item.id}\n component={SectionComponent}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n ) : isField(item) ? (\n <Field\n key={item.id}\n id={item.id}\n depth={item.depth}\n index={index}\n parentId={item.parentId}\n type={item.type}\n item={item.item}\n isSelected={selectedId === item.id}\n component={FieldComponent}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n ) : isAddPlaceholder(item) ? (\n <AddPlaceholder\n key={item.id}\n depth={item.depth}\n parentId={item.parentId}\n component={AddPlaceholderComponent}\n onAdd={onAdd}\n onChange={handleItemChange}\n />\n ) : null\n })}\n </Container>\n </DragDropProvider>\n )\n}\n"],"mappings":";;;;;;;AAqBA,MAAa,kBAA2C,EAAE,OAAO,UAAU,WAAW,WAAW,OAAO,eACpG,oBAAC,WAAD;CAAkB;CAAiB;CAAiB;CAAiB;CAAY,CAAA;;;;;;ACGrF,MAAa,aAAa,SACtB,KAAK,SAAS;;;;AAKlB,MAAa,WACT,SAEA,KAAK,SAAS,aAAa,KAAK,SAAS;;;;AAK7C,MAAa,oBAAoB,SAC7B,KAAK,SAAS;;;ACrClB,MAAa,kBAAkB;CAC3B,WAAW;EACP,GAAG;EACH,GAAG;EACN;CACD,YAAY,EACR,MAAM,MACT;CACJ;;;AC2BD,MAAa,SAAyB,EAClC,IACA,OACA,OACA,UACA,MACA,MACA,YACA,WAAW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kBACA,iBACA,gBACA,gBACA,kBACA,eAAe,YAAY,mBAAmB;AAElD,QACI,oBAAC,kBAAD;EACI,aAAa;EACb,YAAY;EACZ,YAAY;EACZ,WAAW;YACX,oBAAC,WAAD,EAAA,UACK,MAAM,KAAK,MAAM,UAAU;GACxB,MAAM,SAAS,UACX,cAAc,KAAK,SAAS,YAAY,KAAK,KAAK,KAAK,UAAU,MAAM;GAC3E,MAAM,iBAAiB,iBAAiB,KAAK,GAAG;GAChD,MAAM,YAAY,UAAuB,iBAAiB,MAAM,IAAI,MAAM;AAE1E,UAAO,UAAU,KAAK,GAClB,oBAAC,SAAD;IAEI,IAAI,KAAK;IACT,OAAO,KAAK;IACL;IACP,UAAU,KAAK;IACf,MAAM,KAAK;IACX,YAAY,eAAe,KAAK;IAChC,WAAW;IACJ;IACG;IACA;IACZ,EAXO,KAAK,GAWZ,GACF,QAAQ,KAAK,GACb,oBAAC,OAAD;IAEI,IAAI,KAAK;IACT,OAAO,KAAK;IACL;IACP,UAAU,KAAK;IACf,MAAM,KAAK;IACX,MAAM,KAAK;IACX,YAAY,eAAe,KAAK;IAChC,WAAW;IACJ;IACG;IACA;IACZ,EAZO,KAAK,GAYZ,GACF,iBAAiB,KAAK,GACtB,oBAAC,gBAAD;IAEI,OAAO,KAAK;IACZ,UAAU,KAAK;IACf,WAAW;IACJ;IACP,UAAU;IACZ,EANO,KAAK,GAMZ,GACF;IACN,EACM,CAAA;EACG,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/add-placeholder.tsx","../src/core/types.ts","../src/core/constants.ts","../src/field.tsx","../src/section.tsx","../src/core/projection.ts","../src/core/tree.ts","../src/use-form-builder.ts","../src/builder.tsx"],"sourcesContent":["import type { FC } from 'react'\n\nimport type { ContentItem } from '@bluprynt/forms-core'\n\nimport type { NewContentItem } from './core/types'\n\nexport type AddPlaceholderRenderProps = {\n depth: number\n parentId: number | null\n onAdd: (item: NewContentItem) => number\n onChange: (id: number, item: ContentItem) => void\n}\n\ntype AddPlaceholderProps = {\n depth: number\n parentId: number | null\n component: FC<AddPlaceholderRenderProps>\n onAdd: (item: NewContentItem) => number\n onChange: (id: number, item: ContentItem) => void\n}\n\nexport const AddPlaceholder: FC<AddPlaceholderProps> = ({ depth, parentId, component: Component, onAdd, onChange }) => (\n <Component depth={depth} parentId={parentId} onAdd={onAdd} onChange={onChange} />\n)\n","import type {\n AnyFieldContentItem,\n ContentItem,\n ContentItemType,\n FieldContentItem,\n SectionContentItem,\n StaticFieldContentItem,\n} from '@bluprynt/forms-core'\n\n/**\n * A `ContentItem` without an `id` — used when adding new items (id is auto-generated).\n *\n * Written as an explicit union rather than `Omit<ContentItem, 'id'>` because\n * `Omit` does not distribute over a union: it would collapse to the properties\n * the members share, dropping `label`, `text` and `content`.\n */\nexport type NewContentItem =\n | Omit<FieldContentItem, 'id'>\n | Omit<StaticFieldContentItem, 'id'>\n | Omit<SectionContentItem, 'id'>\n\n/**\n * Flat representation of a content item within the sortable tree.\n * Carries depth, parent reference, and the original `ContentItem` for rendering and reconstruction.\n */\nexport type TreeItem = {\n id: number\n type: ContentItemType | 'add-placeholder'\n parentId: number | null\n depth: number\n index: number\n collapsed?: boolean\n item: ContentItem | undefined\n onChange?: (item: ContentItem) => void\n}\n\n/**\n * Type guard that narrows a `TreeItem` to a section (`type` is `'section'`, `item` is `SectionContentItem`).\n */\nexport const isSection = (item: TreeItem): item is TreeItem & { type: 'section'; item: SectionContentItem } =>\n item.type === 'section'\n\n/**\n * Type guard that narrows a `TreeItem` to a field (`type` is not `'section'`,\n * `item` is {@link AnyFieldContentItem}).\n *\n * Note that this includes `static` blocks, which are fields in the tree but\n * carry `text` instead of a required `label`.\n */\nexport const isField = (\n item: TreeItem,\n): item is TreeItem & { type: Exclude<ContentItemType, 'section'>; item: AnyFieldContentItem } =>\n item.type !== 'section' && item.type !== 'add-placeholder'\n\n/**\n * Type guard that narrows a `TreeItem` to an \"add\" placeholder.\n */\nexport const isAddPlaceholder = (item: TreeItem): item is TreeItem & { type: 'add-placeholder'; item: undefined } =>\n item.type === 'add-placeholder'\n","export const INDENTATION = 40\nexport const MAX_DEPTH = 3\n\nexport const SORTABLE_CONFIG = {\n alignment: {\n x: 'start',\n y: 'center',\n },\n transition: {\n idle: true,\n },\n} as const\n","import type { FC } from 'react'\n\nimport type { AnyFieldContentItem, ContentItem, FieldType } from '@bluprynt/forms-core'\nimport { useSortable } from '@dnd-kit/react/sortable'\n\nimport { SORTABLE_CONFIG } from './core/constants'\nimport type { NewContentItem } from './core/types'\n\nexport type FieldRenderProps = {\n ref: (element: Element | null) => void\n handleRef: (element: Element | null) => void\n id: number\n depth: number\n index: number\n parentId: number | null\n type: FieldType\n item: AnyFieldContentItem\n isDragging: boolean\n isSelected: boolean\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\ntype FieldProps = {\n id: number\n depth: number\n index: number\n parentId: number | null\n type: FieldType\n item: AnyFieldContentItem\n isSelected: boolean\n component: FC<FieldRenderProps>\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\nexport const Field: FC<FieldProps> = ({\n id,\n depth,\n index,\n parentId,\n type,\n item,\n isSelected,\n component: Component,\n onAdd,\n onRemove,\n onChange,\n}) => {\n const { ref, handleRef, isDragSource } = useSortable({\n ...SORTABLE_CONFIG,\n id,\n index,\n data: { depth, parentId },\n })\n\n return (\n <Component\n ref={ref}\n handleRef={handleRef}\n id={id}\n depth={depth}\n index={index}\n parentId={parentId}\n type={type}\n item={item}\n isDragging={isDragSource}\n isSelected={isSelected}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n )\n}\n","import { type FC } from 'react'\n\nimport type { ContentItem, SectionContentItem } from '@bluprynt/forms-core'\nimport { useSortable } from '@dnd-kit/react/sortable'\n\nimport { SORTABLE_CONFIG } from './core/constants'\nimport type { NewContentItem } from './core/types'\n\nexport type SectionRenderProps = {\n ref: (element: Element | null) => void\n handleRef: (element: Element | null) => void\n id: number\n depth: number\n index: number\n parentId: number | null\n item: SectionContentItem\n isDragging: boolean\n isSelected: boolean\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\ntype SectionProps = {\n id: number\n depth: number\n index: number\n parentId: number | null\n item: SectionContentItem\n isSelected: boolean\n component: FC<SectionRenderProps>\n onAdd: (item: NewContentItem) => number\n onRemove: () => void\n onChange: (item: ContentItem) => void\n}\n\nexport const Section: FC<SectionProps> = ({\n id,\n depth,\n index,\n parentId,\n item,\n isSelected,\n component: Component,\n onAdd,\n onRemove,\n onChange,\n}) => {\n const { ref, handleRef, isDragSource } = useSortable({\n ...SORTABLE_CONFIG,\n id,\n index,\n data: { depth, parentId },\n })\n\n return (\n <Component\n ref={ref}\n handleRef={handleRef}\n id={id}\n depth={depth}\n index={index}\n parentId={parentId}\n item={item}\n isDragging={isDragSource}\n isSelected={isSelected}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n )\n}\n","import type { TreeItem } from './types'\n\n/**\n * Converts a horizontal pixel offset into a depth level based on indentation width.\n */\nexport const getDragDepth = (offset: number, indentationWidth: number): number => Math.round(offset / indentationWidth)\n\n/**\n * Returns the maximum allowed nesting depth when dragging above a target item.\n * Only sections can accept nested children.\n */\nconst getMaxDepth = (targetItem: TreeItem, previousItem: TreeItem | undefined): number => {\n if (!previousItem) return 0\n if (previousItem.type !== 'section') {\n return previousItem.depth\n }\n return Math.min(targetItem.depth + 1, previousItem.depth + 1)\n}\n\n/**\n * Returns the minimum depth based on the next sibling item.\n * If there is no next item, the minimum depth is 0 (root level).\n */\nconst getMinDepth = (nextItem: TreeItem | undefined): number => (nextItem ? nextItem.depth : 0)\n\n/**\n * Calculates the projected depth and parent for a dragged item relative to a target position.\n * Clamps depth between min/max bounds and enforces `maxAllowedDepth`.\n */\nexport const getProjection = (\n items: TreeItem[],\n targetId: number,\n projectedDepth: number,\n maxAllowedDepth: number,\n): { depth: number; maxDepth: number; minDepth: number; parentId: number | null } => {\n const targetItemIndex = items.findIndex(({ id }) => id === targetId)\n const previousItem = items[targetItemIndex - 1]\n const targetItem = items[targetItemIndex]\n const nextItem = items[targetItemIndex + 1]\n if (!targetItem) return { depth: 0, maxDepth: 0, minDepth: 0, parentId: null }\n\n const maxDepth = getMaxDepth(targetItem, previousItem)\n const minDepth = getMinDepth(nextItem)\n let depth = projectedDepth\n\n if (depth >= maxDepth) {\n depth = maxDepth\n } else if (depth < minDepth) {\n depth = minDepth\n }\n\n if (depth > maxAllowedDepth) {\n depth = maxAllowedDepth\n }\n\n const getParentId = (): number | null => {\n if (depth === 0 || !previousItem) {\n return null\n }\n\n if (depth === previousItem.depth) {\n return previousItem.parentId\n }\n\n if (depth > previousItem.depth) {\n if (previousItem.type !== 'section') {\n return previousItem.parentId\n }\n return previousItem.id\n }\n\n const newParent = items\n .slice(0, targetItemIndex)\n .reverse()\n .find((item) => item.depth === depth)?.parentId\n\n return newParent ?? null\n }\n\n return { depth, maxDepth, minDepth, parentId: getParentId() }\n}\n","import type { ContentItem } from '@bluprynt/forms-core'\n\nimport type { TreeItem } from './types'\n\nlet placeholderIdCounter = -1000\n\n/**\n * Resets the placeholder id counter. Call before each full flatten to ensure stable ids per flatten pass.\n */\nconst resetPlaceholderIds = () => {\n placeholderIdCounter = -1000\n}\n\nconst nextPlaceholderId = () => --placeholderIdCounter\n\n/**\n * Flattens a nested content tree into a flat list of items with depth and parent info.\n * Each item preserves its position metadata for rendering in a sortable tree.\n * Appends an \"add-placeholder\" at the end of each section and at the root level.\n */\nexport const flattenTree = (items: ContentItem[], parentId: number | null = null, depth = 0): TreeItem[] => {\n if (parentId === null) resetPlaceholderIds()\n\n const result = items.reduce<TreeItem[]>((result, current, index) => {\n const isSection = current.type === 'section'\n\n result.push({\n id: current.id,\n type: current.type,\n parentId,\n depth,\n index,\n item: current,\n })\n\n if (isSection) {\n const children = (current as { content: ContentItem[] }).content\n result.push(...flattenTree(children, current.id, depth + 1))\n }\n\n return result\n }, [])\n\n result.push({\n id: nextPlaceholderId(),\n type: 'add-placeholder',\n parentId,\n depth,\n index: items.length,\n item: undefined,\n })\n\n return result\n}\n\n/**\n * Collects all transitive descendant ids for a given parent from a flat item list.\n */\nexport const getDescendants = (items: TreeItem[], parentId: number): Set<number> => {\n const directChildren = items.filter((item) => item.parentId === parentId)\n\n return directChildren.reduce((result, child) => {\n result.add(child.id)\n for (const descendant of getDescendants(items, child.id)) {\n result.add(descendant)\n }\n return result\n }, new Set<number>())\n}\n","import { type ComponentProps, useCallback, useEffect, useRef, useState } from 'react'\n\nimport {\n type ContentItem,\n type FieldContentItem,\n type FormDefinition,\n FormDefinitionEditor,\n type SectionContentItem,\n} from '@bluprynt/forms-core'\nimport { move } from '@dnd-kit/helpers'\nimport { DragDropProvider } from '@dnd-kit/react'\n\nimport { INDENTATION, MAX_DEPTH } from './core/constants'\nimport { getDragDepth, getProjection } from './core/projection'\nimport { flattenTree, getDescendants } from './core/tree'\nimport type { NewContentItem, TreeItem } from './core/types'\n\n/**\n * Manages the form builder state: flattened tree items, drag-and-drop reordering,\n * item editing, and removal. Uses {@link FormDefinitionEditor} for all definition mutations\n * and notifies the consumer of structural changes via {@link onDefinitionChange}.\n *\n * @param definition - The current form definition to build upon.\n * @param onDefinitionChange - Optional callback invoked with the updated `FormDefinition`\n * whenever the tree structure, item content, or item order changes.\n * @returns Flattened items and handlers for item/drag operations.\n */\nexport const useFormBuilder = (\n definition: FormDefinition,\n onDefinitionChange?: (definition: FormDefinition) => void,\n): {\n items: TreeItem[]\n handleItemAdd: (sectionId: number | null, item: NewContentItem) => number\n handleItemChange: (id: number, newItem: ContentItem) => void\n handleItemRemove: (itemId: number) => void\n handleDragStart: ComponentProps<typeof DragDropProvider>['onDragStart']\n handleDragOver: ComponentProps<typeof DragDropProvider>['onDragOver']\n handleDragMove: ComponentProps<typeof DragDropProvider>['onDragMove']\n handleDragEnd: ComponentProps<typeof DragDropProvider>['onDragEnd']\n} => {\n const [items, setItems] = useState<TreeItem[]>(() => flattenTree(definition.content))\n const initialDepth = useRef(0)\n const sourceChildren = useRef<TreeItem[]>([])\n const dragSourceId = useRef<number | null>(null)\n\n const definitionRef = useRef(definition)\n definitionRef.current = definition\n\n const onDefinitionChangeRef = useRef(onDefinitionChange)\n onDefinitionChangeRef.current = onDefinitionChange\n\n // Re-sync items when definition changes externally (e.g. from field editor sheet)\n useEffect(() => {\n setItems(flattenTree(definition.content))\n }, [definition])\n\n const applyEditor = useCallback((editor: FormDefinitionEditor) => {\n const updated = editor.toJSON()\n setItems(flattenTree(updated.content))\n onDefinitionChangeRef.current?.(updated)\n }, [])\n\n const handleItemAdd = useCallback(\n (sectionId: number | null, item: NewContentItem): number => {\n const editor = new FormDefinitionEditor(definitionRef.current)\n const parentId = sectionId ?? undefined\n const id = editor.nextId()\n\n if (item.type === 'section') editor.addSection({ ...item, id }, parentId)\n else editor.addField({ ...item, id } as FieldContentItem, parentId)\n\n applyEditor(editor)\n return id\n },\n [applyEditor],\n )\n\n const handleItemChange = useCallback(\n (id: number, newItem: ContentItem) => {\n const editor = new FormDefinitionEditor(definitionRef.current)\n\n if (newItem.type === 'section') {\n const { id: _, type: __, content: ___, ...updates } = newItem as SectionContentItem\n editor.updateSection(id, updates)\n } else {\n const { id: _, type: __, ...updates } = newItem as FieldContentItem\n editor.updateField(id, updates)\n }\n\n applyEditor(editor)\n },\n [applyEditor],\n )\n\n const handleItemRemove = useCallback(\n (itemId: number) => {\n const editor = new FormDefinitionEditor(definitionRef.current)\n editor.removeItem(itemId)\n applyEditor(editor)\n },\n [applyEditor],\n )\n\n const handleDragStart: ComponentProps<typeof DragDropProvider>['onDragStart'] = (event) => {\n const { source } = event.operation\n if (!source) return\n\n const item = items.find(({ id }) => id === source.id)\n if (!item) return\n\n initialDepth.current = item.depth\n dragSourceId.current = source.id as number\n\n setItems((prev) => {\n sourceChildren.current = []\n const descendants = getDescendants(prev, source.id as number)\n\n return prev.filter((i) => {\n if (descendants.has(i.id)) {\n sourceChildren.current = [...sourceChildren.current, i]\n return false\n }\n return true\n })\n })\n }\n\n const handleDragOver: ComponentProps<typeof DragDropProvider>['onDragOver'] = (event, manager) => {\n const { source, target } = event.operation\n event.preventDefault()\n\n if (source && target && source.id !== target.id) {\n setItems((prev) => {\n const offsetLeft = manager.dragOperation.transform.x\n const dragDepth = getDragDepth(offsetLeft, INDENTATION)\n const projectedDepth = initialDepth.current + dragDepth\n\n const { depth, parentId } = getProjection(prev, target.id as number, projectedDepth, MAX_DEPTH)\n\n const sorted = move(prev, event)\n return sorted.map((item) => (item.id === source.id ? { ...item, depth, parentId } : item))\n })\n }\n }\n\n const handleDragMove: ComponentProps<typeof DragDropProvider>['onDragMove'] = (event, manager) => {\n if (event.defaultPrevented) return\n\n const { source, target } = event.operation\n if (!source || !target) return\n\n const offsetLeft = manager.dragOperation.transform.x\n const dragDepth = getDragDepth(offsetLeft, INDENTATION)\n const projectedDepth = initialDepth.current + dragDepth\n\n const { depth, parentId } = getProjection(items, source.id as number, projectedDepth, MAX_DEPTH)\n\n if (\n (source.data as { depth: number })?.depth !== depth ||\n (source.data as { parentId: number | null })?.parentId !== parentId\n ) {\n setItems((prev) => prev.map((item) => (item.id === source.id ? { ...item, depth, parentId } : item)))\n }\n }\n\n const handleDragEnd: ComponentProps<typeof DragDropProvider>['onDragEnd'] = (event) => {\n if (event.canceled) {\n setItems(flattenTree(definitionRef.current.content))\n dragSourceId.current = null\n sourceChildren.current = []\n return\n }\n\n const draggedId = dragSourceId.current\n if (draggedId === null) return\n\n const draggedItem = items.find((i) => i.id === draggedId)\n if (!draggedItem) return\n\n // Compute sibling index in the new parent\n const targetParentId = draggedItem.parentId\n const draggedFlatIndex = items.findIndex((i) => i.id === draggedId)\n let siblingIndex = 0\n for (let i = 0; i < draggedFlatIndex; i++) {\n const current = items[i]\n if (current && current.parentId === targetParentId && current.type !== 'add-placeholder') {\n siblingIndex++\n }\n }\n\n const editor = new FormDefinitionEditor(definitionRef.current)\n editor.moveItem(draggedId, targetParentId ?? undefined, siblingIndex)\n applyEditor(editor)\n\n dragSourceId.current = null\n sourceChildren.current = []\n }\n\n return {\n items,\n handleItemAdd,\n handleItemChange,\n handleItemRemove,\n handleDragStart,\n handleDragOver,\n handleDragMove,\n handleDragEnd,\n } as const\n}\n","import type { FC, PropsWithChildren } from 'react'\n\nimport type { ContentItem, FormDefinition } from '@bluprynt/forms-core'\nimport { DragDropProvider } from '@dnd-kit/react'\n\nimport { AddPlaceholder, type AddPlaceholderRenderProps } from './add-placeholder'\nimport { isAddPlaceholder, isField, isSection, NewContentItem } from './core/types'\nimport { Field, type FieldRenderProps } from './field'\nimport { Section, type SectionRenderProps } from './section'\nimport { useFormBuilder } from './use-form-builder'\n\ntype FormBuilderProps = {\n definition: FormDefinition\n container: FC<PropsWithChildren>\n section: FC<SectionRenderProps>\n field: FC<FieldRenderProps>\n addPlaceholder: FC<AddPlaceholderRenderProps>\n selectedId?: number | null\n onDefinitionChange?: (definition: FormDefinition) => void\n}\n\nexport const FormBuilder: FC<FormBuilderProps> = ({\n definition,\n container: Container,\n section: SectionComponent,\n field: FieldComponent,\n addPlaceholder: AddPlaceholderComponent,\n selectedId,\n onDefinitionChange,\n}) => {\n const {\n items,\n handleItemAdd,\n handleItemChange,\n handleItemRemove,\n handleDragStart,\n handleDragOver,\n handleDragMove,\n handleDragEnd,\n } = useFormBuilder(definition, onDefinitionChange)\n\n return (\n <DragDropProvider\n onDragStart={handleDragStart}\n onDragOver={handleDragOver}\n onDragMove={handleDragMove}\n onDragEnd={handleDragEnd}>\n <Container>\n {items.map((item, index) => {\n const onAdd = (value: NewContentItem) =>\n handleItemAdd(item.type === 'section' ? item.id : item.parentId, value)\n const onRemove = () => handleItemRemove(item.id)\n const onChange = (value: ContentItem) => handleItemChange(value.id, value)\n\n return isSection(item) ? (\n <Section\n key={item.id}\n id={item.id}\n depth={item.depth}\n index={index}\n parentId={item.parentId}\n item={item.item}\n isSelected={selectedId === item.id}\n component={SectionComponent}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n ) : isField(item) ? (\n <Field\n key={item.id}\n id={item.id}\n depth={item.depth}\n index={index}\n parentId={item.parentId}\n type={item.type}\n item={item.item}\n isSelected={selectedId === item.id}\n component={FieldComponent}\n onAdd={onAdd}\n onRemove={onRemove}\n onChange={onChange}\n />\n ) : isAddPlaceholder(item) ? (\n <AddPlaceholder\n key={item.id}\n depth={item.depth}\n parentId={item.parentId}\n component={AddPlaceholderComponent}\n onAdd={onAdd}\n onChange={handleItemChange}\n />\n ) : null\n })}\n </Container>\n </DragDropProvider>\n )\n}\n"],"mappings":";;;;;;;AAqBA,MAAa,kBAA2C,EAAE,OAAO,UAAU,WAAW,WAAW,OAAO,eACpG,oBAAC,WAAD;CAAkB;CAAiB;CAAiB;CAAiB;CAAY,CAAA;;;;;;ACiBrF,MAAa,aAAa,SACtB,KAAK,SAAS;;;;;;;;AASlB,MAAa,WACT,SAEA,KAAK,SAAS,aAAa,KAAK,SAAS;;;;AAK7C,MAAa,oBAAoB,SAC7B,KAAK,SAAS;;;ACvDlB,MAAa,kBAAkB;CAC3B,WAAW;EACP,GAAG;EACH,GAAG;EACN;CACD,YAAY,EACR,MAAM,MACT;CACJ;;;AC2BD,MAAa,SAAyB,EAClC,IACA,OACA,OACA,UACA,MACA,MACA,YACA,WAAW,WACX,OACA,UACA,eACE;CACF,MAAM,EAAE,KAAK,WAAW,iBAAiB,YAAY;EACjD,GAAG;EACH;EACA;EACA,MAAM;GAAE;GAAO;GAAU;EAC5B,CAAC;AAEF,QACI,oBAAC,WAAD;EACS;EACM;EACP;EACG;EACA;EACG;EACJ;EACA;EACN,YAAY;EACA;EACL;EACG;EACA;EACZ,CAAA;;;;ACrCV,MAAa,WAA6B,EACtC,IACA,OACA,OACA,UACA,MACA,YACA,WAAW,WACX,OACA,UACA,eACE;CACF,MAAM,EAAE,KAAK,WAAW,iBAAiB,YAAY;EACjD,GAAG;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ClB,oBAAC,SAAD;IAEI,IAAI,KAAK;IACT,OAAO,KAAK;IACL;IACP,UAAU,KAAK;IACf,MAAM,KAAK;IACX,YAAY,eAAe,KAAK;IAChC,WAAW;IACJ;IACG;IACA;IACZ,EAXO,KAAK,GAWZ,GACF,QAAQ,KAAK,GACb,oBAAC,OAAD;IAEI,IAAI,KAAK;IACT,OAAO,KAAK;IACL;IACP,UAAU,KAAK;IACf,MAAM,KAAK;IACX,MAAM,KAAK;IACX,YAAY,eAAe,KAAK;IAChC,WAAW;IACJ;IACG;IACA;IACZ,EAZO,KAAK,GAYZ,GACF,iBAAiB,KAAK,GACtB,oBAAC,gBAAD;IAEI,OAAO,KAAK;IACZ,UAAU,KAAK;IACf,WAAW;IACJ;IACP,UAAU;IACZ,EANO,KAAK,GAMZ,GACF;IACN,EACM,CAAA;EACG,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluprynt/forms-builder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/blupryntco/forms-engine.git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@dnd-kit/state": "^0.3.0",
|
|
30
30
|
"react": "^18.0.0 || ^19.0.0",
|
|
31
31
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
32
|
-
"@bluprynt/forms-core": "
|
|
32
|
+
"@bluprynt/forms-core": "^4.1.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@dnd-kit/abstract": "0.3.2",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"ts-jest": "29.4.6",
|
|
49
49
|
"tsdown": "0.21.1",
|
|
50
50
|
"typescript": "5.9.3",
|
|
51
|
-
"@bluprynt/forms-core": "
|
|
51
|
+
"@bluprynt/forms-core": "4.1.0",
|
|
52
52
|
"@repo/typescript-config": "0.0.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|