@betterstart/cli 0.1.48 → 0.1.49
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 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/templates/ui/media-upload-field.tsx +63 -27
package/dist/cli.js
CHANGED
|
@@ -2662,6 +2662,7 @@ export function ${p7.pascal}Form() {
|
|
|
2662
2662
|
|
|
2663
2663
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
2664
2664
|
import { Check, ChevronLeft, ChevronRight } from 'lucide-react'
|
|
2665
|
+
import { parseAsInteger, parseAsArrayOf, useQueryState } from 'nuqs'
|
|
2665
2666
|
import { useState } from 'react'
|
|
2666
2667
|
${p7.rhfImport}
|
|
2667
2668
|
import { z } from 'zod/v3'${queryClientImport}
|
|
@@ -2698,8 +2699,9 @@ ${queryClientSetup}
|
|
|
2698
2699
|
${p7.stepsConst}
|
|
2699
2700
|
|
|
2700
2701
|
${formComponentDecl}() {
|
|
2701
|
-
const [currentStep, setCurrentStep] =
|
|
2702
|
-
const [
|
|
2702
|
+
const [currentStep, setCurrentStep] = useQueryState('step', parseAsInteger.withDefault(0))
|
|
2703
|
+
const [completedStepsArr, setCompletedStepsArr] = useQueryState('completed', parseAsArrayOf(parseAsInteger).withDefault([]))
|
|
2704
|
+
const completedSteps = new Set(completedStepsArr)
|
|
2703
2705
|
const [submitted, setSubmitted] = useState(false)
|
|
2704
2706
|
const [submitting, setSubmitting] = useState(false)
|
|
2705
2707
|
|
|
@@ -2716,13 +2718,15 @@ ${p7.fieldArraySetup}${p7.watchSetup}
|
|
|
2716
2718
|
STEPS[currentStep].fields as (keyof FormValues)[]
|
|
2717
2719
|
)
|
|
2718
2720
|
if (isValid) {
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
+
if (!completedSteps.has(currentStep)) {
|
|
2722
|
+
setCompletedStepsArr([...completedStepsArr, currentStep])
|
|
2723
|
+
}
|
|
2724
|
+
setCurrentStep(currentStep + 1)
|
|
2721
2725
|
}
|
|
2722
2726
|
}
|
|
2723
2727
|
|
|
2724
2728
|
function handleBack() {
|
|
2725
|
-
setCurrentStep(
|
|
2729
|
+
setCurrentStep(currentStep - 1)
|
|
2726
2730
|
}
|
|
2727
2731
|
|
|
2728
2732
|
function handleStepClick(index: number) {
|