@esheet/builder 0.0.1 → 0.0.2-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 +119 -119
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7256 -4274
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
# @esheet/builder
|
|
2
|
-
|
|
3
|
-
Drag-and-drop questionnaire builder for eSheet. Provides a full editing UI for creating and modifying form schemas.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- ✅ Visual form builder with drag & drop (custom pointer-based engine)
|
|
8
|
-
- ✅ 19 built-in field types via `@esheet/fields`
|
|
9
|
-
- ✅ Section nesting with drag-into-section support
|
|
10
|
-
- ✅ Field editors (question text, options, matrix rows/columns, conditional logic)
|
|
11
|
-
- ✅ Code view with Monaco editor (JSON/YAML toggle)
|
|
12
|
-
- ✅ Live preview mode
|
|
13
|
-
- ✅ Import/Export (JSON + YAML)
|
|
14
|
-
- ✅ Custom field type registration
|
|
15
|
-
- ✅ Dark mode support
|
|
16
|
-
- ✅ Mobile responsive (bottom drawer for panels)
|
|
17
|
-
- ✅ Self-contained CSS (injected at runtime, no external stylesheet needed)
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install @esheet/builder @esheet/fields @esheet/core
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
### Basic Example
|
|
28
|
-
|
|
29
|
-
```tsx
|
|
30
|
-
import { EsheetBuilder } from '@esheet/builder';
|
|
31
|
-
import type { FormDefinition } from '@esheet/core';
|
|
32
|
-
|
|
33
|
-
function App() {
|
|
34
|
-
const handleChange = (definition: FormDefinition) => {
|
|
35
|
-
console.log('Form updated:', definition);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return <EsheetBuilder onChange={handleChange} />;
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### With Initial Schema
|
|
43
|
-
|
|
44
|
-
```tsx
|
|
45
|
-
import { EsheetBuilder } from '@esheet/builder';
|
|
46
|
-
|
|
47
|
-
const initialForm: FormDefinition = {
|
|
48
|
-
schemaType: 'mieforms-v1.0',
|
|
49
|
-
title: 'Patient Intake',
|
|
50
|
-
fields: [
|
|
51
|
-
{ id: 'name', fieldType: 'text', question: 'Full Name', required: true },
|
|
52
|
-
{ id: 'dob', fieldType: 'date', question: 'Date of Birth' },
|
|
53
|
-
],
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
<EsheetBuilder initialDefinition={initialForm} onChange={handleChange} />;
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Dark Mode
|
|
60
|
-
|
|
61
|
-
```tsx
|
|
62
|
-
<div className="dark">
|
|
63
|
-
<EsheetBuilder onChange={handleChange} />
|
|
64
|
-
</div>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Add the `dark` class to the builder's root or any ancestor — the builder scopes all dark styles via `.ms-builder-root.dark`.
|
|
68
|
-
|
|
69
|
-
## API
|
|
70
|
-
|
|
71
|
-
### `<EsheetBuilder>`
|
|
72
|
-
|
|
73
|
-
**Props:**
|
|
74
|
-
|
|
75
|
-
| Prop | Type | Description |
|
|
76
|
-
| ------------------- | ------------------------------- | ------------------------------- |
|
|
77
|
-
| `initialDefinition` | `FormDefinition` | Pre-load a form schema |
|
|
78
|
-
| `onChange` | `(def: FormDefinition) => void` | Callback on any form change |
|
|
79
|
-
| `className` | `string` | Additional CSS classes for root |
|
|
80
|
-
|
|
81
|
-
## Custom Field Types
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
import { EsheetBuilder } from '@esheet/builder';
|
|
85
|
-
import { registerCustomFieldTypes } from '@esheet/fields';
|
|
86
|
-
import { registerFieldType } from '@esheet/core';
|
|
87
|
-
|
|
88
|
-
// Register the metadata
|
|
89
|
-
registerFieldType({
|
|
90
|
-
type: 'nps',
|
|
91
|
-
label: 'NPS Score',
|
|
92
|
-
category: 'scale',
|
|
93
|
-
defaultProps: { question: 'How likely are you to recommend us?' },
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Register the component
|
|
97
|
-
registerCustomFieldTypes({
|
|
98
|
-
nps: {
|
|
99
|
-
component: NpsField,
|
|
100
|
-
meta: {
|
|
101
|
-
/* ... */
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
<EsheetBuilder onChange={handleChange} />;
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## CSS Architecture
|
|
110
|
-
|
|
111
|
-
The builder uses Tailwind CSS v4 with `ms:` prefix. CSS is compiled via `@tailwindcss/cli` and embedded into the JS bundle at build time — consumers never need to import a stylesheet. A scoped reset on `.ms-builder-root` prevents style leakage in either direction.
|
|
112
|
-
|
|
113
|
-
## Building
|
|
114
|
-
|
|
115
|
-
Run `nx build @esheet/builder` to build the library.
|
|
116
|
-
|
|
117
|
-
## Running unit tests
|
|
118
|
-
|
|
119
|
-
Run `nx test @esheet/builder` to execute the unit tests via [Vitest](https://vitest.dev/).
|
|
1
|
+
# @esheet/builder
|
|
2
|
+
|
|
3
|
+
Drag-and-drop questionnaire builder for eSheet. Provides a full editing UI for creating and modifying form schemas.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ Visual form builder with drag & drop (custom pointer-based engine)
|
|
8
|
+
- ✅ 19 built-in field types via `@esheet/fields`
|
|
9
|
+
- ✅ Section nesting with drag-into-section support
|
|
10
|
+
- ✅ Field editors (question text, options, matrix rows/columns, conditional logic)
|
|
11
|
+
- ✅ Code view with Monaco editor (JSON/YAML toggle)
|
|
12
|
+
- ✅ Live preview mode
|
|
13
|
+
- ✅ Import/Export (JSON + YAML)
|
|
14
|
+
- ✅ Custom field type registration
|
|
15
|
+
- ✅ Dark mode support
|
|
16
|
+
- ✅ Mobile responsive (bottom drawer for panels)
|
|
17
|
+
- ✅ Self-contained CSS (injected at runtime, no external stylesheet needed)
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @esheet/builder @esheet/fields @esheet/core
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Basic Example
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { EsheetBuilder } from '@esheet/builder';
|
|
31
|
+
import type { FormDefinition } from '@esheet/core';
|
|
32
|
+
|
|
33
|
+
function App() {
|
|
34
|
+
const handleChange = (definition: FormDefinition) => {
|
|
35
|
+
console.log('Form updated:', definition);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return <EsheetBuilder onChange={handleChange} />;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### With Initial Schema
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { EsheetBuilder } from '@esheet/builder';
|
|
46
|
+
|
|
47
|
+
const initialForm: FormDefinition = {
|
|
48
|
+
schemaType: 'mieforms-v1.0',
|
|
49
|
+
title: 'Patient Intake',
|
|
50
|
+
fields: [
|
|
51
|
+
{ id: 'name', fieldType: 'text', question: 'Full Name', required: true },
|
|
52
|
+
{ id: 'dob', fieldType: 'date', question: 'Date of Birth' },
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
<EsheetBuilder initialDefinition={initialForm} onChange={handleChange} />;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Dark Mode
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
<div className="dark">
|
|
63
|
+
<EsheetBuilder onChange={handleChange} />
|
|
64
|
+
</div>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Add the `dark` class to the builder's root or any ancestor — the builder scopes all dark styles via `.ms-builder-root.dark`.
|
|
68
|
+
|
|
69
|
+
## API
|
|
70
|
+
|
|
71
|
+
### `<EsheetBuilder>`
|
|
72
|
+
|
|
73
|
+
**Props:**
|
|
74
|
+
|
|
75
|
+
| Prop | Type | Description |
|
|
76
|
+
| ------------------- | ------------------------------- | ------------------------------- |
|
|
77
|
+
| `initialDefinition` | `FormDefinition` | Pre-load a form schema |
|
|
78
|
+
| `onChange` | `(def: FormDefinition) => void` | Callback on any form change |
|
|
79
|
+
| `className` | `string` | Additional CSS classes for root |
|
|
80
|
+
|
|
81
|
+
## Custom Field Types
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { EsheetBuilder } from '@esheet/builder';
|
|
85
|
+
import { registerCustomFieldTypes } from '@esheet/fields';
|
|
86
|
+
import { registerFieldType } from '@esheet/core';
|
|
87
|
+
|
|
88
|
+
// Register the metadata
|
|
89
|
+
registerFieldType({
|
|
90
|
+
type: 'nps',
|
|
91
|
+
label: 'NPS Score',
|
|
92
|
+
category: 'scale',
|
|
93
|
+
defaultProps: { question: 'How likely are you to recommend us?' },
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Register the component
|
|
97
|
+
registerCustomFieldTypes({
|
|
98
|
+
nps: {
|
|
99
|
+
component: NpsField,
|
|
100
|
+
meta: {
|
|
101
|
+
/* ... */
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
<EsheetBuilder onChange={handleChange} />;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## CSS Architecture
|
|
110
|
+
|
|
111
|
+
The builder uses Tailwind CSS v4 with `ms:` prefix. CSS is compiled via `@tailwindcss/cli` and embedded into the JS bundle at build time — consumers never need to import a stylesheet. A scoped reset on `.ms-builder-root` prevents style leakage in either direction.
|
|
112
|
+
|
|
113
|
+
## Building
|
|
114
|
+
|
|
115
|
+
Run `nx build @esheet/builder` to build the library.
|
|
116
|
+
|
|
117
|
+
## Running unit tests
|
|
118
|
+
|
|
119
|
+
Run `nx test @esheet/builder` to execute the unit tests via [Vitest](https://vitest.dev/).
|
package/dist/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export { FieldComponentProps }
|
|
|
83
83
|
* </FieldWrapper>
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
|
-
export declare function FieldWrapper({ fieldId, form, ui, dragHandleRef, isSelectedOverride, onSelectOverride, selectedVariant, forceExpandVersion, children, }: FieldWrapperProps): JSX.Element | null;
|
|
86
|
+
export declare function FieldWrapper({ fieldId, form, ui, dragHandleRef, isSelectedOverride, onSelectOverride, selectedVariant, forceExpandVersion, forceCollapseVersion, children, }: FieldWrapperProps): JSX.Element | null;
|
|
87
87
|
|
|
88
88
|
export declare interface FieldWrapperProps {
|
|
89
89
|
/** The field ID */
|
|
@@ -102,6 +102,8 @@ export declare interface FieldWrapperProps {
|
|
|
102
102
|
selectedVariant?: 'default' | 'nested';
|
|
103
103
|
/** Optional signal used to force expand a field wrapper (used for section drop UX). */
|
|
104
104
|
forceExpandVersion?: number;
|
|
105
|
+
/** Optional signal used to force collapse a field wrapper. */
|
|
106
|
+
forceCollapseVersion?: number;
|
|
105
107
|
/** Render function that receives field data and tools */
|
|
106
108
|
children: (props: FieldWrapperRenderProps) => default_2.ReactNode;
|
|
107
109
|
}
|