formhell 1.0.1 → 1.0.3
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 +59 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{styles-UY6N5SPU.css → styles-MTB5P5LP.css} +223 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# formhell
|
|
1
|
+
# formhell <img src="favicon.svg" alt="FormHell icon" width="32" height="32" />
|
|
2
2
|
|
|
3
3
|
Finally escape form hell with FormHell
|
|
4
4
|
|
|
@@ -40,6 +40,7 @@ Here's a quick comparison for using FormHell instead of some other headache libr
|
|
|
40
40
|
| Widget overrides by pointer and type | Yes | Usually type-only or custom plumbing |
|
|
41
41
|
| Defaults strategy control | Yes (`all` / `required-only`) | Often limited and super broken |
|
|
42
42
|
| Validation feedback on every change | Yes | Usually yes |
|
|
43
|
+
| Optional MUI or custom theming | Yes | Usually yes |
|
|
43
44
|
|
|
44
45
|
If your form requirements include deep JSON Schema support and your timeline includes "this quarter," this matrix is the point.
|
|
45
46
|
|
|
@@ -64,6 +65,63 @@ import { SchemaForm, SchemaBuilder, SchemaBuilderHelper } from "formhell";
|
|
|
64
65
|
import "formhell/styles.css";
|
|
65
66
|
```
|
|
66
67
|
|
|
68
|
+
## Theming
|
|
69
|
+
|
|
70
|
+
FormHell does not depend on Material UI or any other styling framework. Importing `formhell/styles.css` gives the components a complete default theme, so the library works without a provider or theme package.
|
|
71
|
+
|
|
72
|
+
The components are also designed to participate in a host application's theme. Their styles use CSS custom properties with fallbacks, which means an application can override the FormHell variables at any scope that contains a `SchemaForm`, `SchemaBuilder`, or `SchemaBuilderHelper`:
|
|
73
|
+
|
|
74
|
+
```css
|
|
75
|
+
.checkout-form {
|
|
76
|
+
--raf-color-border: #6b7280;
|
|
77
|
+
--raf-color-border-focus: #0f766e;
|
|
78
|
+
--raf-color-label: #102a43;
|
|
79
|
+
--raf-color-muted: #52657a;
|
|
80
|
+
--raf-color-surface: #ffffff;
|
|
81
|
+
--raf-color-surface-alt: #f3f6fb;
|
|
82
|
+
--raf-color-danger: #b42318;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Optional Material UI integration
|
|
87
|
+
|
|
88
|
+
When a Material UI theme is present, FormHell automatically consumes MUI's generated CSS variables. Create the theme with `cssVariables: true` and place the FormHell components inside the `ThemeProvider`:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { CssBaseline, ThemeProvider, createTheme } from "@mui/material";
|
|
92
|
+
import { SchemaForm } from "formhell";
|
|
93
|
+
import "formhell/styles.css";
|
|
94
|
+
|
|
95
|
+
const theme = createTheme({
|
|
96
|
+
cssVariables: true,
|
|
97
|
+
palette: {
|
|
98
|
+
primary: { main: "#1976d2" },
|
|
99
|
+
secondary: { main: "#526d82" },
|
|
100
|
+
error: { main: "#b42318" },
|
|
101
|
+
background: { default: "#f3f6fb", paper: "#ffffff" },
|
|
102
|
+
text: { primary: "#172b4d", secondary: "#52657a" }
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
<ThemeProvider theme={theme}>
|
|
107
|
+
<CssBaseline />
|
|
108
|
+
<SchemaForm schema={schema} />
|
|
109
|
+
</ThemeProvider>;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
FormHell maps the available MUI variables to its component roles:
|
|
113
|
+
|
|
114
|
+
- `background.paper` controls form inputs, builder controls, modals, and helper surfaces.
|
|
115
|
+
- `background.default` controls nested objects, builder sections, typeahead menus, and previews.
|
|
116
|
+
- `text.primary` controls labels, headings, input text, and body content.
|
|
117
|
+
- `text.secondary` controls optional labels, summaries, muted copy, and empty states.
|
|
118
|
+
- `divider` controls borders.
|
|
119
|
+
- `primary.main` controls primary actions, focus rings, selected type buttons, and links.
|
|
120
|
+
- `secondary.main` controls secondary actions such as Add Type, info buttons, and tooltip Close buttons.
|
|
121
|
+
- `error.main` controls danger actions, validation errors, and error states.
|
|
122
|
+
|
|
123
|
+
MUI is intentionally not listed as a FormHell dependency. Applications that use another theme system can provide the same CSS custom properties, and applications without a theme continue using FormHell's built-in fallbacks.
|
|
124
|
+
|
|
67
125
|
## Exported Components At A Glance
|
|
68
126
|
|
|
69
127
|
- `SchemaForm`: Render data-entry forms from JSON Schema.
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
SchemaForm: () => SchemaForm
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
var import_styles = require("./styles-
|
|
38
|
+
var import_styles = require("./styles-MTB5P5LP.css");
|
|
39
39
|
|
|
40
40
|
// src/components/SchemaForm.tsx
|
|
41
41
|
var import_react3 = require("react");
|
|
@@ -2262,7 +2262,7 @@ function ObjectSchemaEditor({
|
|
|
2262
2262
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "raf-button-row", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2263
2263
|
"button",
|
|
2264
2264
|
{
|
|
2265
|
-
className: "raf-button raf-button-primary",
|
|
2265
|
+
className: "raf-button raf-button-primary raf-builder-add-property",
|
|
2266
2266
|
type: "button",
|
|
2267
2267
|
onClick: () => {
|
|
2268
2268
|
const next = cloneSchema(schema);
|
|
@@ -2597,7 +2597,7 @@ function ArraySchemaEditor({ schema, onChange }) {
|
|
|
2597
2597
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "raf-button-row", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2598
2598
|
"button",
|
|
2599
2599
|
{
|
|
2600
|
-
className: "raf-button raf-button-
|
|
2600
|
+
className: "raf-button raf-button-secondary",
|
|
2601
2601
|
type: "button",
|
|
2602
2602
|
onClick: () => {
|
|
2603
2603
|
const next = cloneSchema(schema);
|
|
@@ -2859,7 +2859,7 @@ function CombinationEditor({
|
|
|
2859
2859
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "raf-button-row", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2860
2860
|
"button",
|
|
2861
2861
|
{
|
|
2862
|
-
className: "raf-button raf-button-
|
|
2862
|
+
className: "raf-button raf-button-secondary",
|
|
2863
2863
|
type: "button",
|
|
2864
2864
|
onClick: () => {
|
|
2865
2865
|
const next = cloneSchema(schema);
|
|
@@ -2887,7 +2887,7 @@ function ConditionalSchemaEditor({
|
|
|
2887
2887
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "raf-button-row", children: !entry ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2888
2888
|
"button",
|
|
2889
2889
|
{
|
|
2890
|
-
className: "raf-button raf-button-
|
|
2890
|
+
className: "raf-button raf-button-secondary",
|
|
2891
2891
|
type: "button",
|
|
2892
2892
|
onClick: () => {
|
|
2893
2893
|
const next = cloneSchema(schema);
|
|
@@ -2945,7 +2945,7 @@ function SingleSchemaEditor({
|
|
|
2945
2945
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "raf-button-row", children: !entry ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2946
2946
|
"button",
|
|
2947
2947
|
{
|
|
2948
|
-
className: "raf-button raf-button-
|
|
2948
|
+
className: "raf-button raf-button-secondary",
|
|
2949
2949
|
type: "button",
|
|
2950
2950
|
onClick: () => {
|
|
2951
2951
|
const next = cloneSchema(schema);
|
|
@@ -3143,7 +3143,7 @@ function FieldLabel({
|
|
|
3143
3143
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3144
3144
|
"button",
|
|
3145
3145
|
{
|
|
3146
|
-
className: "raf-info-button",
|
|
3146
|
+
className: "raf-info-button raf-button-secondary",
|
|
3147
3147
|
type: "button",
|
|
3148
3148
|
"aria-label": `Info about ${label}`,
|
|
3149
3149
|
onClick: (event) => {
|