@vulcantech/forms 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +11 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,30 +10,21 @@ Dynamic form renderer for VulcanTech apps. Renders a form from a JSON `FormDefin
10
10
 
11
11
  Wire forms into a consumer site (Next.js App Router):
12
12
 
13
- **1. Add the dependency** (`package.json`):
14
- ```json
15
- "@vulcantech/forms": "*"
13
+ **1. Add the dependency**:
14
+ ```bash
15
+ npm install @vulcantech/forms
16
16
  ```
17
+ (Inside the VulcanTech monorepo, use the workspace wiring in `MONOREPO.md` instead.)
17
18
 
18
- **2. Transpile + alias it** (`next.config.js`):
19
- ```js
20
- transpilePackages: ["@vulcantech/forms", /* ... */],
21
- webpack: (config) => {
22
- config.resolve.alias["@vulcantech/forms"] = path.join(__dirname, "../../packages/forms");
23
- return config;
24
- },
25
- turbopack: {
26
- resolveAlias: { "@vulcantech/forms": "./../../packages/forms/index.tsx" },
27
- },
28
- ```
19
+ **2. Set the env** — see [Required env](#required-env) below.
29
20
 
30
- **3. Tailwind content (required)** — add the package source to Tailwind, or the renderer's classes won't generate and forms render unstyled. Tailwind v4 (in the app's `globals.css` / `tailwind.css`); adjust the relative path to the app's depth:
21
+ **3. Tailwind content (required)** — add the package to Tailwind's sources, or the renderer's classes won't generate and forms render unstyled. Tailwind v4 (in the app's `globals.css` / `tailwind.css`); adjust the path to where the package resolves from:
31
22
  ```css
32
- @source "../../../../packages/forms/src";
23
+ @source "../node_modules/@vulcantech/forms/dist";
33
24
  ```
34
- (JS config: add `"../../packages/forms/src/**/*.{ts,tsx}"` to `content`.)
25
+ (JS config: add the equivalent glob to `content`. Monorepo apps point at the package source instead — see `MONOREPO.md`.)
35
26
 
36
- **4. Server fetcher** `src/lib/cms/forms.ts` — ISR-cached wrapper over the CMS `/api/forms` (copy from a reference app, e.g. dry-ice / eurocomp). Exposes `getFormById(id)` / `getFormBySlug(slug)`; tags each fetch `form:{projectId}:{formId}` + `forms:{projectId}`; returns `null` on failure so the page still renders.
27
+ **4. Server fetcher** `src/lib/cms/forms.ts` — ISR-cached wrapper over the CMS `/api/forms`. Exposes `getFormById(id)` / `getFormBySlug(slug)`; tags each fetch `form:{projectId}:{formId}` + `forms:{projectId}`; returns `null` on failure so the page still renders.
37
28
 
38
29
  **5. Per-form loader** `src/lib/cms/load<Name>Form.ts` — pin the form's Firestore id and wrap the fetcher with a fallback:
39
30
  ```ts
@@ -64,10 +55,10 @@ export function ContactForm({ definition }: { definition?: FormDefinition }) {
64
55
  `VULCANTECH_PROJECT_ID`, `VULCANTECH_API_KEY` (required) · `VULCANTECH_CMS_URL` (optional) · `VULCANTECH_FORMS_NO_CACHE` (optional, `1`/`true` to bypass ISR).
65
56
 
66
57
  ### Per-app values
67
- - **Form definition ID(s)** — Firestore doc id from the CMS admin (one per form), pinned in `load<Name>Form.ts` (e.g. eurocomp `SERVICE_REQUEST_FORM_ID`, castlerents `CONTACT_FORM_ID`).
58
+ - **Form definition ID(s)** — Firestore doc id from the CMS admin (one per form), pinned in `load<Name>Form.ts` (e.g. `CONTACT_FORM_ID`, `SERVICE_REQUEST_FORM_ID`).
68
59
 
69
60
  ### Notes
70
61
  - `FormDefinition` is the CMS-authored schema (sections, fields, submit config, style).
71
62
  - `style.buttonPlacement: "inline"` renders the submit button beside the fields instead of full-width below them — suited to single-field forms (newsletter email + Join). Editable in the CMS form builder under Style → Submit Button → Button Placement.
72
- - Newsletter forms (`submissionType: "newsletter"`) should submit to an app route that proxies to the CMS `/api/contact` — the CMS routes them into `newsletter_subscribers` (see dry-ice-pro-auto `src/app/api/newsletter/route.ts`).
63
+ - Newsletter forms (`submissionType: "newsletter"`) should submit to an app route that proxies to the CMS `/api/contact` — the CMS routes them into `newsletter_subscribers`.
73
64
  - The package also ships `buildYupSchema` / `buildInitialValues` for custom render paths, but consumer sites use the server-fetcher pattern above for ISR caching.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulcantech/forms",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Dynamic form renderer with TipTap-style builder, Yup validation, sensitive field encryption, and Tailwind styling",
5
5
  "license": "MIT",
6
6
  "source": "./index.tsx",