@betterstart/cli 0.1.53 → 0.1.54
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/dist/cli.js +9 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2580,10 +2580,10 @@ function generateMultiStepForm(schema, cwd, cmsDir, options) {
|
|
|
2580
2580
|
const zodFields = buildZodFields(allFields);
|
|
2581
2581
|
const defaults = buildDefaultValues(allFields);
|
|
2582
2582
|
const listFields = getListFields(allFields);
|
|
2583
|
-
const
|
|
2583
|
+
const hasListFields = listFields.length > 0;
|
|
2584
2584
|
const { setup: watchSetup } = buildWatchDecls(allFields);
|
|
2585
|
-
const rhfImport =
|
|
2586
|
-
const fieldArraySetup =
|
|
2585
|
+
const rhfImport = hasListFields ? `import { useFieldArray, useForm } from 'react-hook-form'` : `import { useForm } from 'react-hook-form'`;
|
|
2586
|
+
const fieldArraySetup = hasListFields ? `
|
|
2587
2587
|
${buildFieldArrayDecls(listFields)}
|
|
2588
2588
|
` : "";
|
|
2589
2589
|
const stepsConst = buildStepsConstant(steps, schema);
|
|
@@ -2612,6 +2612,7 @@ ${fieldsJSX}
|
|
|
2612
2612
|
rhfImport,
|
|
2613
2613
|
hasRadio,
|
|
2614
2614
|
hasFileUpload,
|
|
2615
|
+
hasListFields,
|
|
2615
2616
|
buttonImport,
|
|
2616
2617
|
formImport,
|
|
2617
2618
|
inputImport,
|
|
@@ -2664,7 +2665,7 @@ export function ${p7.pascal}Form() {
|
|
|
2664
2665
|
return `'use client'
|
|
2665
2666
|
|
|
2666
2667
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
2667
|
-
import { ChevronLeft, ChevronRight${hasListFields ? ", Trash2" : ""} } from 'lucide-react'
|
|
2668
|
+
import { ChevronLeft, ChevronRight${p7.hasListFields ? ", Trash2" : ""} } from 'lucide-react'
|
|
2668
2669
|
import { parseAsInteger, useQueryState } from 'nuqs'
|
|
2669
2670
|
import { useState } from 'react'
|
|
2670
2671
|
${p7.rhfImport}
|
|
@@ -2818,14 +2819,14 @@ function generateSingleStepForm(schema, cwd, cmsDir, options) {
|
|
|
2818
2819
|
const zodFields = buildZodFields(fields);
|
|
2819
2820
|
const defaults = buildDefaultValues(fields);
|
|
2820
2821
|
const listFields = getListFields(fields);
|
|
2821
|
-
const
|
|
2822
|
+
const hasListFields = listFields.length > 0;
|
|
2822
2823
|
const { setup: watchSetup } = buildWatchDecls(fields);
|
|
2823
2824
|
const rawFields = schema.fields || [];
|
|
2824
2825
|
const fieldJSX = renderFieldsJSX(rawFields);
|
|
2825
2826
|
const submitText = schema.submitButtonText || "Submit";
|
|
2826
2827
|
const successMessage = escapeJsx(schema.successMessage || "Form submitted successfully!");
|
|
2827
|
-
const rhfImport =
|
|
2828
|
-
const fieldArraySetup =
|
|
2828
|
+
const rhfImport = hasListFields ? `import { useFieldArray, useForm } from 'react-hook-form'` : `import { useForm } from 'react-hook-form'`;
|
|
2829
|
+
const fieldArraySetup = hasListFields ? `
|
|
2829
2830
|
${buildFieldArrayDecls(listFields)}
|
|
2830
2831
|
` : "";
|
|
2831
2832
|
const hasRadio = fields.some((f) => f.type === "radio");
|
|
@@ -2852,7 +2853,7 @@ export function ${pascal}Form() {
|
|
|
2852
2853
|
)
|
|
2853
2854
|
}
|
|
2854
2855
|
` : "";
|
|
2855
|
-
const lucideImport =
|
|
2856
|
+
const lucideImport = hasListFields ? `
|
|
2856
2857
|
import { Trash2 } from 'lucide-react'` : "";
|
|
2857
2858
|
const content = `'use client'
|
|
2858
2859
|
|