@betterstart/cli 0.1.53 → 0.1.55
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 +12 -9
- 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}
|
|
@@ -2719,7 +2720,9 @@ ${p7.fieldArraySetup}${p7.watchSetup}
|
|
|
2719
2720
|
STEPS[currentStep].fields as (keyof FormValues)[]
|
|
2720
2721
|
)
|
|
2721
2722
|
if (isValid) {
|
|
2722
|
-
|
|
2723
|
+
const next = currentStep + 1
|
|
2724
|
+
form.clearErrors(STEPS[next].fields as (keyof FormValues)[])
|
|
2725
|
+
setCurrentStep(next)
|
|
2723
2726
|
}
|
|
2724
2727
|
}
|
|
2725
2728
|
|
|
@@ -2818,14 +2821,14 @@ function generateSingleStepForm(schema, cwd, cmsDir, options) {
|
|
|
2818
2821
|
const zodFields = buildZodFields(fields);
|
|
2819
2822
|
const defaults = buildDefaultValues(fields);
|
|
2820
2823
|
const listFields = getListFields(fields);
|
|
2821
|
-
const
|
|
2824
|
+
const hasListFields = listFields.length > 0;
|
|
2822
2825
|
const { setup: watchSetup } = buildWatchDecls(fields);
|
|
2823
2826
|
const rawFields = schema.fields || [];
|
|
2824
2827
|
const fieldJSX = renderFieldsJSX(rawFields);
|
|
2825
2828
|
const submitText = schema.submitButtonText || "Submit";
|
|
2826
2829
|
const successMessage = escapeJsx(schema.successMessage || "Form submitted successfully!");
|
|
2827
|
-
const rhfImport =
|
|
2828
|
-
const fieldArraySetup =
|
|
2830
|
+
const rhfImport = hasListFields ? `import { useFieldArray, useForm } from 'react-hook-form'` : `import { useForm } from 'react-hook-form'`;
|
|
2831
|
+
const fieldArraySetup = hasListFields ? `
|
|
2829
2832
|
${buildFieldArrayDecls(listFields)}
|
|
2830
2833
|
` : "";
|
|
2831
2834
|
const hasRadio = fields.some((f) => f.type === "radio");
|
|
@@ -2852,7 +2855,7 @@ export function ${pascal}Form() {
|
|
|
2852
2855
|
)
|
|
2853
2856
|
}
|
|
2854
2857
|
` : "";
|
|
2855
|
-
const lucideImport =
|
|
2858
|
+
const lucideImport = hasListFields ? `
|
|
2856
2859
|
import { Trash2 } from 'lucide-react'` : "";
|
|
2857
2860
|
const content = `'use client'
|
|
2858
2861
|
|