@betterstart/cli 0.1.52 → 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 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 hasListFields2 = listFields.length > 0;
2583
+ const hasListFields = listFields.length > 0;
2584
2584
  const { setup: watchSetup } = buildWatchDecls(allFields);
2585
- const rhfImport = hasListFields2 ? `import { useFieldArray, useForm } from 'react-hook-form'` : `import { useForm } from 'react-hook-form'`;
2586
- const fieldArraySetup = hasListFields2 ? `
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);
@@ -2605,7 +2605,6 @@ ${fieldsJSX}
2605
2605
  const textareaImport = resolveUiImport(cwd, "textarea");
2606
2606
  const selectImport = resolveUiImport(cwd, "select");
2607
2607
  const radioGroupImport = resolveUiImport(cwd, "radio-group");
2608
- const progressImport = resolveUiImport(cwd, "progress");
2609
2608
  const mediaUploadImport = resolveUiImport(cwd, "media-upload-field");
2610
2609
  const content = buildComponentSource({
2611
2610
  pascal,
@@ -2613,13 +2612,13 @@ ${fieldsJSX}
2613
2612
  rhfImport,
2614
2613
  hasRadio,
2615
2614
  hasFileUpload,
2615
+ hasListFields,
2616
2616
  buttonImport,
2617
2617
  formImport,
2618
2618
  inputImport,
2619
2619
  textareaImport,
2620
2620
  selectImport,
2621
2621
  radioGroupImport,
2622
- progressImport,
2623
2622
  mediaUploadImport,
2624
2623
  zodFields,
2625
2624
  defaults,
@@ -2666,8 +2665,8 @@ export function ${p7.pascal}Form() {
2666
2665
  return `'use client'
2667
2666
 
2668
2667
  import { zodResolver } from '@hookform/resolvers/zod'
2669
- import { Check, ChevronLeft, ChevronRight${hasListFields ? ", Trash2" : ""} } from 'lucide-react'
2670
- import { parseAsInteger, parseAsArrayOf, useQueryState } from 'nuqs'
2668
+ import { ChevronLeft, ChevronRight${p7.hasListFields ? ", Trash2" : ""} } from 'lucide-react'
2669
+ import { parseAsInteger, useQueryState } from 'nuqs'
2671
2670
  import { useState } from 'react'
2672
2671
  ${p7.rhfImport}
2673
2672
  import { z } from 'zod/v3'${queryClientImport}
@@ -2684,8 +2683,8 @@ import {
2684
2683
  } from '${p7.formImport}'
2685
2684
  import { Input } from '${p7.inputImport}'${p7.hasFileUpload ? `
2686
2685
  import { MediaUploadField } from '${p7.mediaUploadImport}'` : ""}
2687
- import { Progress } from '${p7.progressImport}'${p7.hasRadio ? `
2688
- import { RadioGroup, RadioGroupItem } from '${p7.radioGroupImport}'` : ""}
2686
+ ${p7.hasRadio ? `import { RadioGroup, RadioGroupItem } from '${p7.radioGroupImport}'
2687
+ ` : ""}
2689
2688
  import { Textarea } from '${p7.textareaImport}'
2690
2689
  import {
2691
2690
  Select,
@@ -2705,8 +2704,6 @@ ${p7.stepsConst}
2705
2704
 
2706
2705
  ${formComponentDecl}() {
2707
2706
  const [currentStep, setCurrentStep] = useQueryState('step', parseAsInteger.withDefault(0))
2708
- const [completedStepsArr, setCompletedStepsArr] = useQueryState('completed', parseAsArrayOf(parseAsInteger).withDefault([]))
2709
- const completedSteps = new Set(completedStepsArr)
2710
2707
  const [submitted, setSubmitted] = useState(false)
2711
2708
  const [submitting, setSubmitting] = useState(false)
2712
2709
 
@@ -2723,9 +2720,6 @@ ${p7.fieldArraySetup}${p7.watchSetup}
2723
2720
  STEPS[currentStep].fields as (keyof FormValues)[]
2724
2721
  )
2725
2722
  if (isValid) {
2726
- if (!completedSteps.has(currentStep)) {
2727
- setCompletedStepsArr([...completedStepsArr, currentStep])
2728
- }
2729
2723
  setCurrentStep(currentStep + 1)
2730
2724
  }
2731
2725
  }
@@ -2734,12 +2728,6 @@ ${p7.fieldArraySetup}${p7.watchSetup}
2734
2728
  setCurrentStep(currentStep - 1)
2735
2729
  }
2736
2730
 
2737
- function handleStepClick(index: number) {
2738
- if (index < currentStep || completedSteps.has(index)) {
2739
- setCurrentStep(index)
2740
- }
2741
- }
2742
-
2743
2731
  async function onSubmit(values: FormValues) {
2744
2732
  setSubmitting(true)
2745
2733
  try {
@@ -2768,48 +2756,6 @@ ${p7.fieldArraySetup}${p7.watchSetup}
2768
2756
  return (
2769
2757
  <Form {...form}>
2770
2758
  <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
2771
- {/* Mobile step indicator */}
2772
- <div className="md:hidden space-y-2">
2773
- <p className="text-sm text-muted-foreground">
2774
- Step {currentStep + 1} of {STEPS.length} &mdash; {STEPS[currentStep].label}
2775
- </p>
2776
- <Progress value={((currentStep + 1) / STEPS.length) * 100} />
2777
- </div>
2778
-
2779
- {/* Desktop step indicator */}
2780
- <nav className="hidden md:flex items-center justify-center" aria-label="Form progress">
2781
- {STEPS.map((step, index) => (
2782
- <div key={step.name} className="flex items-center">
2783
- <button
2784
- type="button"
2785
- onClick={() => handleStepClick(index)}
2786
- disabled={index > currentStep && !completedSteps.has(index)}
2787
- aria-current={index === currentStep ? 'step' : undefined}
2788
- className={\`flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium transition-colors \${
2789
- completedSteps.has(index)
2790
- ? 'bg-primary text-primary-foreground cursor-pointer'
2791
- : index === currentStep
2792
- ? 'border-2 border-primary text-primary'
2793
- : 'border-2 border-muted text-muted-foreground'
2794
- }\`}
2795
- >
2796
- {completedSteps.has(index) ? (
2797
- <Check className="h-4 w-4" />
2798
- ) : (
2799
- index + 1
2800
- )}
2801
- </button>
2802
- {index < STEPS.length - 1 && (
2803
- <div
2804
- className={\`h-0.5 w-8 mx-1 \${
2805
- completedSteps.has(index) ? 'bg-primary' : 'bg-muted'
2806
- }\`}
2807
- />
2808
- )}
2809
- </div>
2810
- ))}
2811
- </nav>
2812
-
2813
2759
  {/* Step header */}
2814
2760
  <div>
2815
2761
  <h3 className="text-lg font-semibold">{STEPS[currentStep].label}</h3>
@@ -2873,14 +2819,14 @@ function generateSingleStepForm(schema, cwd, cmsDir, options) {
2873
2819
  const zodFields = buildZodFields(fields);
2874
2820
  const defaults = buildDefaultValues(fields);
2875
2821
  const listFields = getListFields(fields);
2876
- const hasListFields2 = listFields.length > 0;
2822
+ const hasListFields = listFields.length > 0;
2877
2823
  const { setup: watchSetup } = buildWatchDecls(fields);
2878
2824
  const rawFields = schema.fields || [];
2879
2825
  const fieldJSX = renderFieldsJSX(rawFields);
2880
2826
  const submitText = schema.submitButtonText || "Submit";
2881
2827
  const successMessage = escapeJsx(schema.successMessage || "Form submitted successfully!");
2882
- const rhfImport = hasListFields2 ? `import { useFieldArray, useForm } from 'react-hook-form'` : `import { useForm } from 'react-hook-form'`;
2883
- const fieldArraySetup = hasListFields2 ? `
2828
+ const rhfImport = hasListFields ? `import { useFieldArray, useForm } from 'react-hook-form'` : `import { useForm } from 'react-hook-form'`;
2829
+ const fieldArraySetup = hasListFields ? `
2884
2830
  ${buildFieldArrayDecls(listFields)}
2885
2831
  ` : "";
2886
2832
  const hasRadio = fields.some((f) => f.type === "radio");
@@ -2907,7 +2853,7 @@ export function ${pascal}Form() {
2907
2853
  )
2908
2854
  }
2909
2855
  ` : "";
2910
- const lucideImport = hasListFields2 ? `
2856
+ const lucideImport = hasListFields ? `
2911
2857
  import { Trash2 } from 'lucide-react'` : "";
2912
2858
  const content = `'use client'
2913
2859